Repository navigation
fix(looper): materialize non-persistent buffers before the resume hook (#4777) - #4781
Merged
Merged
Conversation
#4777) Resuming any QQQ quantization crashed at restore, before doing any work: ValueError: workspace is on the meta device, we need a `value` to put in on cpu. `GPTQCheckpoint.restore` rebuilds each finished module on `meta`, writes the offload index from `module.state_dict()`, then calls `attach_disk_offload_hook`. `state_dict()` excludes non-persistent buffers by definition, so `QQQLinear.workspace` - the split-K lock array, registered with `persistent=False` - had no stored value. Accelerate's hook init then tried to move every buffer, found `workspace` on meta, and raised. Every resume path for QQQ was affected, so a resumed run could never finish. `attach_disk_offload_hook` now materializes non-persistent meta buffers on CPU before `disk_offload`. They are runtime scratch and never checkpoint state, so allocating them is the correct treatment rather than adding them to the index. Persistent buffers are untouched: the index still carries them. The fix is generic, not QQQ-specific: any kernel with a non-persistent buffer would have hit the same accelerate path. Tests: new `tests/test_checkpoint_resume_nonpersistent_4777.py` builds the bundle + index exactly as `restore` does, restores a `QQQTorchLinear` on meta, and asserts (a) the workspace is materialized with the right shape/dtype and zeroed, (b) the loop-exit restore leaves no meta tensor and the resumed module's forward is bit-identical to the source module, (c) persistent state still comes from the bundle, not from a zero fill. Runs on CPU; no ggml/QQQ extension needed. Red on unmodified main (dba142d): 3/3 fail with the issue's ValueError.
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 #4777. Regression from #4611 (
2f1682053).Problem
Resuming any QQQ quantization crashed at restore, before any work was done:
GPTQCheckpoint.restore()rebuilds each finished module onmeta, writes an accelerate offloadindex.jsonfrommodule.state_dict(), and callsattach_disk_offload_hook(module, directory).state_dict()excludesnon-persistent buffers by definition, so
QQQLinear.workspace- the split-K lock array, registered withpersistent=False- had no stored value. Accelerate'sinit_hookthen tried to move every buffer, foundworkspacestill on meta, and raised.
All 10 checkpoint-recovery cases for QQQ (
term,kill-before,kill-after,error; dense, EoRA and MoE) diedhere, so a resumed QQQ run could never complete.
Fix
gptqmodel/utils/offload.py-attach_disk_offload_hookmaterializes non-persistent meta buffers on CPU beforedisk_offload:the index would also mean writing
workspaceinto a checkpoint that has no meaning for it);accelerate path.
It runs after the "index must exist" check and before
disk_offload, so the failure mode for a missing bundle isunchanged.
Tests
New
tests/test_checkpoint_resume_nonpersistent_4777.py(3 cases, CPU-only, no QQQ native extension needed) buildsthe safetensors bundle +
index.jsonexactly asrestore()does, then:QQQTorchLinearbuilt undertorch.device("meta")and assertsworkspaceis no longer meta, keepsits shape/dtype, and is zeroed;
restore_disk_offloaded_modules()and asserts no meta tensor remains and the resumed module'sforward is bit-identical to the source module;
B,s_channel,s_group) still comes from the bundle, not from a zero fill.Red on unmodified
main(dba142d2f): 3/3 fail with the issue'sValueError.Green on this branch: 3/3 new, plus
tests/test_offload_files.py,tests/test_offload_reference_4395.py,tests/test_offload_quantized_modules_restored_4450.pyandtests/test_checkpoint_modules.py-> 161 passed / 9skipped, with only the pre-existing
test_qqq_optional_group_scales_schemafailure (needs a buildable QQQ CUDAextension; fails identically on
mainhere).ruff checkclean.The 10
tests/test_checkpoint_method_compatibility.pyrecovery cases need CUDA plus the native QQQ extension, whichcannot build on this host (no
CUDA_HOME/nvcc); the unit-level test above covers the exact restore step they diein.