Skip to content

refactor(awq): release width-dropped tracker types to fold declarations - #6650

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

Qubitium merged 1 commit into
mainfrom
refactor/awq-release-dropwidth-tracker-types

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Remove the awq_groups_from_tree_order = True opt-out from 37 model definitions
whose tree-order AWQ plan differed from their fold declarations only by
width-mismatched Linear→Linear guesses (drop:width). The processor already
discards those groups after its fallback check, so the effective plan is
unchanged; the fixture diff deletes exactly 55 such rows and nothing else.

The other 29 of the 66 reviewed candidates stay on the tracker because a
stress/perturbation or local-port config still changes an effective group
(empty/absent capture, MHA or MLA width coincidence). Releasing them needs
their own behaviour-evidenced change, so this PR deliberately does not release
the full 66.

No issue: this is the maintainer-approved cleanup step before AWQ PR 8 deletes
the tree planner.

What Changed

  • 37 definitions no longer set the opt-out (33 explicit lines; glm4,
    phimoe, mllama_text_model, qwen2_5_vl_text and qwen2_vl_text inherit
    from a released parent).
  • MiniCPMV4_6QModel drops its full-attention tracker branch; every layer now
    plans from the fold declarations (the tracker's only extra group there was a
    width-dropped v_proj -> o_proj).
  • NemotronHPuzzleQModel and NemotronOmniQModel set the flag explicitly
    (they inherited it from NemotronHQModel) with the data-dependent reason.
  • tests/module_tree/fixtures/awq_fold_plans.json: 37 types changed,
    55 drop:width groups removed, 0 other changes.
  • tests/module_tree/test_awq_fold_inventory.py: new DATA_DEPENDENT_KEEPS
    and test_data_dependent_keeps_stay_on_the_tracker; glm4v is pinned
    through its Glm4vGPTQ parent.
  • tests/module_tree/test_chatglm_local_port.py,
    tests/test_awq_scaling_groups.py and tests/test_ricursive_local_port.py
    now pin the declaration plan; the nodes they used to expect were
    width-dropped and never folded.
  • docs/awq-scaling-groups.md: MiniCPM-V 4.6 now plans every layer from the
    declarations, and DATA_DEPENDENT_KEEPS is documented.

Released (37)

bloom, chatglm, glm, glm4, glm4_moe_lite, glm_ocr, glmasr, gpt_bigcode, gpt_neox, gpt_oss, granitemoehybrid, grinmoe, internlm2, jamba, lfm2_moe, minicpm3, minicpmv, minicpmv4_6, minimax_m2, ministral3, mistral3, mixtral, mllama, mllama_text_model, mpt, nemotron_h, phi3, phimoe, qwen2_5_omni, qwen2_5_vl, qwen2_5_vl_text, qwen2_vl, qwen2_vl_text, qwen3_omni_moe, ricursive, starcoder2, voxtral

