Skip to content

fix(awq): keep the norm fold for linear-attention siblings of an absent block (#4732) - #4751

Merged
Qubitium merged 2 commits into
mainfrom
fix/issue-4732
Nov 17, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/issue-4732

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

What

#4708 added refuse_last_module_fallback to awq_get_modules_for_scaling: when the previous block resolved to no module, the last-module fallback must not fold a norm into the wrong producer. On Qwen3.5-text, MiniCPM-V 4.6 and Intern-S2 that drops a real fold.

Those hybrid trees declare self_attn and linear_attn against the same :in=<tag> input. A linear-attention layer owns no self_attn, so the self_attn block is absent, but it still declares that tag. The following linear_attn block therefore read the same tensor the absent block would have read: the two are siblings, not producer/consumer. Refusing the fallback there replaced the valid input_layernorm -> [linear_attn.in_proj_qkv, linear_attn.in_proj_z] with the invalid in_proj_qkv -> in_proj_z, which AWQ then dropped at debug level — so the DeltaNet input group folded nothing.

Fixes #4732 (regression from #4708).

Fix

Track the input tags of a run of absent blocks and allow the last-module fallback when the following block declares the same :in= tag. Full-attention layers are unchanged.

Evidence

  • Red on parent: tests/module_tree/test_awq_fold_safety_4175.py::test_minicpmv_4_6_linear_attn_tags_preserve_layer_output and ::test_intern_s2_preview_linear_attn_tags_preserve_layer_output fail; 9 pass.
  • Green: the same two files (test_awq_fold_safety_4175.py + test_awq_ling2_fold_4677.py, which fix(awq): do not fold a block that follows an absent declaration (#4677) #4708 must keep green) → 11 passed.
  • ruff check gptqmodel/models/base.py clean.

…nt block (#4732)

#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.
@Qubitium
Qubitium merged commit 9ebf50d into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the fix/issue-4732 branch November 17, 2026 13:42
Qubitium added a commit that referenced this pull request Nov 17, 2026
)

#4751 exempted a block from `refuse_last_module_fallback` only when the block
and the preceding absent block shared one `:in=` tag. Hybrid trees whose
alternative mixer branches carry no tag still lost the norm -> projection
group, so the following block silently fell back to plain quantization:

* Granite-4.0-H attention layers (absent `mamba`),
* LFM2 attention layers (absent `conv`),
* Nemotron-H Mamba and MLP layers (absent `mixer.q_proj`/`mixer.o_proj`/
  `mixer.in_proj` siblings),
* Ling 2.0 `input_layernorm -> attention.query_key_value` (absent
  `self_attn` before `attention`).

An absent declaration may only take the fold source away when it is a
data-flow predecessor of the consumer: it must be declared under the same
plan parent as the block and a quantized block of that branch must already
have been emitted (#4677's `attention.q_b/kv_b` before `attention.dense`).
An absent sibling branch (different plan parent) never is, so the norm still
folds. The tagged-tree exemption from #4732 is unchanged.

Tests: tiny granitemoehybrid/lfm2/nemotron_h/bailing_moe layers assert the
norm group is emitted and that folding it is neutral.
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