Repository navigation
fix(awq): do not fold a block that follows an absent declaration (#4677) - #4708
Merged
Merged
Conversation
#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.
This was referenced Nov 17, 2026
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.
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4677 — a regression from my #4429.
#4429 split the remote Ling
attentiontree intoquery_key_value/q_a/kv_a/g(stage 0),q_b/kv_b(stage 1) anddense(stage 2). A Ling 2.0 layer owns no MLA pair, so stage 1 resolved to no module. Thedenseblock then fell back tolast_module, which still pointed atinput_layernormbecause the preceding block ended on an absentg_proj. The two norm-sourced groups merged into:attention.densereads 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_modulefallback. 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 realBailingMoeQModel.awq_get_modules_for_scalingover the Ling subset split:input_layernorm -> [query_key_value, dense]input_layernorm -> [query_key_value]apply_scale+ layer output)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.pyclean.Resolves #4677.