You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] AWQ crashes on DeepSeek-V4 (KeyError: 'sliding_attention'): scale-search rotary is called with the architecture layer_type instead of V4's rope_layer_type ('main'/'compress') #4695
AWQ crashes on every DeepSeek-V4 checkpoint in the first scale search. GPTQ on the same model completes.
AWQProcessor._prepare_module_forward (looper/awq_processor.py:4016) rebuilds position_embeddings with rotary(x, pos, **self._rotary_layer_type_kwargs(rotary, module)). _rotary_layer_type_kwargs (:4071-4109) passes the module's architecture layer_type ("sliding_attention", "compressed_sparse_attention", "heavily_compressed_attention").
DeepSeek-V4 deliberately decouples rotary types from architecture types. DeepseekV4RotaryEmbedding.layer_types comes from config.rope_parameters (["main", "compress"]), and the attention selects with self.rope_layer_type = "main" if self.layer_type == "sliding_attention" else "compress" (modeling_deepseek_v4.py:774). So the rotary indexes self.rope_type[layer_type] with an architecture name and raises:
File "gptqmodel/looper/awq_processor.py", line 2598, in _quantize_layer
File "gptqmodel/looper/awq_processor.py", line 3051, in _search_best_scale
File "gptqmodel/looper/awq_processor.py", line 4016, in _prepare_module_forward
module_kwargs["position_embeddings"] = rotary(
File ".../transformers/modeling_rope_utils.py", line 122, in wrapper
rope_type = self.rope_type if layer_type is None else self.rope_type[layer_type]
KeyError: 'sliding_attention'
Repro
Uses the real DeepSeek-V4-Flash config (the 3-layer DeepSeek-V4-Flash-3L-BF16 config.json: layer_types = ['sliding_attention', 'sliding_attention', 'compressed_sparse_attention'], rope_parameters keys ['main', 'compress']). Only n_routed_experts is changed (8), to make it small. Random init.
A tiny AutoConfig.for_model("deepseek_v4") model fails the same way, with KeyError: 'heavily_compressed_attention'.
Suggested fix
In _rotary_layer_type_kwargs, prefer the attention's own rotary selector when it has one (rope_layer_type). More generally, only pass a value that is a key of the rotary's rope_type/layer_types mapping, and otherwise fall back to the captured position_embeddings. DeepSeek-V4 attention computes its own rotary from position_ids, so it may not need AWQ to synthesize position_embeddings at all.
Test that should have caught it
tests/test_awq_scaling_groups.py builds deepseek_v4 groups but never runs _search_best_scale. An AWQ quantize smoke test on a tiny deepseek_v4 config (seconds on CPU/GPU) would hit this immediately.
Severity
High for DeepSeek-V4 / V4-Flash / V4-Pro users: AWQ cannot quantize the family at all.
Activity
ZX-ModelCloud commentedon Nov 17, 2026
Claimed. I'm working on this issue and will submit a fix PR. Please avoid duplicate work in the meantime.
fix(awq): resolve scale-search rotary from the attention rope label (M…