Repository navigation
fix(awq): scale the sibling branch of a shared norm instead of falling back (#4741) - #4772
Merged
Merged
Conversation
…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`.
This was referenced Nov 17, 2026
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.
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.
Closes #4741.
Falcon-H1 declares attention and the Mamba mixer as parallel consumers of
input_layernorm, so_merge_shared_source_nodesmerges their groups into[q_proj, k_proj, v_proj, mamba.in_proj]. There is no shared ancestor below the decoder layer, so the merge keptmodule2inspect = self_attn, and_validate_scale_grouprejected the whole group becausemamba.in_projsits in the siblingmambabranch. Every layer then fell back to plain quantization, so an "AWQ" checkpoint had RTN q/k/v and RTNmamba.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_foldis 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 inapply_scale.Tests
tests/test_awq_falcon_h1_parallel_branch_4741.py:q/k/vand marksmamba.in_projfold-only; nomamba.conv1d -> out_projgroup is built;_search_best_scalecalled withallow_outside_fold=Trueandmamba.in_projinfold_layers, a non-trivial scale, and the norm gain actually divided.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-existingCUDA_HOMEMarlin-JIT build failures (a bf16 case passes withCUDA_HOMEset), andtest_fusion_kernel_backendsalso fails on pristinemain(missingAwqGEMVTorchLinearspec from fix(awq): give FORMAT.GEMV_FAST and LLM_AWQ a CPU in-session reader (#4736) #4753).ruff check gptqmodel testsclean.