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
Audit of main @ a16977e. Both bugs silently change model outputs during AWQ scale folding. The scale search doesn't catch them because it scores the inspected submodule, not the folded norm.
1. scale_ln_fcs only handles (1 + weight) norms for GemmaRMSNorm/Gemma2RMSNorm
gptqmodel/quantization/awq/quantize/scale.py:144-150 checks the offset path with isinstance(ln, GemmaRMSNorm) or isinstance(ln, Gemma2RMSNorm). These norms also compute x * (1 + weight) but don't subclass either one, so they fall through to a plain weight /= s:
Gemma3RMSNorm
Qwen3_5RMSNorm
Qwen3_5MoeRMSNorm
Qwen3NextRMSNorm
The effective gain becomes 1 + w/s instead of (1 + w)/s.
Repro: apply a random AWQ scale via apply_scale(norm, [linear]) and compare norm→linear output before and after.
norm
rel. L2 error
LlamaRMSNorm / Gemma2RMSNorm
~1e-7
Gemma3RMSNorm
0.48
Qwen3_5RMSNorm
0.47
Qwen3_5MoeRMSNorm
0.44
Qwen3NextRMSNorm
0.44
Fix: detect the offset semantics, not a class list. Options: a registry covering Gemma3, Qwen3.5(-MoE), Qwen3-Next, VaultGemma, T5Gemma and others; or a check for 1.0 + self.weight / 1 + self.weight in the forward. Then do w.add_(1).div_(s).sub_(1), ideally in fp32.
2. Gemma2/Gemma3: MLP scale is folded into post_attention_layernorm instead of pre_feedforward_layernorm
awq_get_modules_for_scaling in gptqmodel/models/base.py (~4400-4410) keeps only the first of consecutive non-quantized blocks as prev_op. The Gemma2/3 layer is post_attention_layernorm:! → pre_feedforward_layernorm:! → mlp.gate/up, so prev_op for gate/up ends up as post_attention_layernorm.
That norm's output is added to the residual and then re-normalized by pre_feedforward_layernorm. Dividing it by s is therefore not equivalent to scaling the MLP input, and it also perturbs the residual stream.
Repro: real Gemma2QModel.awq_get_modules_for_scaling on a tiny Gemma2DecoderLayer:
Every Gemma2/Gemma3 AWQ quant is affected. For Gemma3, bug 1 makes it worse.
Fix: use the norm that immediately feeds the consumer block (pre_feedforward_layernorm). Alternatively, mark sandwich post-norms as non-scaling sources in the gemma2/gemma3 module trees.
Follow-up: the offset-gain fold is still not neutral in bf16 when AWQ scales are large. Gemma-3 MLP scales reach ~1e3, so 1+w' cancels in bf16 and gemma-3-1b AWQ PPL goes from 39.8 to 486 (RTN is 48). Details in the new matrix issue, item 1.
Activity
docs(awq): record measured scale-folding errors (#3973)
docs(awq): reference the introducing PR (#3973)
fix(awq): fold scales into the correct norm and resolve offset gains (#…
Qubitium commentedon Nov 14, 2026
Follow-up review of the merged fix found remaining problems; see #4002.
Qubitium commentedon Nov 14, 2026
Follow-up: the offset-gain fold is still not neutral in bf16 when AWQ scales are large. Gemma-3 MLP scales reach ~1e3, so
1+w'cancels in bf16 and gemma-3-1b AWQ PPL goes from 39.8 to 486 (RTN is 48). Details in the new matrix issue, item 1.