Repository navigation
Conversation
This was referenced Nov 28, 2026
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
With the default
offload_to_disk=True, quantization offloads the base modules(
embed_tokens/lm_head) before the layer loop and never restores them.LazyTurtle.materialize_submodulethen callstie_weights()after every layer,re-pointing
lm_head.weightat the meta embedding parameter, which has nooffload hook. After
quantize()the model reportsdevice == meta, CPUinput_idssilently generate garbage, and string prompts / CUDA inputs crash.This restores the offloaded base modules when the quantization loop exits so the
in-session model is usable again. If restoration cannot materialize a module, the
run raises a clear "reload the saved checkpoint" error instead of returning a
broken model.
What Changed
gptqmodel/utils/offload.pycapture_offloaded_base_modules()to snapshot base modules (and theirdevice) before offload, skipping modules that are already on meta.
restore_offloaded_modules()to materialize them again, re-tie sharedweights, and raise the reload error in strict mode.
undo_offload_to_disk()'stie_weights()call withcallable():submodules such as
LlamaRotaryEmbeddingexposeconfigbut have notie_weights(), which previously made a restore attempt raise.gptqmodel/looper/module_looper.py: record the offloaded base modules in_loop_impl()and restore them inloop()(strict on success, best-effort onfailure so the original exception is preserved).
gptqmodel/looper/weight_only_looper.py: same capture/restore for theweight-only lifecycle.
Tests
End-to-end repro on a tiny tied Llama (CPU, 2 layers,
offload_to_disk=True):before the fix
model.device=meta,embed=meta,lm_head=metaand logits were~
1e28; after the fix all three reportcpuand the forward returns finitelogits.
Fixes #4203