Skip to content

refactor(awq): release the empty-capture tracker types to fold declarations - #6675

Merged
Qubitium merged 1 commit into
mainfrom
refactor/awq-release-empty-capture-types
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
refactor/awq-release-empty-capture-types

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Move the remaining tracker-planned types whose AWQ plan differs from their fold
declarations only in the empty/absent-capture bookkeeping to the declaration
planner: remove their awq_groups_from_tree_order = True opt-out. This is the
last release before AWQ PR 8 deletes the tree planner, except for three types
blocked on a processor crash found while validating this release (below).

#6657 (fix(awq): keep a declared fold whose first reader captured nothing)
landed the declaration-path half of #6630: a declared fold whose first feature
is absent/empty is kept with its full target set and inp=None, and the
processor's fallback check owns it. That makes the declaration path the correct
planner for the types this PR releases: under an empty/absent capture the
tracker either drops the group or folds a narrowed target set that omits an
uncaptured reader, while the declarations keep the full set (fold it when every
reader was captured, fall back otherwise).

Full-capture plans are unchanged for every MODEL_MAP type: the inventory
fixture diff removes exactly the tracker's width-dropped guesses and nothing
else (awq_fold_inventory.py --check -> changed: none).

No issue: maintainer-approved cleanup before the tree planner is deleted.

What Changed

  • 13 definition files no longer set awq_groups_from_tree_order = True. The
    line is on the shared class for four of them, so it releases 19 types:
    ernie4_5_moe_vl/ernie4_5_vl_moe (Ernie4_5_VLMoeQModel),
    llama4/llama4_text (Llama4QModel), refinedWeb/refinedWebModel
    (RwgQModel) and falcon (FalconQModel(RwgQModel)).
  • glm4v shares Glm4vGPTQ with the two released glm4v_moe* types; its
    perturb A/B is fallback-bookkeeping only (no effective group changes), so it
    is released with them instead of adding a pin subclass.
  • tests/module_tree/fixtures/awq_fold_plans.json: 19 types changed,
    36 drop:width groups removed, 0 other changes.
  • tests/module_tree/test_awq_fold_inventory.py: DATA_DEPENDENT_KEEPS drops
    the released 19; xing4_0 keeps its own MLA-latent reason,
    minimax_m3_vl gets an MHA tracker-gap reason, and
    deepseek_v3/kimi_k2/kimi_k25 are pinned on the processor crash below.
  • tests/test_awq_falcon_two_norm_parallel_5414.py and
    tests/test_awq_scaling_groups.py: falcon now plans from its declarations;
    the tracker's width-dropped query_key_value -> dense candidate is gone, so
    the tests assert the surviving norm folds.
  • docs/awq-scaling-groups.md: documents that an absent/empty capture no
    longer keeps a type on the tracker.

Released (19)

deepseek_v32, dots3_note, flint, glm4_moe, glm4v_moe, glm4v_moe_text, llama4, llama4_text, mimo_v2_flash, ernie4_5_moe, ernie4_5_moe_vl, ernie4_5_vl_moe, falcon, refinedWeb, refinedWebModel, falcon_h1, moss, qwen3_next, glm4v

Kept on the tracker

  • deepseek_v3, kimi_k2, kimi_k25: a layer with no captured rows keeps
    its declared folds with inp=None, and the processor's clip search then
    raises KeyError for an ungrouped projection (self_attn.o_proj) with no
    capture. tests/module_tree/test_deepseek_v3_local_port.py and
    test_kimi_k25_local_port.py reproduce it; the fix is a separate processor
    change (skip clip search for a module with no captured rows), so these three
    stay on the tracker until it lands.
  • xing4_0: the tracker emits a width-valid
    self_attn.kv_a_layernorm -> self_attn.kv_b_proj MLA latent fold;
    kv_b_proj is not a first-stage leaf, so the declarations never emit it.
  • minimax_m3_vl: under an MHA config the declarations emit a valid
    self_attn.v_proj -> o_proj fold the tracker misses; adopting it changes
    numerics and needs its own quality-evidenced PR.
  • lfm2, lfm2_vl, dbrx_converted (MHA width coincidence),
    deepseek_vl_v2 (dense-Q MLA latent), nemotron_h_puzzle (unrouted shared
    expert), nemotronh_nano_omni_reasoning_v3 (mixer search feature): the
    previously pinned reasons are unchanged.

Tests

# full-capture plans: no effective 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

# 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
# -> 1414 passed, 103 skipped

# E2 (the 189 files in e2_files.txt), origin/main vs branch
bash run_e2.sh <base> e2b_base
bash run_e2.sh <branch> e2b_branch
# -> base: 2 failed, 6771 passed, 758 skipped, 3 xfailed
# -> branch: 1 failed, 6772 passed, 758 skipped, 3 xfailed
# The pre-existing failure is test_local_model_loading.py::test_bypass_requires_explicit_trust_and_is_rechecked_on_retry;
# the base-only second failure (test_deepseek_vl_v2_local_port.py, image processor) passes in isolation (8 passed).

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

Full-capture stress A/B (width coincidence)

