Repository navigation
fix(moe): GPTAQ/FOEM flattened-row native split, share-cache release, AWQ fallback=None expert prune (#4457, #4463, #4456) - #4500
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4457
Fixes #4456
Fixes #4463 item 3 (sibling-share cache lifetime). Items 1 and 2 were fixed in #4496 and #4492.
Summary
NativeProcessor._split_batch_samplesnow splits flattened[B*S, H]module inputs per sample using the keep mask, mirroringGPTQProcessor's 2-D branch. HF qwen2_moe'sshared_expertand OPT'sfc1/fc2see flattened rows, so GPTAQ/FOEM crashed atbatch_size > 1withsize of tensor a (B*S) must match tensor b (S_kept).embed_tokensinto host RAM (+1 GiB RSS spike, 978c7c1), QQQ keeps the damped Hessian alive through the block pass (+C²·4 B VRAM, 5fbd636), sibling-share TLS cache pins activations after quantize (9626f50) #4463 item 3: the sibling-share cache moves from athreading.localto a lock-guarded per-thread dict thatprocess()andfinalize()clear.process()/finalize()run on a different thread and could not clear the old cache. The last batch's activations are no longer pinned after the layer or afterquantize().fallback=Noneon MoE with uncovered experts: quantize aborts with "reached packing without quantized zero points" (pruned experts never leave the AWQ layer state; #4349 fixed only GPTQ) #4456: a newLoopProcessor.prune_uncovered_module(module)hook is called by thefallback=Nonecoverage prune.AWQProcessordrops the pruned module from_AWQLayerState.modules/pending_modules. The layer then quantizes, and the uncovered experts stay dense and are recorded indynamic, as GPTQ already does ([BUG] MoE quantize withfallback=Nonecannot be saved: experts that received no tokens keep their AUTO_NF12 packed source ("Save aborted: AUTO_NF12 source storage is still installed") #4349).Evidence (RTX 5090)
quantize()(Qwen2.5-0.5B GPTAQ bs=4, 32 rows)reached packing without quantized zero pointsdynamicexclusions), save/reload OKAWQ 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:
ParoQuantProcessorhas the same layer-state gating, so it likely needs the sameprune_uncovered_moduleoverride. It is not reproduced here.Docs:
docs/native-calibration-batch-split.mdanddocs/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 afterprocess()/finalize().tests/test_moe_gptaq_foem.py: tiny Qwen2-MoE GPTAQ/FOEM atbatch_size1 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.ruffis clean.🤖 Generated with Claude Code