Skip to content

fix(awq): do not fold a block that follows an absent declaration (#4677) - #4708

Merged
Qubitium merged 1 commit into
mainfrom
fix/ling-awq-dense-fold-4677
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/ling-awq-dense-fold-4677

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4677 — a regression from my #4429.

#4429 split the remote Ling attention tree into query_key_value/q_a/kv_a/g (stage 0), q_b/kv_b (stage 1) and dense (stage 2). A Ling 2.0 layer owns no MLA pair, so stage 1 resolved to no module. The dense block then fell back to last_module, which still pointed at input_layernorm because the preceding block ended on an absent g_proj. The two norm-sourced groups merged into:

input_layernorm -> [attention.query_key_value, attention.dense]

attention.dense reads the attention output, not the normed hidden state, so AWQ rescaled its input columns with no compensation — 13–14% logit change from the fold alone on Ling-mini-2.0.

The block walk now records whether the previous block declared only modules this layer does not own, and the next block refuses the last_module fallback. The group is left unscaled, which is exactly the pre-#4429 behavior (6.2e-07 fold error). Everything else about source selection is unchanged.

I did not take the issue's alternative (re-numbering the definition): stage 2 is only reachable when the MLA pair is present, and the code fix covers both layouts without a second static split.

Validation

tests/test_awq_ling2_fold_4677.py (new) builds a Ling-2.0-shaped layer (input_layernorm + attention.query_key_value/attention.dense) and runs the real BailingMoeQModel.awq_get_modules_for_scaling over the Ling subset split:

case before after
Ling 2.0 group structure input_layernorm -> [query_key_value, dense] input_layernorm -> [query_key_value]
Ling 2.0 fold invariance (apply_scale + layer output) logits change unchanged (rtol 1e-5)
Ling 2.6 MLA control dense not norm-folded unchanged

Pre-fix the file fails 3 of 4; post-fix 4 passed.

Regression sweep: tests/test_awq_scaling_groups.py (the output-preservation invariant over every registered family) plus the bailing MLA module-tree test and the new file → 159 passed, 9 skipped. ruff check gptqmodel docs/eora tests setup.py clean.

Resolves #4677.

#4429 split the remote Ling `attention` tree into
`query_key_value/q_a/kv_a/g` (0), `q_b/kv_b` (1) and `dense` (2). A Ling 2.0
layer owns no MLA pair, so block 1 resolved to no module; the `dense` block
then fell back to `last_module`, which still pointed at `input_layernorm`
because the preceding block ended on an absent `g_proj`. The two norm-sourced
groups merged into `input_layernorm -> [query_key_value, dense]`, rescaling
`attention.dense`'s input columns with no compensation (13-14% logit change).

Track whether the previous block declared only modules this layer does not
own and refuse the `last_module` fallback for the next block. The group is
then left unscaled, which is the pre-#4429 behavior; nothing else about the
selection changes.
@Qubitium
Qubitium merged commit e2a5ff6 into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the fix/ling-awq-dense-fold-4677 branch November 17, 2026 10:24
Qubitium added a commit that referenced this pull request Nov 17, 2026
…nt block (#4732) (#4751)

#4708's refuse_last_module_fallback drops the last-module fallback when the
previous block resolved to no module, which broke Qwen3.5-text, MiniCPM-V 4.6
and Intern-S2 layers: their self_attn block is absent on a linear-attention
layer, so the DeltaNet input group lost input_layernorm -> in_proj_qkv/z and
AWQ folded nothing.

A block that declares the same :in=<tag> input as the absent block is its
sibling, not its consumer, so the norm before them is still this block's
producer. Track the absent block's input tags and allow the fallback when the
following block reads the same tensor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant