Repository navigation
fix(loader): put LazyTurtle pickle conversion under offload_to_disk_path - #4340
Merged
Merged
Conversation
…ath (#4319) LazyTurtle converts a .bin/.pt checkpoint into a full safetensors copy, but the loader never passed the configured offload root to maybe_create, so the copy always landed in the system TMPDIR. Pass quantize_config.offload_to_disk_path through; LazyTurtle still falls back to tempfile.gettempdir() only when no path is configured. Regression test builds a .bin-only local source, pins TMPDIR to an empty directory, and asserts the converted directory is a child of the configured offload path and absent from TMPDIR. It also asserts the conversion is removed when the turtle is released.
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 #4319
Root cause
LazyTurtle.maybe_create()already acceptedoffload_path, andLazyTurtle._conversion_root_for()uses it, butModelLoader.from_pretrained()never passed it(
gptqmodel/models/loader.py:2015)._infer_conversion_root()could notrecover it either: the HF shell model has no
quantize_config, andoffload_to_disk_pathis not in the HFmodel_init_kwargs. So a.bin/.ptsource was always converted under
tempfile.gettempdir()(the incomplete#4205fix).Fix
Pass
quantize_config.offload_to_disk_pathasoffload_path=when the loaderconstructs the turtle.
_normalize_conversion_root()makes it absolute;_conversion_root_for()keeps the existingtempfile.gettempdir()fallbackfor the unset case only. No new config field and no environment switch.
Test
tests/test_lazy_turtle_conversion_cache.py::test_loader_converts_bin_under_configured_offload_path_not_tmpdirModelLoader.from_pretrained()path with a.bin-only localsource (fake checkpoint class, no network).
offload_to_disk_pathtotmp_path/configured-offload.tempfile.gettempdir()to an emptytmp_path/system-tmp.path and that no
lazyturtle-*directory appears under the pinned TMPDIR.and loader instance are released (cleanup/retention).
Verified the test fails on the pre-fix code:
assert converted.parent == offloadreported the pinned TMPDIR as the parent. It passes with the fix.Verification
ruff check gptqmodel docs/eora tests setup.py->All checks passed!pytest tests/test_lazy_turtle_conversion_cache.py -q-> 6 passedpytest tests/test_local_model_paths.py tests/test_quantize_config_offload_tempdir.py -q-> 31 passed, 2 skippedResidual risk
quantize_config.offload_to_disk_pathafterfrom_pretrained()returns doesnot move an existing conversion. That matches the rest of the offload path,
which also snapshots the path at load time.
_perform_conversion()isunchanged, so this does not add cross-filesystem atomicity guarantees. A
configured path on a filesystem without atomic directory rename keeps the
previous behavior.
HF checkpoint, so it pins the wiring (the actual bug) and the
conversion-root semantics; the transformer-specific export path remains
covered by the existing conversion tests.