Skip to content

fix(awq): scale the sibling branch of a shared norm instead of falling back (#4741) - #4772

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

Qubitium merged 2 commits into
mainfrom
fix/issue-4741

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Closes #4741.

Falcon-H1 declares attention and the Mamba mixer as parallel consumers of input_layernorm, so _merge_shared_source_nodes merges their groups into [q_proj, k_proj, v_proj, mamba.in_proj]. There is no shared ancestor below the decoder layer, so the merge kept module2inspect = self_attn, and _validate_scale_group rejected the whole group because mamba.in_proj sits in the sibling mamba branch. Every layer then fell back to plain quantization, so an "AWQ" checkpoint had RTN q/k/v and RTN mamba.in_proj.

The captured replay input is the post-norm activation, so the decoder layer cannot be the boundary (it would apply the norm twice). Split the group instead: score the members the current boundary covers and fold the same scale into the sibling branch — every member reads that one tensor, so the fold is correct for all of them. allow_outside_fold is set only for a group the tree declares across sibling branches; the containment check stays for every other group.

Also drop scaling groups whose source cannot absorb a fold (mamba.conv1d, weightless/gated norms) at build time instead of searching them and discarding the result in apply_scale.

Tests

  • tests/test_awq_falcon_h1_parallel_branch_4741.py:
    • structural: the merged group searches q/k/v and marks mamba.in_proj fold-only; no mamba.conv1d -> out_proj group is built;
    • end-to-end (tiny Falcon-H1, CPU AWQ): no fallback warning, _search_best_scale called with allow_outside_fold=True and mamba.in_proj in fold_layers, a non-trivial scale, and the norm gain actually divided.
  • Red on parent: both tests fail (KeyError: '_awq_allow_outside_fold', fallback assertion).

Verification

  • pytest tests/test_awq_scaling_groups.py tests/test_awq_falcon_h1_parallel_branch_4741.py -> 154 passed, 9 skipped (the output-preservation invariant for every registered family, incl. all MoE families).
  • pytest tests/module_tree tests/test_tiny_moe_quant_smoke.py -> 1789 passed, 302 skipped; the 470 failures are the pre-existing CUDA_HOME Marlin-JIT build failures (a bf16 case passes with CUDA_HOME set), and test_fusion_kernel_backends also fails on pristine main (missing AwqGEMVTorchLinear spec from fix(awq): give FORMAT.GEMV_FAST and LLM_AWQ a CPU in-session reader (#4736) #4753).
  • ruff check gptqmodel tests clean.

…g back (#4741)

Falcon-H1 declares attention and the Mamba mixer as parallel consumers of
`input_layernorm`, so the merged scaling group is
`[q_proj, k_proj, v_proj, mamba.in_proj]`. `_merge_shared_source_nodes`
could not widen `module2inspect` past `self_attn` (there is no shared
ancestor below the decoder layer), and `_validate_scale_group` rejected the
whole group, so every layer fell back to plain quantization for q/k/v and
`mamba.in_proj`.

The replay input is the post-norm activation, so the decoder layer cannot be
the boundary (it would apply the norm twice). Split the group instead: score
the members the current boundary covers and fold the same scale into the
sibling branch, since every member reads that one tensor. `allow_outside_fold`
keeps the containment check for every other group.

Also drop scaling groups whose source cannot absorb a fold (`mamba.conv1d`,
weightless or gated norms) at build time instead of searching them and
discarding the result in `apply_scale`.
@Qubitium
Qubitium merged commit 9a63019 into main Nov 17, 2026
8 checks passed
@Qubitium
Qubitium deleted the fix/issue-4741 branch November 17, 2026 14:33
sLaffey pushed a commit to sLaffey/GPTQModel that referenced this pull request Nov 18, 2026
…odelCloud#4898) (ModelCloud#5002)

Cohere2-MoE reads one `input_layernorm` from two parallel branches
(`self_attn` and the MoE block), and the MoE router consumes the same normed
input. `_merge_shared_source_nodes` already splits such a group (ModelCloud#4772): the
members the replay boundary covers are scored, the rest are fold-only
(`_awq_allow_outside_fold`). But `_validate_scale_group` exempted only the
fold-only *targets* from the containment check, so the router - a
`_scale_consumers` entry - still had to live inside `self_attn`. It never can,
so every layer rejected the group and sent q/k/v plus every routed and shared
expert gate/up to plain quantization behind one per-layer warning.

With `_awq_allow_outside_fold`, only the members the search scores must be
replayed; out-of-boundary members and consumers are folded, and `apply_scale`
still compensates every declared consumer through its consumer map. The fold is
exact because the router reads the same normed tensor.

`tests/test_awq_cohere2_moe_parallel_norm_4898.py` reproduces it end to end on a
tiny `cohere2_moe`: on unmodified main every layer logs "replay boundary
`self_attn` does not contain targets ['mlp.gate']" and q/k/v keep
`loss=not applicable`; with the fix the group is scored and folded.
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