Repository navigation
fix(loader,gptq,qqq,exl3): complete the #4400 memory fallbacks - #4442
Merged
Merged
Conversation
Item 2: on the quantized-load path, park fused 3-D expert projections on meta before Defuser's tensor defusion and restore real (uninitialized) storage on the split linears afterwards. Defuser then never materializes one dense bf16 Linear per expert just to have make_quant replace it. Item 3: QQQ and EXL3 block_ldl now classify solver allocation failures with GPTQ's _is_memory_allocation_failure and finish the Hessian inverse on the host instead of aborting. EXL3 also retries the diagonal-block inverse. Item 4: GPTQ retries the post-inverse block pass (Losses/Q and the W-sized block update) on CPU when the allocation fails on the device. Tests cover the meta expert shell (structural + end-to-end bitwise reload), the QQQ/EXL3 CPU retries (bitwise/close against an unconstrained CPU run), and the GPTQ block-pass retry (bitwise against a CPU run) plus its non-memory guardrail.
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.
Summary
The remaining three findings of #4400 (item 1, shared-input Hessian adoption release, shipped in #4430):
RssAnon12.17 GiB for a 3.66 GiB checkpoint, 3.3x).block_ldlmissed solver allocation failures (HIPSOLVER_STATUS_ALLOC_FAILED).Losses,Q) and the block update still ran on the failed device and aborted the run.Addresses items 2-4 of #4400.
What Changed
models/loader.py:_meta_fused_expert_params()parks the fused 3-Dgate_up_proj/gate_proj/up_proj/down_proj(and fused biases) onmetabefore_convert_model_with_defuser(..., cleanup_original=True)on the quantized-load path;_materialize_meta_expert_linears()thento_emptys fully-meta split linears somake_quantcan build kernels. The legacy path is kept for non-quantized loads and for differently-named fused experts.quantization/qqq.py: Hessian inverse factored into_inverse_hessian, wrapped in_is_memory_allocation_failure+ CPU retry.exllamav3/.../exl3_lib/quantize.py:block_ldlclassifies allocation failures with_is_memory_allocation_failureand retries the diagonal-block inverse on CPU.quantization/gptq.py: the post-inverse block pass (Losses/Q+ block update) is wrapped in the same CPU retry; the retry resets partially-appended scale/zero entries and the block index first.git diff -wis 38 lines.docs/quantized-moe-reload-meta-shell.md(lifecycle + OOM-fallback Mermaid diagrams, README link). New tests:tests/test_moe_reload_meta_4400.py,tests/test_moe_reload_meta_e2e_4400.py,tests/test_qqq_exl3_oom_fallback_4400.py,tests/test_gptq_post_inverse_fallback_4400.py.Tests
Measured (synthetic fused-MoE shell, 8 layers x 8 experts, bf16, ~3.2 GB expert weights): peak
RssAnon8830.5 MiB -> 7747.1 MiB (shell baseline 7726.1 MiB), i.e. the fix adds ~21 MiB over the shell instead of 1.1-1.9 GiB; 4-layer variant 5558.7 -> 4264.1 MiB. Tiny real OLMoE 4-bit reload 1138.1 -> 1083.1 MiB withstate_dictand logitstorch.equal. QQQ retry: packedQ/scalebitwise equal to an unconstrained CPU run. GPTQ block-pass retry:Qbitwise equal. EXL3block_ldl:Lmatches the CPU run at rtol/atol 1e-6.Fail-before on pristine main: all four item-2 tests fail (helpers absent) and the fallback assertions fail while the non-memory guardrails pass.
Not executed: the real
allenai/OLMoE-1B-7B-0924reload (13.9 GB download + 7B quantization) — synthetic shell plus a tiny real OLMoE checkpoint used instead; fused GPTQ CUDA block-update and Marlin/Triton/EXL3 kernels (noCUDA_HOME).Logic Flow Documentation
docs/quantized-moe-reload-meta-shell.mddocuments the reload lifecycle (including the legacy and partially-meta fallbacks) and the OOM-fallback decision path with Mermaid diagrams using the real symbol names; linked fromREADME.md.Review Requirements