Skip to content

fix(moe): GPTAQ/FOEM flattened-row native split, share-cache release, AWQ fallback=None expert prune (#4457, #4463, #4456) - #4500

Merged
Qubitium merged 2 commits into
mainfrom
fix/moe-gptaq-awq-4456-4457
Nov 16, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/moe-gptaq-awq-4456-4457

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4457
Fixes #4456
Fixes #4463 item 3 (sibling-share cache lifetime). Items 1 and 2 were fixed in #4496 and #4492.

Summary

Evidence (RTX 5090)

Case Before After
Qwen1.5-MoE 2-layer, GPTAQ bs=4 / bs=2, FOEM α=0.25 bs=4, variable-length rows RuntimeError (784 vs 196, 170 vs 85) completes; the bs=1 checkpoint is bitwise identical
OPT-125m GPTAQ bs=4 RuntimeError 788 vs 197 PPL 48.34 (GPTQ 48.03, fp16 42.91)
Llama-3.2-1B GPTAQ/FOEM, Qwen2.5-0.5B GPTAQ bs=4 – checkpoints bitwise identical
Allocated after quantize() (Qwen2.5-0.5B GPTAQ bs=4, 32 rows) 11.37 MiB 5.85 MiB (no-sharing baseline 5.91 MiB)
Qwen3-30B-A3B 1 layer, AWQ fallback=None, 4×8 tokens (41/128 experts uncovered) reached packing without quantized zero points 265 quantized, 123 dense expert linears (bit-identical to source, equal to the dynamic exclusions), save/reload OK

AWQ note: a scaling group that contains a pruned expert (the shared routed-expert gate/up group) is skipped, so its covered members are quantized without an AWQ scale. The configured-fallback path does the same.

Follow-up: ParoQuantProcessor has the same layer-state gating, so it likely needs the same prune_uncovered_module override. It is not reproduced here.

Docs: docs/native-calibration-batch-split.md and docs/quantizer-moe.md §5.

Tests

  • tests/test_gptaq_foem_batch.py: flattened-capture parity and pad-row tests.
  • tests/test_native_sibling_input_sharing.py: the cache no longer pins source/mask after process()/finalize().
  • tests/test_moe_gptaq_foem.py: tiny Qwen2-MoE GPTAQ/FOEM at batch_size 1 and 4.
  • tests/test_awq_moe_prune_uncovered_4456.py: the executor-level AWQ prune, the hook, and a tiny Qwen3-MoE end to end.
  • All new tests fail on main and pass here.
  • After rebasing on c7ea976, RTX 5090: 169 passed across the native, MoE, AWQ-MoE, subset and offload suites. ruff is clean.

🤖 Generated with Claude Code

Qubitium and others added 2 commits November 16, 2026 20:06
…bling-share cache (#4457, #4463)

GPTAQ/FOEM pair one native entry with each per-sample add_batch call.
NativeProcessor._split_batch_samples only split [B,S,H] inputs and returned a
single B*S-row entry for flattened [B*S,H] rows, while GPTQProcessor's 2-D
branch splits those rows per sample with the keep mask. HF qwen2_moe's
shared_expert (and OPT's fc1/fc2) see flattened rows, so batch_size>1 crashed
with "size of tensor a (B*S) must match tensor b (S_kept)". The native split
now mirrors the 2-D branch: inp[b*S:(b+1)*S][keep[b]], empty samples skipped.

The sibling-share cache lived in a threading.local; process()/finalize() run
on another thread and could only bump an epoch, so each capture worker kept
its last (source, mask, entries) alive through the layer and after
quantize(). The cache is now one slot per capture thread in a lock-guarded
dict that process() and finalize() clear.

Dense Llama-3.2-1B GPTAQ/FOEM and Qwen2.5-0.5B GPTAQ checkpoints are bitwise
identical to the parent commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With fallback=None the subset executor prunes modules that never received
calibration input, but only popped processor.tasks. AWQ also tracks each
module in _AWQLayerState.modules/pending_modules and quantizes the layer
only when nothing in scope is pending, so one uncovered MoE expert kept the
layer from quantizing and every module reached pack_module without zero
points.

The executor now calls LoopProcessor.prune_uncovered_module(module); the base
implementation pops tasks and AWQProcessor also removes the module from its
layer state. Uncovered experts stay dense (bit-identical to the source) and
are recorded in dynamic, as for GPTQ (#4349); the rest of the layer is
quantized.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium merged commit 6e2da65 into main Nov 16, 2026
8 checks passed
@Qubitium
Qubitium deleted the fix/moe-gptaq-awq-4456-4457 branch November 16, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment