Skip to content

fix(awq): keep the norm fold for an absent sibling branch (#4759) - #4800

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

Qubitium merged 2 commits into
mainfrom
fix/issue-4759

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Problem

#4751 exempted a block from refuse_last_module_fallback (#4708) only when the current block and the preceding absent block share one :in= tag. Hybrid trees whose alternative branches carry no tag still lost the norm -> projection AWQ group whenever a sibling branch was absent:

tree absent branch result
Granite-4.0-H mamba on an attention layer input_layernorm -> [q,k,v] dropped
LFM2 conv on an attention layer operator_norm -> [q,k,v] dropped
Nemotron-H mixer attention/mamba/MLP alternatives every Mamba/MLP layer silently RTN
Ling 2.0 (bailing_moe) self_attn before attention input_layernorm -> query_key_value dropped

Fix

gptqmodel/models/base.py: refuse_last_module_fallback now requires the absent run to be a data-flow predecessor, not merely absent. It tracks the absent run's plan parents and the plan parents of quantized blocks already emitted since the last declared non-quant block, and refuses the fallback only when both intersect the current block's parents.

The :in= tag exemption from #4732 is untouched.

Tests

tests/module_tree/test_awq_fold_safety_4175.py (+244): four new "the norm still folds" tests with fold-neutrality assertions — tiny granitemoehybrid (attention), lfm2 (attention), nemotron_h (M/-/* layers: norm -> mixer.in_proj, norm -> mixer.up_proj, norm -> q/k/v), and bailing_moe (input_layernorm -> [attention.query_key_value], no dense).

Red on parent (source stashed, tests kept): 4 failed — "attention input norm did not fold after the absent mamba sibling branch", same for conv, nemotron "type: no foldable AWQ group was emitted", bailing got [] for input_layernorm.

Verification

  • test_awq_fold_safety_4175.py + test_awq_scaling_groups.py + test_awq_moe_starved_expert_group_4675.py + test_awq_ling2_fold_4677.py: 170 passed, 9 skipped
  • with the clip/mean/per-module AWQ suites: 197 passed, 89 skipped
  • ruff check gptqmodel tests: clean

Closes #4759

#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