Repository navigation
Description
Found on main @ dba142d, RTX 5090 (CUDA 13.2, torch 2.15, transformers 5.22).
What is wrong
quantize(..., checkpoint=CheckpointConfig(...)) accepts NF12 and MACaQ: validate_checkpoint_support (gptqmodel/looper/gptq_checkpoint.py:293) passes, and the interrupted run writes checkpoint generations. Resuming that checkpoint always fails, so every finished layer is lost:
gptqmodel.looper.checkpoint_store.CheckpointError: checkpoint tensor schema differs: model.layers.0.self_attn.q_proj
gptq_checkpoint.py:582 restore()
restore() rebuilds an empty module template with restore_packed_module() (gptqmodel/looper/checkpoint_modules.py) and requires the bundle's tensors to match module.state_dict() exactly in names, shapes and dtypes (gptq_checkpoint.py:575-582). The rebuilt template does not match the data-dependent or runtime-dtype buffers of these two kernels. I instrumented the comparison to find the exact mismatch:
| method | template (expected) | bundle on disk |
|---|---|---|
| NF12 | nf12_escapes: (0, 8) int16 |
nf12_escapes: (589, 8) int16 (the escape count depends on the data and differs per module) |
MACaQ (dtype=torch.float16 load) |
BH: (32,32) bfloat16, pre_scale: (896,) bfloat16 |
BH: (32,32) float16, pre_scale: (896,) float16 (the template uses the source config's dtype, not the run's compute dtype; docs/checkpoint-and-runtime-contracts.md:188 says these are kept in the model dtype) |
This is the same class of failure as #4324, where the bias dtype was not carried. The fix there covered only bias_dtype.
The checkpoint recovery tests never exercise either method. tests/test_checkpoint_method_compatibility.py parametrizes rtn/fp8/gguf/bitsandbytes (weight-only) and qqq/paro/exl3 (specialized). Its tiny random-token models would also produce 0 NF12 escapes.
Repro
Qwen2.5-0.5B-Instruct truncated to 2 layers (real safetensors copy), 16 C4 rows, dtype=torch.float16. The process is killed with SIGKILL right after the layer-0 checkpoint boundary is published (the same hook as tests/checkpoint_quantization_driver.py --mode kill-after), then resumed with the same CheckpointConfig:
import os, signal, torch
from gptqmodel import GPTQModel, CheckpointConfig
from gptqmodel.quantization.config import CalibrationConfig, NF12Config, MacaqConfig
from gptqmodel.looper.checkpoint import CheckpointExtension
def run(cfg, kill):
if kill:
orig = CheckpointExtension.on_boundary
def boundary(ext, event):
orig(ext, event)
if event.step.index == 0: os.kill(os.getpid(), signal.SIGKILL)
CheckpointExtension.on_boundary = boundary
m = GPTQModel.load(MODEL, cfg, dtype=torch.float16)
m.quantize(CalibrationConfig(dataset=texts), checkpoint=CheckpointConfig("ck"))
m.save("out")
run(NF12Config(), kill=True) # process 1: killed after layer 0
run(NF12Config(), kill=False) # process 2: resume -> CheckpointErrorResults from the same harness for every method (base, base, uninterrupted with checkpoint, kill + resume; all compared bytewise):
| method | resume |
|---|---|
| GPTQ, GPTQ desc_act, AWQ gemm, RTN, FP8, GGUF q4_k_m, BnB 4-bit, EXL3, Paro | resumed output bytewise identical to the uninterrupted run |
| NF12 | CheckpointError: checkpoint tensor schema differs |
| MACaQ | CheckpointError: checkpoint tensor schema differs |
| QQQ | workspace is on the meta device (#4777) |
| VPTQ | refused up front with checkpoint has no state adapter for this processor chain (OK) |
Suggested fix
- Persist the shape of data-dependent buffers (NF12
nf12_escapesrow count, and any MoE escape offsets) in the module config, and allocate the template with that shape. Alternatively, build the template from the bundle's header shapes for buffers the kernel declares as variable-length. - Persist the actual dtype of MACaQ
BH/pre_scale(asbias_dtypealready is) and restore it before the schema comparison. Or validate the floating buffers against the run's compute dtype instead of the template default. - Add NF12 and MACaQ to the
weight_only/specializedrecovery parametrizations, using a model with real weights (or a stub with forced escapes) so that the escape count is non-zero.
Severity
High for long runs: the documented crash-recovery feature reports success while it saves generations, but those generations can never be resumed for two supported methods. The user finds out only after the crash.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 17, 2026
Claiming. Will persist the data-dependent NF12
nf12_escapesrow count and the MACaQBH/pre_scaledtype in the module config so the restore template matches the bundle, plus a schema-level regression test for both methods.fix(looper): make NF12 and MACaQ checkpoints resumable (#4792) (#4806)