ab_stress.py over the 19 released types: every inventory config variant plus
+mha and the explicit width-coincidence variants (MHA, MLA coincident, KV
shared, k_eq_v, qk_layernorm), base 0127a0313 vs branch.

python -P ab_stress.py --compare stress19_base.json stress19_branch.json
# -> cases=48 equal=12 differ=36 build-errors(both sides)=0
python -P validate_stress.py stress19_base.json stress19_branch.json
# -> changed=36 unexplained=0; removed groups by status: {'drop:width': 52}

Perturb A/B: empty/absent captures

Two seeds of empty20, absent20, root_empty and unrouted over every
config variant (plus +mha) of the 19 released types, origin/main (tracker)
vs branch (declarations). Every difference is one of:

class count effective?
removed drop:* group (tracker junk) 428 no, processor drops it
added drop:* group (declaration junk) 3008 no, processor drops it
fallback group added/removed/changed 107 no, both sides quantize plainly
declaration folds the full group where the tracker dropped/narrowed it (root_empty/empty20) 36 yes, #6630/#4697 fix
tracker folded a narrowed set that omitted an uncaptured reader; declarations keep the full set and fall back (empty20) 15 yes, #6630 fix (tracker bug removed)

No difference adds a group the tracker never had with a different target set,
and no difference changes a full-capture plan. The 15 removed-ok cases are
the tracker folding a group that dropped the uncaptured mlp.gate router
(qwen3_next), the attention branch of a shared norm (falcon, refinedWebModel,
moss, falcon_h1) or the gate half of a dense gate/up pair (ernie4_5_moe,
ernie4_5_moe_vl); the declaration path keeps those readers and either folds the
full set or falls back, which is the #6630 contract.

AB_BASE=<origin/main> AB_BRANCH=<branch> python -P ab_perturb.py \
  "<19 types>" --seeds 2 --out perturb_release19.json
python -P validate_release.py perturb_release.json
# -> problems: 0

Zero-size-module stress (#6663 class)

klear with n_shared_experts=0 (the config-disabled shared expert that
materializes as zero-sized Linears, #6663) plus no_shared variants of the
released MoE types are included in a perturb A/B (klear, deepseek_v32,
glm4_moe, glm4v_moe, glm4v_moe_text, ernie4_5_moe,
ernie4_5_moe_vl, flint, qwen3_next; all variants + no_shared + +mha,
1 seed), with #6663's zero-size-source check applied to both checkouts
(planned_group -> DROP): 384 layer plans over 36 config variants, 0 build
errors, and every base/branch difference stays in the release classes above
(validate_release.py -> problems: 0). The inventory harness does not emit
a zero-element-source group itself (the planner skips it), so the end-to-end
guard is the #6663 reproducer below.

python -P -m pytest -q tests/module_tree/test_klear_local_port.py -k no-shared
# origin/main 0127a0313 (without #6663): 3 failed, 6 passed
# branch + #6663 check:                     9 passed

GPU AWQ A/B

ERNIE-4.5-21B-A3B-PT (ernie4_5_moe, a Group-A2/B2 released type; the only
Group-A MoE checkpoint available locally), quantized on GPU 2 with a fixed
seed and the same 32-row wikitext calibration on both sides
(offload_to_disk=True so the 21B checkpoint fits the 32 GB card), every saved
tensor compared byte-for-byte.

model tensors result
baidu/ERNIE-4.5-21B-A3B-PT 16252 bit-identical

AWQ onboarding safety

  • Full-capture source/consumer relationships are unchanged (inventory
    changed: none, stress A/B 0 differences); the release only changes the
    planner used to derive the same groups.
  • The empty/absent-capture behaviour is the fix(awq): keep a dynamic-excluded reader in its source's scaling group on the tree-order planner #6630 contract introduced by
    fix(awq): keep a declared fold whose first reader captured nothing #6657: the full target set is kept, and the processor's fallback check
    decides between folding the whole set and plain quantization. The new
    tests/test_awq_declaration_empty_capture.py proves the empty-root fold is
    neutral and that folding around an uncaptured reader drifts.
  • 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.

Logic Flow Documentation

Not applicable: no control-flow change. The planner selection switch
(awq_groups_from_tree_order) and the declaration/processor flow are already
documented in docs/awq-scaling-groups.md; this PR only removes opt-outs and
updates that page's release criterion.

Kernel Accuracy Requirements

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

Notes

  • The 15 removed-ok perturbation cases are tracker bugs being removed, not
    regressions: the tracker folded a narrowed group that omitted an uncaptured
    reader (the router, a parallel branch or a gate sibling). The declaration
    path keeps the full set and falls back when a member has no capture.
  • fallback=None keeps the documented fix(awq): keep a declared fold whose first reader captured nothing #6657 contract: an empty (not absent)
    capture fails closed with _AWQScaleGroupError.

🤖 Generated with Claude Code

…ations

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
Qubitium marked this pull request as ready for review December 1, 2026 17:47
@Qubitium
Qubitium merged commit 2f1bb67 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the refactor/awq-release-empty-capture-types branch December 1, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant