Skip to content

fix(awq): skip clip search for modules with no captured features - #6681

Merged
Qubitium merged 1 commit into
mainfrom
fix/awq-clip-search-missing-feature
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/awq-clip-search-missing-feature

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

AWQProcessor._search_best_clip indexed input_feat[name] for every quantized
module in the layer. A module with no captured calibration rows (a featureless
layer, a dynamic exclusion, a starved reader or an unrouted expert) is absent
from input_feat, so the clip search raised KeyError: '<module>' instead of
leaving that module unclipped. #6657 keeps a declared fold whose first reader
captured nothing (inp=None), so a declaration-planned layer can reach the
clip search with an ungrouped quantized projection that has no capture — for
example DeepSeek-V3/Kimi self_attn.o_proj, or falcon self_attention.dense
after #6675 releases it to its declarations.

The same missing-capture condition also filtered those modules out of the
quantization pass (named_childs was filtered to name in input_feat). That
does not produce a usable dense checkpoint: the module stays in the layer state
and still reaches pack_module, which raises RuntimeError: ... reached packing without quantized zero points. On main, a featureless layer therefore
cannot finish quantization at all (clip KeyError, or the pack RuntimeError
when clip search is disabled). This PR fixes both: the clip search skips
modules with absent or empty captures, and the quantization pass quantizes every
non-fallback module (the scale search still only uses captured features).

No model is special-cased. This unblocks releasing deepseek_v3/kimi_k2/kimi_k25
to fold declarations (follow-up PR) and fixes the crash on the types released
by #6675 (falcon and friends).

What Changed

Reachability

  • A fully featureless screen of the 39 declaration-path types released by refactor(awq): release width-dropped tracker types to fold declarations #6650
    found ungrouped quantized projections, but the inventory model dropped all
    their groups before the clip call, so none reproduced in that screen.
  • The crash is reachable on current main 695ea9614 (after refactor(awq): release the empty-capture tracker types to fold declarations #6675 released
    falcon to its declarations): a featureless falcon layer with the default
    AWQConfig() fallback raises KeyError: 'self_attention.dense' during a
    public GPTQModel.load(...).quantize(...) run. With the declaration path
    forced, the DeepSeek-V3/Kimi featureless tests raise
    KeyError: 'self_attn.o_proj' (4 fallback params).
  • The same absent/empty feature condition covers dynamic exclusions, unrouted
    experts and zero-row calibration.

Why the named_childs change is required (CPU end-to-end)

The review asked whether main's behaviour (an uncaptured module excluded from
apply_quant) is an intentional dense-in-checkpoint state. It is not
reachable: the module remains in the layer state and pack_module requires its
staged zero points. Proof with a tiny falcon (two-norm parallel decoder, 2
layers, 8 quantized linears), the public GPTQModel.load -> quantize -> save -> load path on CPU, the processor's capture forced empty
(_layer_input_features -> {}, i.e. the zero-row/featureless calibration case),
AWQConfig(device="cpu", group_size=-1, fallback={}) (current main 8eeab5e35
is the same code as 695ea9614 plus a test-only turboquant commit):

run result
main 695ea9614, featureless declaration layer, default fallback KeyError: 'self_attention.dense' in _search_best_clip; no checkpoint
main, featureless declaration layer, clip search disabled RuntimeError: AWQProcessor: module transformer.h.0.self_attention.dense reached packing without quantized zero points; no checkpoint
main, declaration layer with only the fold sources captured, default fallback KeyError: 'self_attention.dense' in _search_best_clip; no checkpoint
main, same partial capture, clip search disabled RuntimeError: ... self_attention.dense reached packing without quantized zero points; no checkpoint
main, tracker forced (awq_groups_from_tree_order=True, featureless) 8/8 linears packed as AwqTorchLinear; save + GPTQModel.load OK; finite logits (std 0.1082)
main, real tracker type DeepSeek-V3 (featureless) 28/28 linears packed; save + load OK; finite logits (std 0.1064)
branch, featureless declaration layer 8/8 linears packed; save + load OK; finite logits (std 0.1082)
branch, partial capture (only the fold sources) 8/8 linears packed; save + load OK; finite logits (std 0.1083)
branch, real tracker type DeepSeek-V3 28/28 linears packed; save + load OK; finite logits (std 0.1064)

In the partial runs the group sources (self_attention.query_key_value,
mlp.dense_h_to_4h) have captured rows and the ungrouped
self_attention.dense / mlp.dense_4h_to_h do not: the exact
one-ungrouped-projection-missing case, not only a fully featureless layer.

The tracker's established behaviour is to quantize the uncaptured projection
(its featureless layer falls back to plain quantization), not to leave it
dense. The declaration path must match; the named_childs change does exactly
that. This is the same missing-capture cause as the clip crash, so it stays in
this PR rather than a split.

Script: .../awq-clip-search-missing-feature.scratch/prove_named_childs.py
(logs prove_falcon_*.log, prove_deepseek_tracker_*.log).

Tests

# red on main 695ea9614 (branch test files copied over), green on branch
HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES= \
  PYTHONPATH=$PWD:$PWD/tests python -P -m pytest -q -p no:cacheprovider \
  tests/test_awq_clip_empty_feature_4679.py \
  tests/module_tree/test_deepseek_v3_local_port.py \
  tests/module_tree/test_kimi_k25_local_port.py -k "featureless or no_capture"
# main:   8 failed, 6 passed (KeyError: self_attn.o_proj / self_attention.dense)
# branch: 14 passed

# full-capture plans (processor-only fix: no plan change)
HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES= \
  PYTHONPATH=$PWD:$PWD/tests python -P tests/module_tree/awq_fold_inventory.py --check
# -> changed: none

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

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

Measured Impact

GPU AWQ A/B, GPU 2 (CUDA_DEVICE_ORDER=PCI_BUS_ID), fixed seed, the same
32-row wikitext calibration, every saved tensor compared byte-for-byte
(offload_to_disk=True for the 21B model):

model tensors result
Qwen/Qwen2.5-0.5B-Instruct 626 bit-identical
baidu/ERNIE-4.5-21B-A3B-PT 16252 bit-identical

The A/B was taken before the final log-level amendment; the only delta since is
log.debug -> log.warn in the missing-capture skip branch, which has no
numeric path.

Model Support / Module Plan

Not applicable: no model type, alias or definition change.

AWQ onboarding safety

Logic Flow Documentation

Not applicable: no new decision mechanism or lifecycle. The existing clip loop
adds one per-module skip (features is None or features.numel() == 0), and the
named_childs predicate loses its name in input_feat term. The scale search's
missing-feature handling and the fallback/drop order are unchanged.

Kernel Accuracy Requirements

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

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 unquantized-modules part was found while validating the clip fix: after
    skipping the absent module in the clip search, the V3/Kimi featureless tests
    failed because named_childs had dropped it from apply_quant; in the real
    pipeline the same module then aborts packing. The one-line filter fix makes
    those tests green and completes the run.
  • The DeepSeek-V3/Kimi tests force the declaration path locally; the class flag
    stays True until the release PR.

🤖 Generated with Claude Code

`_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
Qubitium force-pushed the fix/awq-clip-search-missing-feature branch from 1d75651 to ff10c83 Compare December 1, 2026 18:50
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 18:58
@Qubitium
Qubitium merged commit 1bfd646 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/awq-clip-search-missing-feature branch December 1, 2026 18:58
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