Skip to content

fix(awq): keep a declared fold whose first reader captured nothing - #6657

Merged
Qubitium merged 1 commit into
mainfrom
fix/awq-declaration-empty-capture-group
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/awq-declaration-empty-capture-group

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

The fold-declaration AWQ planner dropped a declared fold whenever its first
feature was absent or empty. On a MoE gate/up group the feature is the root
capture when it holds rows (#4760); a seeded-but-uncaptured root (an empty
tensor) therefore skipped the whole group, even though every routed expert had
its own capture. The layer lost a fold the tree planner keeps, and the planner
could no longer tell the processor that the group's readers share the norm, so
an excluded/starved reader could not veto the fold (#6630).

The declaration planner now uses the tracker's feature precedence: the MoE root
only when it holds rows, otherwise the first reader with a capture; if no reader
captured anything it keeps the node with inp=None and the full declared target
set. The processor's fallback check then owns the group: a group with a starved
member is not folded, and a group whose members are all captured folds
neutrally on the captured member's feature. This is a behavior fix for
declaration-path types whenever a capture is empty or absent; full-capture plans
are unchanged for every type.

Fixes #4697 (the empty-root case now folds on a captured member instead of
dropping the group) and completes the declaration-path half of #6630.

What Changed

  • gptqmodel/models/base.py — _awq_nodes_from_declarations:
  • docs/awq-scaling-groups.md — the declared-fold contract and the planner
    flow diagram now describe the kept node and the processor fallback.
  • tests/test_awq_declaration_empty_capture.py — new real-model regression on
    Qwen2-MoE and Qwen3-MoE tiny local ports: an empty root keeps the full
    gate/up group, the fold is neutral, an uncaptured reader stays in the group,
    folding around it drifts, and folding the full set is neutral.
  • Updated tests that pinned the old "skip the fold" outcome to the new
    contract: tests/module_tree/test_awq_fold_declarations.py,
    tests/test_awq_moe_root_capture_4697.py,
    tests/module_tree/test_deepseek_v4_local_port.py,
    tests/module_tree/test_intern_s2_preview_local_port.py,
    tests/test_hymba_local_port.py, and the processor fixture in
    tests/test_lfm3_native_coverage.py (it passed full module names where the
    processor uses layer-relative names, and inference tensors where it divides
    the replay feature in place).

Behavior change: with fallback=None, an empty (not absent) capture now fails
closed with _AWQScaleGroupError instead of silently skipping the fold; the
documented fallback=None contract already propagates that error. With the
default fallback the group quantizes plainly, and absent readers are skipped by
the processor's missing-feature check.

Out of scope: the 23 _EMPTY_CAPTURE tracker keeps are released by PR-B after
this lands; no definition opt-out is touched here.

Tests

# full-capture plans: no change for any type
HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES= \
  PYTHONPATH=$PWD:$PWD/tests /root/venv/bin/python -P \
  tests/module_tree/awq_fold_inventory.py --check
# -> changed: none

# inventory contract (210 MODEL_MAP types)
HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES= \
  PYTHONPATH=$PWD:$PWD/tests /root/venv/bin/python -P -m pytest -q \
  tests/module_tree/test_awq_fold_inventory.py
# -> 765 passed

# new red/green regression
HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES= \
  PYTHONPATH=$PWD:$PWD/tests /root/venv/bin/python -P -m pytest -q \
  tests/test_awq_declaration_empty_capture.py
# branch: 4 passed; origin/main: 4 failed
#   AssertionError: the empty-root MoE gate/up fold was dropped

# affected family tests (all pass on the branch)
HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES= \
  PYTHONPATH=$PWD:$PWD/tests /root/venv/bin/python -P -m pytest -q \
  tests/module_tree/test_awq_fold_declarations.py \
  tests/test_awq_moe_root_capture_4697.py \
  tests/module_tree/test_deepseek_v4_local_port.py \
  tests/module_tree/test_intern_s2_preview_local_port.py \
  tests/test_hymba_local_port.py tests/test_lfm3_native_coverage.py \
  tests/test_awq_moe_prune_uncovered_4456.py tests/test_awq_empty_groups.py \
  tests/test_awq_moe_shared_expert_group_4760.py \
  tests/test_awq_moe_starved_expert_group_4675.py \
  tests/module_tree/test_awq_dynamic_excluded_reader.py
# -> 164 passed, 1 skipped

