Repository navigation
Description
Summary
quantize(..., checkpoint=CheckpointConfig(...)) with AWQConfig cannot resume a stopped run when the source model is BF16. BF16 is the default dtype of most current checkpoints (Qwen2/2.5/3, Llama 3, ...). The first resume attempt raises:
gptqmodel.looper.checkpoint_store.CheckpointError: checkpoint tensor schema differs: model.layers.0.self_attn.q_proj
AwqGEMMLinear.pack() keeps the scale dtype of the source (scale_dtype = scales.dtype if scales.dtype in (fp16, bf16) else fp16), so the committed bundle holds BF16 scales. restore_packed_module rebuilds the template with the kernel constructor. AWQuantLinear.__init__ registers scales as torch.float16, and packed_module_config records no scale dtype. The template therefore never matches, and QuantizationCheckpointAdapter.restore rejects every AWQ module. #4324 fixed the same mismatch for bias (bias_dtype) and #4792 for NF12/MACaQ buffers. The AWQ scales buffer was not covered.
Checkpointed AWQ is documented as supported (checkpoint.md: "GPTQ, RTN, AWQ, ..."). The GPTQ path is not affected because GPTQ scales are stored as FP16. A dynamic GPTQ stop/resume on the same model resumed and gave a bit-identical PPL.
Introduced by
Pre-existing. AWQ checkpoint support plus BF16 scale storage in AwqGEMMLinear.pack. The restore path was reworked in #3796 (ModuleConstructorConfig), and #4362 added only bias_dtype. Still present at a311c91b9.
Location
gptqmodel/looper/checkpoint_modules.py @ a311c91:
packed_module_config(around lines 95-131) recordsbias_dtype,compute_dtype(bnb/bitblas/macaq) andescape_rows, but noscalesdtype.restore_packed_module(lines 154-247) restoresbiasdtype only.
gptqmodel/nn_modules/qlinear/__init__.py around line 3413 (AWQuantLinear.__init__):
self.register_buffer("scales", t.zeros(..., dtype=t.float16))gptqmodel/nn_modules/qlinear/gemm_awq.py lines 454-469 (pack): scale_dtype = scales.dtype ...; self.register_buffer("scales", stored_scales).
gptqmodel/looper/gptq_checkpoint.py lines 593-598 (the schema comparison that raises).
Reproduction (ran on a311c91, RTX 4090)
import os, signal, sys, threading
from datasets import load_dataset
from gptqmodel import AWQConfig, CalibrationConfig, CheckpointConfig, CheckpointStopped, GPTQModel
src = "Qwen2.5-0.5B-Instruct" # local copy of Qwen/Qwen2.5-0.5B-Instruct (config dtype bfloat16)
cal = [t for t in load_dataset("Salesforce/wikitext", "wikitext-2-raw-v1", split="train")["text"] if len(t) > 200][:64]
m = GPTQModel.load(src, AWQConfig(bits=4, group_size=128))
if sys.argv[1:] == ["stop"]:
threading.Timer(30, lambda: os.kill(os.getpid(), signal.SIGINT)).start()
try:
m.quantize(CalibrationConfig(dataset=cal, batch_size=1),
checkpoint=CheckpointConfig(path="ckpt_awq", resume="auto"))
except CheckpointStopped as e:
print("STOPPED", e); sys.exit(75)
m.save("out_awq")Run once with stop, then again without it:
STOPPED checkpoint committed; resume from step 7
...
File "gptqmodel/looper/gptq_checkpoint.py", line 599, in restore
raise CheckpointError(f"checkpoint tensor schema differs: {name}")
gptqmodel.looper.checkpoint_store.CheckpointError: checkpoint tensor schema differs: model.layers.0.self_attn.q_proj
Instrumenting restore_packed_module shows the mismatch:
module config : {'bits': 4, 'group_size': 128, 'sym': True, 'format': 'gemm', 'bias_dtype': 'torch.bfloat16', 'kernel': '...gemm_awq.AwqGEMMLinear', ...}
template : qweight (896,112) int32 | qzeros (7,112) int32 | scales (7,896) float16 | bias (896,) bfloat16 | qzeros_format () int64
bundle : qweight (896,112) I32 | qzeros (7,112) I32 | scales (7,896) BF16 | bias (896,) BF16 | qzeros_format () I64
The same script with GPTQConfig resumes correctly.
Expected vs actual
- Expected: a stopped AWQ run on a BF16 model resumes from the committed layer and saves normally.
- Actual: every resume attempt fails before layer 0, so AWQ checkpointing is unusable for BF16 models.
resume="auto"cannot recover, and the run has to restart from scratch with a new checkpoint path.
Suggested fix
Record the stored scales dtype in packed_module_config, as is already done for bias_dtype. In restore_packed_module, reallocate module.scales at that dtype. Alternatively, record and restore every buffer dtype generically from the bundle header. Add a BF16 AWQ stop/resume case to the checkpoint tests.
Activity
fix(quantize): do not pack with an inherited inference-only backend (#…
fix(checkpoint): record the AWQ scale dtype for resume (ModelCloud#6153…
tests: pin file-backed resume/offload state in the remaining checkpoi…
Remove accelerate: explicit WeightLoader for weight loading, placemen…