Repository navigation
fix(awq): drop folds whose source has no weight elements - #6663
Merged
Merged
Conversation
added 2 commits
December 1, 2026 15:42
A port materializes a config-disabled projection as a zero-sized Linear. Klear's mlp.shared_experts with n_shared_experts=0 is the concrete case: gate_proj/up_proj are [0, hidden] and down_proj is [hidden, 0]. After #6657 kept declared folds whose first reader captured nothing, the planner also kept a fold whose source is one of those empty projections. planned_group() only checked the module plan and widths, so the node became a scaling group; tests/module_tree/test_klear_local_port.py then sees the shared_experts.up_proj -> down_proj fold in the no-shared plan. Reject a source whose weight tensor has no elements in the shared planner filter. A zero-sized source has no output to divide and no weight to absorb a scale, so the group cannot be folded; the target falls back to plain quantization like any other dropped group. This is general to every definition, not a Klear special case. Refs #6657
The planner unit test fails on main because planned_group() accepts a zero-sized Linear as a fold source, and passes with the fix.
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
#6657 keeps a declared AWQ fold whose first reader captured nothing. A port materializes a config-disabled projection as a zero-sized
Linear; Klear'smlp.shared_expertswithn_shared_experts=0isgate_proj/up_proj = [0, hidden]anddown_proj = [hidden, 0].planned_group()accepted that empty projection as a fold source, somlp.shared_experts.up_proj -> down_projbecame a scaling group on the no-shared variant.tests/module_tree/test_klear_local_port.py::test_awq_folds_are_neutral_on_dense_and_moe_layers[...-no-shared]fails on main for this reason.What Changed
planned_group()now returnsDROPwhen the source'sweighttensor has no elements. A zero-sized source has no output to divide and no weight to absorb a scale, so it cannot be a scaling group; the target falls back to plain quantization like any other dropped group.test_planned_group_rejects_a_zero_size_sourceto the declared-fold planner family.No API or config changes. This is general to every definition, not a Klear special case.
Tests
CPU only,
CUDA_VISIBLE_DEVICES=.Measured Impact
Seeded A/B on NVIDIA GB10 (sm_121), torch 2.15.0+cu132, Qwen2.5-0.5B-Instruct, 64 wikitext rows,
batch_size=1, save + reloadBACKEND.AUTO+ greedy 32 tokens. Main0127a0313vs this branch:MarlinLinearbothAwqMarlinLinearbothModel Support / Module Plan
Not applicable: no model, alias or definition change.
AWQ onboarding safety
test_klear_local_port.pycovers dense/MoE/mixed/periodic/no-shared layouts and all pass with the fix.Logic Flow Documentation
Not applicable: this adds one
DROPverdict inside the existingplanned_group()filter. No control-flow mechanism, resolution order or tensor lifecycle changes.Review Requirements
Kernel Accuracy Requirements
Not applicable: planner filter only; no kernel, dispatch or fusion change.
Notes
Refs #6657. The regression is reproducible on
0127a0313and disappears with the one-condition drop. Pre-existing failures seen on this host (missing/monster/datafixtures, optional deps) are unrelated.