# AWQ CPU unit baseline
PATH=/root/venv/bin:$PATH HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 \
  CUDA_VISIBLE_DEVICES= PYTHONPATH=$PWD:$PWD/tests bash tests/run_awq_cpu.sh unit
# -> 1412 passed, 103 skipped; 2 docs examples hit the 240 s execution budget
#    under parallel load. tests/test_docs_contract_refs.py alone: 267 passed.

# E2 (the 189 files in e2_files.txt), origin/main vs branch
bash run_e2.sh <base> base   # -> 1 failed, 6772 passed, 758 skipped, 3 xfailed
bash run_e2.sh <branch> branch2
# -> 1 failed, 6772 passed, 758 skipped, 3 xfailed
# the one failure is pre-existing on both sides:
# tests/test_local_model_loading.py::test_bypass_requires_explicit_trust_and_is_rechecked_on_retry

# formatting
PATH=/root/venv/bin:/tmp/awq-shim:$PATH bash format/check.sh
# -> ruff 0.14.2; All checks passed!

# full-capture width-coincidence stress A/B
AB_TYPES=<156 declaration-path types> PYTHONPATH=<repo> python -P ab_stress.py \
  --repo <repo> --out <json>
python -P ab_stress.py --compare base.json branch.json
# -> cases=403, equal=403, differ=0 (30 config build errors on both sides)

GPU AWQ A/B (gpu_ab.py, GPU index 2, fixed seed, Salesforce/wikitext-2
calibration, every checkpoint tensor compared byte-for-byte):

model tensors result
Qwen/Qwen2.5-0.5B-Instruct (control) 626 bit-identical
allenai/OLMoE-1B-7B-0924 (MoE) 9491 bit-identical

Perturb A/B: declaration-path types whose plan changes

Two seeds of empty20, absent20, root_empty, and unrouted over every
config variant (plus +mha) of the 156 declaration-path MODEL_MAP types,
base f442095e2 (current main) vs branch. 144 types change; no type
removes or changes an existing group
, and no full plan differs. The
branch only adds nodes:

  • 39 types gain a fold (ok) under root_empty/empty20: the group is
    searched on the first captured reader and folds every declared target.
  • 142 types gain a fallback node for an empty first feature: the processor
    falls the group back to plain quantization instead of folding it.
  • 130 types gain a node whose targets are all absent (drop): the
    processor's missing-feature check skips it.
Per-type exact group delta (144 types)

Perturb A/B: declaration-path types whose plan changed (base vs branch)

No type removed or changed an existing group; every difference is an added node.
# templates one routed expert. A drop node has at least one declared target absent from
input_feat (the processor skips it); a fallback node has an empty feature (the processor
does not fold it); an ok node is a fold the base planner dropped.

type perturbations added groups (source -> targets [status])
agnes absent20:3,empty20:9 input_layernorm -> 2 [fallback]; input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
axk2 absent20:4,empty20:1 mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]
baichuan absent20:2,empty20:3 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
bloom absent20:3,empty20:3 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; post_attention_layernorm -> 1 [drop]; post_attention_layernorm -> 1 [fallback]
brumby absent20:1,empty20:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
chatglm absent20:15,empty20:15 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; post_attention_layernorm -> 1 [drop]; post_attention_layernorm -> 1 [fallback]
cohere empty20:6 input_layernorm -> 5 [fallback]
cohere2 absent20:3,empty20:5 input_layernorm -> 5 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
cohere2_moe absent20:6,empty20:2 mlp.experts.#.up_proj -> 1 [drop]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
cohere_compass empty20:1 input_layernorm -> 5 [fallback]
deepseek_ocr2 absent20:5,empty20:4,root:2 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 18 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
deepseek_v2 absent20:12,empty20:6,root:6 input_layernorm -> 2 [drop]; input_layernorm -> 2 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; post_attention_layernorm -> 130 [ok]
deepseek_v4 absent20:12,empty20:4,root:6 input_layernorm -> 2 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; post_attention_layernorm -> 514 [ok]
deepseek_vl absent20:3,empty20:4 post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
diffusion_gemma absent20:5,empty20:5,root:4 experts.0.up_proj -> 1 [drop]; experts.1.up_proj -> 1 [drop]; experts.2.up_proj -> 1 [drop]; experts.3.up_proj -> 1 [drop]; input_layernorm -> 2 [fallback]; input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]; pre_feedforward_layernorm_2 -> 8 [ok]
dots1 absent20:6,empty20:3,root:4 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; post_attention_layernorm -> 18 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
dream absent20:2,empty20:3 post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
ernie4_5 absent20:1,empty20:4 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
exaone4 absent20:5,empty20:5 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
exaone4_5_text absent20:2,empty20:2 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]
falcon_mamba absent20:4,empty20:4 norm -> 1 [drop]; norm -> 1 [fallback]
gemma empty20:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
gemma2 absent20:1,empty20:1 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]
gemma3 absent20:2,empty20:5 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
gemma3_text absent20:2,empty20:5 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]
gemma3n absent20:3,empty20:6 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]
gemma3n_text absent20:2,empty20:3 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]
gemma4 absent20:12,empty20:16,root:6 experts.1.up_proj -> 1 [drop]; experts.2.up_proj -> 1 [drop]; experts.3.up_proj -> 1 [drop]; experts.5.up_proj -> 1 [drop]; experts.6.up_proj -> 1 [drop]; experts.7.up_proj -> 1 [drop]; input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]; pre_feedforward_layernorm_2 -> 16 [ok]
gemma4_text absent20:15,empty20:27,root:6 experts.0.up_proj -> 1 [drop]; experts.1.up_proj -> 1 [drop]; experts.4.up_proj -> 1 [drop]; experts.5.up_proj -> 1 [drop]; experts.6.up_proj -> 1 [drop]; experts.7.up_proj -> 1 [drop]; input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; input_layernorm -> 2 [fallback]; input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [drop]; pre_feedforward_layernorm -> 2 [fallback]; pre_feedforward_layernorm_2 -> 16 [ok]
gemma4_unified absent20:3,empty20:11 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]
gemma4_unified_text absent20:6,empty20:9 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]
glm absent20:3,empty20:3 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
glm4 absent20:1,empty20:3 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
glm4_moe_lite absent20:4,empty20:2,root:2 input_layernorm -> 2 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 130 [ok]
glm_moe_dsa absent20:5,empty20:4,root:2 mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; post_attention_layernorm -> 514 [ok]
glm_ocr empty20:5 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
glmasr absent20:1,empty20:4 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
gpt_bigcode absent20:5,empty20:5 ln_1 -> 1 [drop]; ln_1 -> 1 [fallback]; ln_2 -> 1 [drop]; ln_2 -> 1 [fallback]
gpt_neo absent20:1,empty20:3 attn.attention.v_proj -> 1 [drop]; attn.attention.v_proj -> 1 [fallback]; ln_1 -> 3 [fallback]
gpt_neox absent20:4,empty20:4 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; post_attention_layernorm -> 1 [drop]; post_attention_layernorm -> 1 [fallback]
gpt_oss absent20:2,empty20:4,root:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 256 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
gptj absent20:1,empty20:1 attn.v_proj -> 1 [drop]; attn.v_proj -> 1 [fallback]
granite absent20:2,empty20:5 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
granite_swa empty20:1 post_attention_layernorm -> 2 [fallback]
granitemoe absent20:7,empty20:5,root:4 block_sparse_moe.experts.#.up_proj -> 1 [drop]; input_layernorm -> 3 [fallback]; post_attention_layernorm -> 16 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
granitemoe_swa absent20:7,empty20:4,root:4 block_sparse_moe.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 16 [fallback]; post_attention_layernorm -> 16 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
granitemoehybrid absent20:7,empty20:4 block_sparse_moe.experts.#.up_proj -> 1 [drop]; input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; mamba.norm -> 1 [drop]; mamba.norm -> 1 [fallback]
grinmoe absent20:8,empty20:5,root:4 block_sparse_moe.experts.#.w3 -> 1 [drop]; input_layernorm -> 3 [fallback]; post_attention_layernorm -> 32 [ok]
helium absent20:3,empty20:5 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
hunyuan_v1_dense absent20:4,empty20:4 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
hunyuan_v1_moe absent20:8,empty20:4,root:4 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_mlp.up_proj -> 1 [drop]; mlp.shared_mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 130 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
hunyuan_vl absent20:2,empty20:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
hy_v3 absent20:4,empty20:2,root:2 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; post_attention_layernorm -> 386 [ok]
hymba absent20:14,empty20:11,root:16 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; moe.experts.#.up_proj -> 1 [drop]; pre_moe_layernorm -> 1 [ok]; pre_moe_layernorm -> 2 [ok]; pre_moe_layernorm -> 16 [ok]; pre_moe_layernorm -> 32 [fallback]; pre_moe_layernorm -> 32 [ok]
inkling_mm_model absent20:8,empty20:1 input_layernorm -> 4 [fallback]; mlp.experts.#.up_proj -> 1 [drop]
instella absent20:3,empty20:5 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_attention_layernorm -> 3 [fallback]; pre_feedforward_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
intern_s2_preview absent20:24,empty20:11,root:12 input_layernorm -> 2 [drop]; input_layernorm -> 2 [fallback]; input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [fallback]; post_attention_layernorm -> 514 [drop]; post_attention_layernorm -> 514 [fallback]; post_attention_layernorm -> 514 [ok]
internlm absent20:1,empty20:3 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
internlm2 absent20:6,empty20:8 attention_norm -> 1 [drop]; attention_norm -> 1 [fallback]; feed_forward.w3 -> 1 [drop]; feed_forward.w3 -> 1 [fallback]; ffn_norm -> 2 [fallback]
interns1 empty20:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
internvl absent20:1,empty20:3 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
internvl_chat empty20:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
jamba absent20:10,empty20:11,root:2 feed_forward.experts.#.up_proj -> 1 [drop]; feed_forward.up_proj -> 1 [drop]; feed_forward.up_proj -> 1 [fallback]; input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; input_layernorm -> 3 [fallback]; pre_ff_layernorm -> 2 [fallback]; pre_ff_layernorm -> 32 [fallback]; pre_ff_layernorm -> 32 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
k2_horizon absent20:18,empty20:14,root:8 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; post_attention_layernorm -> 202 [ok]; post_attention_layernorm -> 256 [ok]; post_attention_layernorm -> 386 [ok]
klear absent20:8,empty20:5,root:4 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; post_attention_layernorm -> 258 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
laguna absent20:5,empty20:3,root:2 mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 514 [ok]
lfm2_moe absent20:4,empty20:2,root:2 feed_forward.experts.#.up_proj -> 1 [drop]; ffn_norm -> 16 [ok]; operator_norm -> 1 [drop]; operator_norm -> 1 [fallback]
lfm3 absent20:1,empty20:3 ffn_norm -> 2 [fallback]; operator_norm -> 1 [drop]; operator_norm -> 1 [fallback]
lfm3_omni absent20:3,empty20:5 ffn_norm -> 2 [fallback]; operator_norm -> 1 [drop]; operator_norm -> 1 [fallback]
lfm3_vl absent20:10,empty20:14 feed_forward.w3 -> 1 [drop]; feed_forward.w3 -> 1 [fallback]; ffn_norm -> 2 [fallback]; operator_norm -> 1 [drop]; operator_norm -> 1 [fallback]
llada2_moe absent20:10,empty20:9,root:4 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; post_attention_layernorm -> 514 [ok]
llama absent20:6,empty20:10 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
llava absent20:5,empty20:6 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
llava_qwen2 empty20:5 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
locateanything absent20:2,empty20:5 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
longcat_flash absent20:8,empty20:2 mlp.experts.#.up_proj -> 1 [drop]; mlps.1.up_proj -> 1 [drop]; mlps.1.up_proj -> 1 [fallback]
marin absent20:1,empty20:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
mimo absent20:3,empty20:5 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
minicpm absent20:3,empty20:5 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
minicpm3 absent20:1,empty20:5 input_layernorm -> 2 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
minicpmo absent20:4,empty20:4 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
minicpmv absent20:2,empty20:11 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
minicpmv4_6 empty20:5 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
minimax_m2 absent20:8,empty20:4,root:4 mlp.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 512 [fallback]; post_attention_layernorm -> 512 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
ministral3 absent20:3,empty20:6 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
mistral absent20:1,empty20:3 post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
mistral3 absent20:4,empty20:4 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
mixtral absent20:7,root:4 mlp.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 16 [ok]
mllama absent20:1,empty20:3 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
mllama_text_model absent20:4,empty20:6 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
mobilellm absent20:1,empty20:3 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
mpt absent20:3,empty20:3 norm_1 -> 1 [drop]; norm_1 -> 1 [fallback]; norm_2 -> 1 [drop]; norm_2 -> 1 [fallback]
muse_glimmer absent20:1,empty20:4 input_layernorm -> 4 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]
nemotron_h absent20:2,empty20:3 norm -> 1 [drop]; norm -> 1 [fallback]; norm -> 3 [fallback]
nemotron_labs_diffusion absent20:1,empty20:4 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]
olmo absent20:3,empty20:3 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
olmo2 absent20:3,empty20:3 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
olmo3 absent20:1,empty20:1 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]
olmoe absent20:8,empty20:5,root:4 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 128 [fallback]; post_attention_layernorm -> 128 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
opt absent20:3,empty20:5 fc1 -> 1 [drop]; fc1 -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]; self_attn_layer_norm -> 3 [fallback]
ouro absent20:4,empty20:4 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
ovis absent20:3,empty20:5 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
ovis2 absent20:1,empty20:2 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
ovis2_5 absent20:1,empty20:2 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]
ovis2_6_moe absent20:8,empty20:4,root:4 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 256 [ok]
ovis2_6_next absent20:12,empty20:4,root:6 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [fallback]; post_attention_layernorm -> 1026 [ok]
phi absent20:4,empty20:4 self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
phi3 absent20:4,empty20:6 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
phi4mm absent20:9,empty20:9 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; post_attention_layernorm -> 1 [drop]; post_attention_layernorm -> 1 [fallback]
phimoe absent20:7,empty20:2,root:4 input_layernorm -> 3 [drop]; input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 32 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen2 absent20:4,empty20:4 mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen2_5_omni absent20:2,empty20:6 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen2_5_vl absent20:2,empty20:3 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen2_5_vl_text absent20:2,empty20:6 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
qwen2_audio absent20:2,empty20:4 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen2_moe absent20:8,empty20:7,root:4 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [fallback]; post_attention_layernorm -> 122 [fallback]; post_attention_layernorm -> 122 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen2_vl absent20:2,empty20:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen2_vl_text absent20:1,empty20:3 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen3 absent20:1,empty20:4 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen3_5_moe absent20:12,empty20:6,root:6 input_layernorm -> 2 [fallback]; input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [fallback]; post_attention_layernorm -> 514 [ok]
qwen3_5_moe_text absent20:12,empty20:5,root:6 input_layernorm -> 2 [fallback]; input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [fallback]; post_attention_layernorm -> 514 [fallback]; post_attention_layernorm -> 514 [ok]
qwen3_5_text absent20:2,empty20:5 input_layernorm -> 2 [fallback]; input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen3_moe absent20:8,empty20:2,root:4 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 256 [fallback]; post_attention_layernorm -> 256 [ok]
qwen3_omni_moe absent20:8,empty20:4,root:4 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; post_attention_layernorm -> 256 [fallback]; post_attention_layernorm -> 256 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
qwen4_exp absent20:6,empty20:1 mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [drop]; mlp.shared_expert.up_proj -> 1 [fallback]
qwen4_exp_text absent20:4 mlp.experts.#.up_proj -> 1 [drop]
raon1_mini empty20:8,root:8 input_layernorm -> 3 [fallback]; input_layernorm -> 7 [fallback]; post_attention_layernorm -> 2 [fallback]; post_attention_layernorm -> 258 [fallback]; post_attention_layernorm -> 258 [ok]
ricursive absent20:3,empty20:12 input_layernorm -> 4 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; pre_feedforward_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
seed_oss empty20:2 input_layernorm -> 3 [fallback]
smollm3 absent20:3,empty20:5 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
smolvlm empty20:3 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
solar_open absent20:8,empty20:6,root:4 input_layernorm -> 3 [drop]; input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; post_attention_layernorm -> 258 [fallback]; post_attention_layernorm -> 258 [ok]
solar_open2 absent20:29,empty20:16,root:16 input_layernorm -> 3 [fallback]; input_layernorm -> 4 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; post_attention_layernorm -> 10 [ok]; post_attention_layernorm -> 642 [fallback]; post_attention_layernorm -> 642 [ok]
spark2_5 absent20:4,empty20:6 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
stablelm absent20:2,empty20:7 input_layernorm -> 3 [fallback]; input_layernorm -> 5 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
starcoder2 absent20:1,empty20:1 self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
telechat absent20:8,empty20:11 input_layernorm -> 2 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]
unlimited-ocr absent20:5,empty20:4,root:2 mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; post_attention_layernorm -> 130 [fallback]; post_attention_layernorm -> 130 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
unlimited_ocr absent20:7,empty20:6,root:2 input_layernorm -> 3 [fallback]; mlp.experts.#.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [drop]; mlp.shared_experts.up_proj -> 1 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 130 [ok]; self_attn.v_proj -> 1 [drop]; self_attn.v_proj -> 1 [fallback]
voxtral empty20:3 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
xverse empty20:6 input_layernorm -> 3 [fallback]; post_attention_layernorm -> 2 [fallback]
zamba absent20:7,empty20:7 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; mamba_decoder.input_layernorm -> 1 [drop]; mamba_decoder.input_layernorm -> 1 [fallback]
zamba2 absent20:6,empty20:6 input_layernorm -> 1 [drop]; input_layernorm -> 1 [fallback]; mamba_decoder.input_layernorm -> 1 [drop]; mamba_decoder.input_layernorm -> 1 [fallback]
zdtaichu5_0 absent20:3,empty20:7 input_layernorm -> 3 [fallback]; mlp.up_proj -> 1 [drop]; mlp.up_proj -> 1 [fallback]; post_attention_layernorm -> 2 [fallback]