Kept on the tracker (29)

  • lfm2, lfm2_vl: MHA width coincidence makes the tracker's
    v_proj -> out_proj group searchable; out_proj has no o role.
  • dbrx_converted: same width coincidence through attn_config.kv_n_heads;
    the local-port test exercises kv_n_heads == n_heads.
  • deepseek_vl_v2: a dense-Q MLA config makes the tracker's
    kv_a_layernorm -> kv_b_proj fold width-valid; kv_b_proj is not a
    first-stage leaf, so the declarations never emit it.
  • nemotronh_nano_omni_reasoning_v3: the MoE group's mixer search feature
    (the [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 starved-expert split) has no declaration form.
  • deepseek_v3, kimi_k2, deepseek_v32, dots3_note, flint,
    glm4_moe, glm4v_moe, glm4v_moe_text, kimi_k25, llama4,
    llama4_text, mimo_v2_flash, minimax_m3_vl, xing4_0,
    ernie4_5_moe, ernie4_5_moe_vl, ernie4_5_vl_moe, falcon,
    refinedWeb, refinedWebModel, falcon_h1, moss, qwen3_next: an
    empty/absent capture changes the effective group set (the tracker emits a
    group that falls back, keeps a narrower target set, or merges a member the
    declarations skip or retarget).
  • glm4v: stays only because Glm4vGPTQ is the shared parent of the two
    glm4v_moe* keeps above.

Tests

HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES= \
PYTHONPATH=$PWD:$PWD/tests /root/venv/bin/python -P -m pytest -p no:cacheprovider -n 20 -q -rs \
  tests/module_tree/test_awq_fold_inventory.py
# 765 passed, 3 warnings

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 (exit 0)

PATH=/root/venv/bin:<no-op pip shim>:$PATH bash format/check.sh
# ruff 0.14.2; All checks passed!

E2 (the 189 files in scratch/e2_files.txt, CPU-only, -n 40):

Side Result
base c31a0ec8e 1 failed, 6769 passed, 758 skipped, 3 xfailed
branch 2 failed, 6769 passed, 758 skipped, 3 xfailed

Both failures are environmental/flaky, not planner changes:
test_local_model_loading.py::test_bypass_requires_explicit_trust_and_is_rechecked_on_retry
fails on both sides because the sandbox's HF modules cache is read-only, and
test_deepseek_vl_v2_local_port.py::test_routed_and_shared_moe_matches_independent_full_consumer_sum[noaux_tc]
is an RNG-dependent routing assertion that passes when run alone on both sides.

Targeted regressions after the local-port findings (19 passed):

... -m pytest -q -n 8 \
  tests/module_tree/test_dbrx_converted_local_port.py::test_awq_scale_folds_preserve_attention_and_routed_expert_output \
  tests/module_tree/test_chatglm_local_port.py::test_chatglm_post_layernorm_residual_keeps_norms_unscaled \
  "tests/test_awq_scaling_groups.py::test_excluded_projection_is_never_a_fold_source[bloom]" \
  "tests/test_awq_scaling_groups.py::test_excluded_projection_is_never_a_fold_source[gpt_bigcode]" \
  "tests/test_awq_scaling_groups.py::test_excluded_projection_is_never_a_fold_source[gpt_neox]" \
  "tests/test_awq_scaling_groups.py::test_excluded_projection_is_never_a_fold_source[mpt]" \
  tests/module_tree/test_deepseek_vl_v2_local_port.py::test_awq_scale_folds_preserve_real_text_decoder_output \
  tests/test_ricursive_local_port.py::test_public_awq_every_linear_dense_owner_and_two_reloads
# 19 passed

A/B evidence

Fallback-before-drop proof. AWQProcessor._quantize_layer calls
_should_fallback_group at gptqmodel/looper/awq_processor.py:4750, before the
DROP branch at awq_processor.py:4791; the width verdict comes from
width_mismatch in gptqmodel/quantization/awq/fold_rules.py:244, and the
default fallback threshold is "0.5%" at
gptqmodel/quantization/config.py:2054 (should_use_fallback,
gptqmodel/utils/fallback.py:111). Expanding the pre-change fixture shows the
37 released types' 55 junk groups target only dense, always-run projections
(0 routed-expert and 0 shared-expert targets; 13 distinct dense leaves). Their
full capture is the whole calibration set, so the 0.5% threshold cannot trigger.

Width-coincidence stress A/B (scratch/ab_stress.py, base vs branch, every
inventory config variant plus +mha and MLA-coincident variants): 102 cases,
3410 layers compared, 2533 removed junk groups, 0 non-junk differences.

Capture-perturbation A/B (scratch/ab_perturb.py, 2 seeds, full,
unrouted, absent20, empty20, root_empty, plus +mha): for the 37
released types, 608 layer-plan differences and 707 removed junk groups,
0 non-junk differences. The same run found the 25 non-junk types listed
above; refinedWeb was added because it shares the refinedWebModel class,
and the two local-port configs added dbrx_converted and deepseek_vl_v2.

GPU AWQ A/B (GPU index 2, fixed seed/calibration, every saved tensor and
config/text file compared bytewise; scratch/run_gpu_ab.sh):

Model Type Result
ibm-granite/granite-4.0-h-350m granitemoehybrid (released) 642 tensors, bit-identical
Qwen/Qwen2-VL-2B-Instruct qwen2_vl (released) 1121 tensors, bit-identical
Qwen/Qwen2.5-0.5B-Instruct control 626 tensors, bit-identical
LiquidAI/LFM2-1.2B lfm2 (kept) 332 tensors, bit-identical (earlier base)
baidu/ERNIE-4.5-0.3B-PT ernie4_5 (unaffected) 416 tensors, bit-identical (earlier base)

The first three rows were rerun against the rebased origin/main
(c31a0ec8e); the LFM2/ERNIE rows are the earlier run against 53ca01933
and cover a kept and an unaffected type.

A ai21labs/Jamba-tiny-dev attempt was rejected before quantization by the
artifact-security chat-template check (UnsafeModelArtifactError), so it is
not counted as evidence.

Model Support / Module Plan

Not applicable as new-model support: no MODEL_MAP entry, loader, tree or
fusion change. This is a definition-data cleanup. The inventory test still
builds every MODEL_MAP type and pins every effective plan; the module-plan
inventory (registered_module_plans.json) is untouched.

AWQ onboarding safety

  • The released groups are width-dropped guesses; the declarations add no fold
    and remove no effective fold. The inventory pins the full node fields the
    processor reads.
  • The local-port tests above exercise the real decoder forwards for the
    affected types; dbrx_converted (MHA), deepseek_vl_v2 (dense-Q MLA),
    chatglm (post-LN residual), ricursive (GQA/MHA) and the four
    fused-QKV families cover the layouts that changed.
  • The GPU A/B is bit-identical on two released types plus the control.
  • Not all 29 kept types were GPU-quantized; their tracker path is unchanged.

Logic Flow Documentation

The dispatch flow is unchanged; this PR moves 37 definitions from the tracker
branch to the declarations branch. The old decision was "definition sets
awq_groups_from_tree_order = True"; the new decision is the class default
(False) plus the declaration set. The removed tracker groups were dropped
before any fold, so no tensor path changes.

flowchart TD
    A["BaseQModel.awq_get_modules_for_scaling"] --> B{"awq_groups_from_tree_order?"}
    B -- "yes: 29 kept candidates" --> T["_awq_generic_get_modules_for_scaling<br/>tree-order tracker"]
    B -- "no: 37 released definitions" --> C["_awq_nodes_from_declarations<br/>awq_fold_declarations(layer)"]
    T --> D["tracker plan<br/>includes width-dropped guesses"]
    C --> E["declaration plan<br/>no width-dropped guesses"]
    D --> F["AWQProcessor._quantize_layer"]
    E --> F
    F --> G{"_should_fallback_group?<br/>line 4750, before drop"}
    G -- "starved / empty capture" --> H["fallback member or group"]
    G -- "full capture" --> I{"check_layer verdict"}
    I -- "DROP width" --> J["skip group<br/>line 4791"]
    I -- "OK" --> K["scale search and fold"]
    style H fill:#fff3cd,stroke:#997404,stroke-width:2px
    style J fill:#fff3cd,stroke:#997404,stroke-width:2px
Loading
Stage Base (before) Branch (after)
opt-out data 66 candidates set awq_groups_from_tree_order = True 37 released use the False default; 29 keep the flag
dispatch base.py:7857 → _awq_generic_get_modules_for_scaling (base.py:7863) base.py:7859 → _awq_nodes_from_declarations (base.py:7781)
group source tracker's previous-module heuristic emits the width-mismatched Linear→Linear guess role-derived declarations never emit that guess
fallback awq_processor.py:4750 can fall back before the drop same check; the group does not exist
drop fold_rules.py:244 → awq_processor.py:4791 no group reaches the drop
fixture tracker plan pinned declaration plan pinned; diff is exactly 55 drop:width rows

The reference page is docs/awq-scaling-groups.md (updated in this PR).

Measured Impact

Not applicable: the change is behavior-preserving for every released type.
The GPU A/B is bit-identical (table above); no VRAM, throughput or accuracy
metric changes.

Review Requirements

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface.
  • Considered and eliminated potential regressions.

Notes

  • The 29 keeps are a deliberate deviation from the "66" target: the task's
    fallback-before-drop rule says to keep any type that can still be affected,
    and the perturbation A/B plus two local-port configs show they can.
  • minicpmv_4_6 also loses its full-attention tracker branch, which is the
    only code change beyond the opt-out lines.
  • No new bug was found; the pre-existing test_local_model_loading failure is
    environmental (read-only HF modules cache).

🤖 Generated with Claude Code

The tree-order AWQ planner emits width-mismatched Linear->Linear guesses
(fused QKV -> dense, GQA v_proj -> o_proj, MLA latents) that the processor
drops after the fallback check.  For 37 definitions those guesses were the
only difference from the fold declarations, so remove the
`awq_groups_from_tree_order` opt-out and pin the declaration plan in the
inventory fixture: the diff deletes exactly 55 `drop:width` rows and
nothing else.

MiniCPM-V 4.6's full-attention branch is removed with its opt-out; every
layer now plans from the declarations.  Nemotron-H Puzzle and Nemotron Omni
keep the tracker explicitly (they inherited it from Nemotron-H) because
their data-dependent captures still differ.

The remaining 29 of the 66 reviewed candidates stay on the tracker: the
stress/perturbation A/B still changes an effective group for 28 of them
(empty/absent capture, MHA or MLA width coincidence) and glm4v shares the
Glm4vGPTQ parent with two of those.  Keeping them is required by the
fallback-before-drop rule; they can be released with their own
behaviour-evidenced change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 12:15
@Qubitium
Qubitium merged commit 69c41e7 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the refactor/awq-release-dropwidth-tracker-types branch December 1, 2026 12:15
Qubitium added a commit that referenced this pull request Dec 1, 2026
Follow-up to #6650: the merged change left `nemotron_h_puzzle` and
`glm4v` without a test pin (their keeps were only comments) and left a
blank line after the class header in the definitions whose opt-out was
removed.

Add both types to `DATA_DEPENDENT_KEEPS` with their reasons so
`test_data_dependent_keeps_stay_on_the_tracker` fails if either flag is
dropped, and remove the leftover blank lines.

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

Development

Successfully merging this pull request may close these issues.

1 participant