Skip to content

fix(looper): stop a subset only after every member captured (#4679) - #4703

Merged
Qubitium merged 1 commit into
mainfrom
fix/subset-early-stop-order-4679
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/subset-early-stop-order-4679

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4679. stage_subset set forward_hook_last on the member at the declared end of the subset, assuming declaration order matches the order the model calls the modules. When a sibling runs after the declared-last member it never saw an activation:

  • Falcon-H1 feed_forward: up_proj runs first, so gate_proj got 0 samples in every layer — GPTQ silently shipped RTN for it, AWQ crashed on the empty feature.
  • bailing_hybrid self_attn: b_proj runs before g_proj, so g_proj got 0 samples on every linear-attention layer.

Capture now keeps the set of members still unseen and flips the stop flag from the hook of the member that actually completes the subset. Declaration order no longer decides where the forward stops, and a subset with a member that never fires runs to completion instead of starving the others.

Also hardened the AWQ side of the same failure: _search_best_clip logs and skips a projection whose feature is empty (previously RuntimeError: cannot reshape tensor of 0 elements into shape [-1, 0]), and _compute_best_clip raises an explicit error for a direct caller.

Validation

tests/test_subset_declared_order_4679.py (new) builds a layer whose MLP calls up_proj before gate_proj and declares the subset in the Falcon-H1 order:

test before after
declared [gate, up], executed up, gate captures only up_proj → fails both captured
declared [up, gate], executed up, gate both captured, forward stopped unchanged

Both cases also assert the module after the subset still does not run, so the early stop is preserved.

tests/test_awq_clip_empty_feature_4679.py (new): the empty-feature skip returns no clip bounds, and the helper raises ValueError mentioning "at least one calibration token row".

Adjacent suites: tests/module_tree/test_subset.py, tests/test_subset_cancel_hook_cleanup_4470.py, tests/test_quantization_lifecycle_contracts.py, tests/test_stage_modules.py → 78 passed, 7 failed. All 7 failures are in tests/test_stage_modules.py and pre-exist on unmodified main: its DummyLooper double lacks _track_inflight_layer, which #4546 added (AttributeError). I verified the same 7 fail on a pristine main worktree and will fix that double separately.

ruff check gptqmodel docs/eora tests setup.py clean.

Resolves #4679.

`stage_subset` set `forward_hook_last` on the member at the declared end of
the subset, assuming declaration order matches the order the model calls the
modules. Falcon-H1's MLP computes `up_proj(x)` before `gate_proj(x)`, so the
forward stopped at `up_proj` and `gate_proj` never saw a calibration sample
(GPTQ silently fell back to RTN; AWQ crashed on the empty feature).
bailing_hybrid's hybrid attention runs `b_proj` before `g_proj`, same effect.

Track the members still unseen and flip the stop flag from the hook of the
member that actually completes the subset. Declaration order no longer
decides where the forward stops, and a subset whose member never fires simply
runs to completion instead of starving the rest.

Also skip AWQ clip search for a projection with an empty feature (log instead
of reshaping a 0-element tensor) and give `_compute_best_clip` an explicit
error for that case.
@Qubitium
Qubitium merged commit 219a528 into main Nov 17, 2026
8 checks passed
@Qubitium
Qubitium deleted the fix/subset-early-stop-order-4679 branch November 17, 2026 10:13
Qubitium added a commit that referenced this pull request Nov 17, 2026
…tch (#4738) (#4752)

#4703 made the member that empties the pending set flip forward_hook_last, so a
subset is cut off only after every member fired once. But the pending set was
built once per subset pass and the flag was only cleared at the end of the
pass. From the second calibration batch on the set was already empty, so the
first member to fire stopped the forward: every sibling - every other routed
expert of a MoE layer - captured exactly one batch.

Register a forward pre-hook on the layer module that refills the pending set and
clears the flag once per batch, before any subset member runs. The #4703
ordering guarantee is unchanged.
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