total types: 144

Measured Impact

Not applicable: no kernel, format, or runtime math change. Full-capture AWQ
plans and saved checkpoints are unchanged (inventory changed: none, stress
A/B 0 differences, GPU A/B bit-identical on the control and the MoE model).
The behavior change is limited to empty/absent captures, where the group now
falls back or folds on a captured member instead of being dropped.

Model Support / Module Plan

Not applicable: no new MODEL_MAP entry, alias, or definition change. The
module-plan inventory fixture is unchanged; awq_fold_inventory.py --check
reports changed: none.

AWQ onboarding safety

  • Native forward evidence: the new tests run the real Qwen2-MoE/Qwen3-MoE tiny
    local ports, capture the layer inputs from a native forward, and apply the
    emitted fold to every target and non-quantized consumer. The empty-root group
    folds with a captured expert's input (the same post-norm tensor every expert
    reads) and is output-neutral (0.0 relative logits change). Folding the norm
    into the captured siblings only changes the output, which is why the
    uncaptured reader stays in the group.
  • The processor's fallback check sees the starved member: a group with an
    absent/empty member is not folded (the starved member is folded then
    plain-quantized for a MoE gate/up group, [QUALITY] AWQ MoE: one starved, unrouted or dynamic-excluded expert sends ALL experts' gate/up to RTN (one all-or-nothing scale group); default AWQ on Qwen3-30B-A3B RTNs all 256 expert gate/up per layer #4675; a dense group falls back
    whole).
  • tests/test_awq_moe_shared_expert_group_4760.py,
    tests/test_awq_moe_starved_expert_group_4675.py,
    tests/test_awq_moe_prune_uncovered_4456.py,
    tests/test_awq_empty_groups.py, and
    tests/module_tree/test_awq_dynamic_excluded_reader.py pass.
  • Every declaration-path type remains qualified on full captures: inventory
    changed: none and the width-coincidence stress A/B has 0 differences.

