Repository navigation
Delete the dead hook-based offload machinery (#6471) - #6494
Merged
Merged
Conversation
After #6473 offload_to_disk is file-backed and resume loads artifacts with load_state_dict(assign=True), so nothing in the library reaches these anymore (call graph from every name the rest of gptqmodel/ imports): _snapshot_preexisting_hooks, _prepare_offload_directory, _write_offload_index, _bundle_module_state_dict, _qzero_layout_for_module, _bundle_qzero_layout, _qzeros_format_buffer, _convert_bundle_qzeros, _LiveQzeroWeightsMap, _iter_offload_hooks, _install_live_qzero_restore, offload_to_safetensors_reference, attach_disk_offload_hook (utils/offload.py 1973 -> ~1500 lines). Kept: undo_offload_to_disk / restore_disk_offloaded_modules / materialize_disk_offloaded_module (placement disk> targets still install offload hooks), and the writer's offload-reference resolution (writer.py builds OffloadTensorRef itself). Tests: offload_to_safetensors_reference moves to tests/offload_test_utils.py as a fixture builder for the writer's reference-resolution and export-preflight tests; the four tests of that helper's own validation are dropped; #4777 now drives the real resume path (artifact load_state_dict(assign=True) + non-persistent scratch) instead of attach_disk_offload_hook. Docs describe the file-backed resume and source-backed modules. Co-Authored-By: Claude Opus 5.5 <[email protected]>
27 tasks done
Qubitium
marked this pull request as ready for review
November 30, 2026 11:09
Qubitium
added a commit
that referenced
this pull request
Nov 30, 2026
DEVICE.to_device_map() and p2p.accelerator_devices_from_device_map() have no callers since GPT-QModel stopped consuming device maps (#6471). Also document the intentional pass in the offload test fixture (code-quality review on #6494). Co-authored-by: Claude Opus 5.5 <[email protected]>
Qubitium
added a commit
that referenced
this pull request
Nov 30, 2026
…mport Accelerate dispatch, stale guards (#6499) Regressions found by re-auditing the accelerate removal (#6471): - Importing gptqmodel hid Accelerate from all of Transformers, so `TrainingArguments`/`Trainer` raised "requires accelerate" even with it installed (PEFT fine-tuning of GPT-QModel models broke). The isolation now executes only `transformers.trainer` / `transformers.training_args` with the real flag via a scoped import hook; loading, placement, generation and `load_adapter` stay isolated. - A plain-Transformers load that imports gptqmodel late (Optimum imports it inside the GPTQ quantizer, after `device_map` was accepted) got dispatched by Accelerate and then half-initialized by the bridge, which only understands weight_loader hooks. `hf_gptqmodel_post_init` now refuses Accelerate hooks with a pointer to `GPTQModel.load(placement=...)` (strict everywhere). - OSTQuant's lazy-shell guard still read `turtle_model`; it never fired. - Three unchanged tests still used LazyTurtle's private interface or a deleted test file. Cleanup: dead preexisting-hook plumbing in utils/offload.py (its setter went in #6494), unused `_split_dim_cache_key`, and stale docs/comments that still described Accelerate dispatch or LazyTurtle names. 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.
Follow-up to #6473, for #6471.
After #6473,
offload_to_diskis file-backed and checkpoint resume loads artifacts withload_state_dict(assign=True). That leaves the hook-based offload machinery inutils/offload.pyunreachable. This PR deletes it: 8 files, +232 / −640.utils/offload.pygoes from 1,973 to about 1,500 lines.What is removed (dead by call graph)
Computed from every name the rest of
gptqmodel/imports fromutils/offload.py, following references inside the file:_snapshot_preexisting_hooks_prepare_offload_directory,_write_offload_index,_bundle_module_state_dict_qzero_layout_for_module,_bundle_qzero_layout,_qzeros_format_buffer,_convert_bundle_qzeros_LiveQzeroWeightsMap,_iter_offload_hooks,_install_live_qzero_restoreoffload_to_safetensors_reference,attach_disk_offload_hookWhat stays, and why
undo_offload_to_disk,restore_disk_offloaded_modules,materialize_disk_offloaded_moduleplacement=withdisk>accel:Ntargets still installs offload hooks at inference timewriter.pybuildsOffloadTensorRefitself, so these are liveTests
offload_to_safetensors_referencemoves totests/offload_test_utils.py. It is a fixture builder for the writer's reference-resolution and export-preflight tests, which keep their assertions. The four tests of that helper's own validation are dropped.test_checkpoint_resume_nonpersistent_4777.py) now drives the real resume path: artifactload_state_dict(assign=True)plus_materialize_meta_nonpersistent_buffers. It still checks that the workspace is materialized, the forward is identical to the source, and persistent state comes from the artifact.ruff 0.14.2) passes.Checked separately: saving into the source directory
Quantized Llama-3.2-1B, whose
embed_tokensis source-backed (a view of the sourcemodel.safetensors), thensave()into that same directory:The writer's temp-file plus atomic-rename leaves the mapped inode intact, so there is no SIGBUS and no corruption on Linux.
Docs
The following are updated to describe file-backed resume and source-backed modules:
in-session-model-after-offload.mdgptq-qzero-runtime-layout.mdoffload-run-directories.mdsafetensors-reference-offload.md🤖 Generated with Claude Code