Repository navigation
fix(offload): keep per-run bundles after save so in-session forward works - #4416
Merged
Merged
Conversation
#4368 asked for the per-run offload directory to stop accumulating, and #4409 removed it at the end of save(). That breaks a supported workflow: save_quantized() streams the bundles but leaves the quantized modules on meta with an accelerate hook pointing into the run directory, so an in-session forward or a second save() after save() now raises FileNotFoundError (tests/test_planar_model_e2e.py fails on main). Release the directory only when the model can no longer read it: on teardown (weakref finalizer), on a failed quantization run, and when the same model binds another run. Document the ownership contract and the lifecycle, and pin save-then-forward, save-retry, and sequential-run behavior with CPU regression tests.
Collaborator
Author
|
CI note: the only failing check is |
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
#4409fixed the unbounded growth ofoffload_to_disk_pathby deleting the per-runrun-<uuid>directory at the end ofsave(). That is too early:save_quantized()streams the bundles but leaves the quantized modules onmetawith an accelerate offload hook pointing into that directory, so any in-session use aftersave()now fails.tests/test_planar_model_e2e.py::test_planar_model_quantize_save_reload_inference[4]fails on currentmain(0b78e472d):This PR keeps
#4368's goal (an explicit offload root no longer grows by one full model per run) while releasing the directory only when the model can no longer read it.What Changed
gptqmodel/models/base.py:save()no longer callsrelease_private_offload_root(). The timer bookkeeping in thefinallyblock is unchanged.weakref.finalizeon model teardown,release_private_offload_root()in theModuleLooper/WeightOnlyLooperfailure branch, and before the same model binds a new run.tests/test_offload_run_namespace.py:test_base_model_save_releases_private_run_dirbecomestest_base_model_save_keeps_private_run_dir_for_in_session_use(save keeps the bundles, a second save works, teardown removes them).tests/test_offload_run_cleanup_4368.py(new): save-then-teardown, failed-save-then-retry, and two sequential runs on a shared explicit root with no accumulation.docs/offload-run-directories.md(new) plus links fromREADME.mdanddocs/README.md: the ownership/lifecycle contract with Mermaid state and flow diagrams.No API change:
release_private_offload_root()and the_private_offload_*attributes are unchanged.Tests
CPU-only (
GPTQ_BYPASS_SAFETY_CHECKS=1,CUDA_VISIBLE_DEVICES="",PYTHONPATH= worktree):Notes
quantize()creates a new full-sizerun-<uuid>directory underoffload_to_disk_path, and it is never deleted (regression from 2bc2f63, #4202) #4368 (fixed by fix(offload): remove per-run offload directory after save, teardown, or failure (#4368) #4409, regression corrected here). Not a duplicate of fix(offload): remove per-run offload directory after save, teardown, or failure (#4368) #4409: the teardown/failure/rebind cleanup and the isolation from [BUG] Offload bundles are keyed only by module name in a directory shared by every copy of aQuantizeConfig, so a secondquantize()silently overwrites the first model's quantized weights #4202 are kept.SIGKILLed processes still leave a directory; that is unchanged and out of scope.