Logic Flow Documentation

  • The control-flow change is documented in docs/awq-scaling-groups.md:
    the declared-fold flow now keeps the node (inp=None) and the processor
    fallback owns it; the hand-declared skip and the routed-expert down
    exception are marked.
  • The new-flow Mermaid diagram uses the real symbols
    (_awq_nodes_from_declarations, merge_by_source,
    generate_node_for_awq_scaling, AWQProcessor._quantize_layer).
  • The replaced mechanism (skip the fold when no feature was captured) is
    shown in the diagram and described in the contract text.
  • Failure/fallback paths are visually distinct (keep node with inp=None,
    skip group).
  • The reference page is docs/awq-scaling-groups.md, already linked from
    the AWQ documentation set.

Review Requirements

  • Reviewed this PR.
  • Matches existing project structure, APIs, and conventions.
  • No monkeypatching; the fix is in the owning planner.
  • Minimized and compacted the impacted code surface.
  • Considered regressions: full-capture inventory, stress A/B, E2, and GPU
    A/B; existing tests updated only where they pinned the old skip behavior.

Kernel Accuracy Requirements

Not applicable: no kernel, packing, dispatch, or fusion change.

Notes

  • fallback=None + an empty (not absent) capture now fails closed with
    _AWQScaleGroupError instead of silently dropping the fold. This is the
    documented fallback=None contract; the default fallback quantizes plainly.
  • The updated test_lfm3_native_coverage.py fixture now passes layer-relative
    module names and normal tensors to the processor, matching production
    (state.modules[module.name], replay features are divided in place). The old
    fixture's full names only worked because the planner skipped every group.

