Repository navigation
Description
Found on main @ 4b65923, RTX 5090 (sm_120), torch 2.15 / transformers 5.22.
What is wrong
#4498 (#4450) set the contract that when quantize() returns, the in-session model is the same model offload_to_disk=False produces: no meta tensors, no offload hooks, usable for inference and model.to(...) (docs/in-session-model-after-offload.md). A quantize(checkpoint=CheckpointConfig(...)) run that resumes from a published checkpoint breaks that contract, and does so silently.
gptqmodel/looper/gptq_checkpoint.py:~560-605rebuilds every completed layer's packed modules withrestore_packed_module(...)onmeta, writes a per-attemptindex.jsonthat points at the checkpoint object, andset_submodules them into the model ("Packed modules remain meta until the normal save path resolves their offload references", line 593). These modules carry no accelerate offload hook.- At loop exit,
restore_disk_offloaded_modules(gptqmodel/utils/offload.py:268) only targets modules where_owns_offload_hook(module)is true, so it skips the restored modules. materialize_remaining_meta_modules(gptqmodel/utils/offload.py:344) skips every module with aQUANT_TYPE(line 366).
So every layer that was restored from the checkpoint stays on meta. No error and no log line is emitted (the strict=True RuntimeError and the log.error in those two helpers never see these modules). The first in-session forward, or model.to("cuda"), raises NotImplementedError: Cannot copy out of meta tensor.
save() still works, and the resumed checkpoint is byte-identical to an uninterrupted run (verified for GPTQ and AWQ, 794/626 tensors, 0 differences). Only the in-session model is broken.
docs/looper-checkpoint-redesign.md:147 still says "Completed packed modules intentionally remain offloaded/meta until saving". That predates #4498 and conflicts with the newer in-session contract.
Repro (Qwen2.5-0.5B-Instruct, GPTQ 4-bit; AWQ behaves the same)
import os, signal, torch
from gptqmodel import GPTQModel, CheckpointConfig
from gptqmodel.looper.checkpoint import CheckpointExtension, CheckpointStopped
from gptqmodel.quantization.config import GPTQConfig
def run(stop_at=None):
cfg = GPTQConfig(bits=4, group_size=128) # offload_to_disk=True (default, required)
m = GPTQModel.load("Qwen2.5-0.5B-Instruct", cfg, dtype=torch.float16)
if stop_at is not None: # same trick as tests/checkpoint_quantization_driver.py
orig = CheckpointExtension.on_boundary
def boundary(ext, ev):
if ev.step.index == stop_at:
os.kill(os.getpid(), signal.SIGINT)
orig(ext, ev)
CheckpointExtension.on_boundary = boundary
m.quantize(calib_16_c4_texts, checkpoint=CheckpointConfig(path="ckpt"))
return m
# process 1
try: run(stop_at=3)
except CheckpointStopped as e: print(e) # checkpoint committed; resume from step 4
# process 2 (fresh interpreter): resume
m = run()
meta = [n for n, t in list(m.model.named_parameters()) + list(m.model.named_buffers()) if t.is_meta]
print(len(meta), meta[:3])
ids = m.tokenizer("Hello", return_tensors="pt").input_ids
m.model(ids) # in-session forward
m.model.to("cuda:0")Output:
checkpoint committed; resume from step 4
152 ['model.layers.0.self_attn.q_proj.qzeros_format', 'model.layers.0.self_attn.q_proj.qweight', 'model.layers.0.self_attn.q_proj.qzeros']
NotImplementedError: Cannot copy out of meta tensor; no data!
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() ...
The same script without the stop/resume step (with or without checkpoint=) gives 0 meta tensors, a working CPU forward and a working .to("cuda:0"). With AWQ the result is the same: 124 meta tensors after the resume, and the same error.
| run | meta tensors after quantize() |
CPU forward | .to("cuda") |
saved checkpoint vs uninterrupted |
|---|---|---|---|---|
| GPTQ, no checkpoint | 0 | ok | ok | — |
| GPTQ, checkpoint, uninterrupted | 0 | ok | ok | identical |
| GPTQ, checkpoint, resumed at step 4 | 152 | NotImplementedError | NotImplementedError | identical |
| AWQ, checkpoint, resumed at step 4 | 124 | NotImplementedError | NotImplementedError | identical |
Suggested fix
At loop exit, materialize the checkpoint-restored packed modules from the per-attempt index the adapter writes. That index already maps every tensor to a byte range of an immutable checkpoint object, so this can reuse the undo_offload_to_disk / weights-map path. One option is to register these modules with the same offload hook as freshly offloaded modules, so the #4498 restore covers them. Then run rehome_quantized_kernel as usual. At minimum, include QUANT_TYPE modules that still own meta tensors in the strict check so the caller gets the "reload the saved checkpoint" error instead of a raw meta-tensor failure. Update docs/looper-checkpoint-redesign.md:147.
Test that should have caught it
tests/test_offload_quantized_modules_restored_4450.py covers only uninterrupted runs. The checkpoint recovery tests (tests/checkpoint_quantization_driver.py and test_checkpoint_quantization.py) compare only the saved output. One in-session forward (or a no meta tensors assertion) after the resumed quantize() in the driver would catch it.
Severity
Medium. The saved checkpoint is correct. But the documented resume workflow is quantize, then evaluate in-session, then save, and its in-session half fails after every real resume, with no diagnostic.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 17, 2026
Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow.
Qubitium commentedon Nov 17, 2026
Additional data on the same build (
main@ 4b65923, RTX 5090, Qwen2.5-0.5B-Instruct, interrupted at step 4 and then resumed):quantize()layers.0-3.*.weight,weight_scale_inv,bias)NotImplementedError: Cannot copy out of meta tensor.to("cuda")So the weight-only looper is affected as well. EXL3 is not, because its restore branch
load_state_dict(..., assign=True)s the CPU buffers (gptq_checkpoint.py:~584). Applying that same materialization to the other packed kinds at loop exit would cover GPTQ, AWQ and FP8.🤖 Generated with Claude Code
fix(offload): finish the in-session materialisation contract for resu…
Offload finalized modules as file-backed tensors instead of meta + ho…
Remove accelerate: explicit WeightLoader for weight loading, placemen…