🤖 Generated with Claude Code

The fold-declaration planner skipped a declared fold when its first
feature was absent or empty. For a MoE gate/up group whose root capture
was seeded but empty (a missing capture hook, a dynamic exclusion), this
dropped a fold the tree planner keeps and could not tell the processor
that the group's readers share the source (#6630).

Use the tracker's feature precedence: the MoE root only when it holds
rows, else the first declared target with a capture; when none captured
anything, keep the node with `inp=None` and the full target set. The
processor's fallback check then sees the starved members and does not
fold the source without them. Full-capture plans are unchanged for all
210 MODEL_MAP types.

Keep the derived routed-expert `down` empty capture (#4675) and the
hand-written-declaration skip (#5995). Build the node from the merged
declaration so a merged source keeps its full target set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 14:28
@Qubitium
Qubitium merged commit 0127a03 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/awq-declaration-empty-capture-group branch December 1, 2026 14:29
Qubitium added a commit that referenced this pull request Dec 1, 2026
* fix(awq): drop folds whose source has no weight elements

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

* test(awq): pin the zero-size fold source rejection

The planner unit test fails on main because planned_group() accepts a
zero-sized Linear as a fold source, and passes with the fix.

---------

Co-authored-by: GB10 Sweep <sweep@localhost>
Qubitium added a commit that referenced this pull request Dec 1, 2026
…ations (#6675)

Remove the `awq_groups_from_tree_order` opt-out for the 19 types whose
full-capture plan differs from their fold declarations only by width-dropped
guesses. #6657 keeps a declared fold whose first reader captured nothing, so
the declaration path no longer needs the tracker's narrowed/dropped groups.

The inventory fixture diff removes exactly 36 `drop:width` groups and no
other group; `awq_fold_inventory.py --check` reports `changed: none`.

deepseek_v3, kimi_k2 and kimi_k25 stay on the tracker until the
`_search_best_clip` KeyError on an uncaptured ungrouped projection is fixed;
xing4_0 and minimax_m3_vl keep their separate reasons.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Qubitium added a commit that referenced this pull request Dec 1, 2026
`_search_best_clip` indexed `input_feat[name]` for every quantized module, so
a featureless layer, a `dynamic` exclusion, a starved reader or an unrouted
expert raised KeyError instead of leaving the module unclipped. #6657 keeps a
declared fold with `inp=None`, so a declaration-planned layer can reach the
clip search with an ungrouped quantized projection that has no capture.

Skip absent or empty features with the existing #4679 `log.warn` low-coverage
signal. The same missing-capture condition also filtered those modules out of
`apply_quant`; the module then reached packing without zero points and aborted
the run. Quantize every non-fallback module and let the clip search skip the
uncaptured ones. The tracker path already quantizes the same module via its
fallback, so the declaration path now matches it.

Tests: the DeepSeek-V3/Kimi featureless tests force the declaration path and
assert the #6657 featureless contract; clip-search unit tests cover the absent
feature and its warning. Full-capture plans are unchanged (`awq_fold_inventory.py
--check` -> changed: none; Qwen2.5-0.5B and ERNIE-4.5-21B GPU A/B bit-identical).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qubitium added a commit that referenced this pull request Dec 1, 2026
`_search_best_clip` indexed `input_feat[name]` for every quantized module, so
a featureless layer, a `dynamic` exclusion, a starved reader or an unrouted
expert raised KeyError instead of leaving the module unclipped. #6657 keeps a
declared fold with `inp=None`, so a declaration-planned layer can reach the
clip search with an ungrouped quantized projection that has no capture.

Skip absent or empty features with the existing #4679 `log.warn` low-coverage
signal. The same missing-capture condition also filtered those modules out of
`apply_quant`; the module then reached packing without zero points and aborted
the run. Quantize every non-fallback module and let the clip search skip the
uncaptured ones. The tracker path already quantizes the same module via its
fallback, so the declaration path now matches it.

Tests: the DeepSeek-V3/Kimi featureless tests force the declaration path and
assert the #6657 featureless contract; clip-search unit tests cover the absent
feature and its warning. Full-capture plans are unchanged (`awq_fold_inventory.py
--check` -> changed: none; Qwen2.5-0.5B and ERNIE-4.5-21B GPU A/B bit-identical).

Co-authored-by: Claude Opus 5.5 <[email protected]>
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