Skip to content

fix(checkpoint): record the AWQ scale dtype for resume (#6153) - #6161

Merged
Qubitium merged 1 commit into
mainfrom
fix/6153-awq-scales-dtype
Nov 28, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/6153-awq-scales-dtype

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

AwqGEMMLinear.pack keeps the source scale width:

scale_dtype = scales.dtype if scales.dtype in (torch.float16, torch.bfloat16) else torch.float16

so a BF16 model's committed bundle holds BF16 scales. restore_packed_module
rebuilt the template from the kernel constructor, and AWQuantLinear.__init__
registers scales at FP16. packed_module_config recorded no scale dtype, so
the template never matched and every resume of a stopped BF16 AWQ run failed
before layer 0:

gptqmodel.looper.checkpoint_store.CheckpointError: checkpoint tensor schema differs: model.layers.0.self_attn.q_proj

BF16 is the default dtype of most current checkpoints, so checkpointed AWQ was
unusable there. The GPTQ path was unaffected because GPTQ scales are FP16.

Fixes #6153

What Changed

Behaviour change: checkpoint module configs for non-FP16 scale widths gain a
scales_dtype entry. FP16 configs are unchanged, so existing checkpoints
restore as before. Out of scope: an end-to-end stop/resume of a real AWQ run
(needs GPU quantization and model downloads); the adapter round trip is covered
directly.

Tests

  • Unit tests have been executed and passed.
  • I added a new simple/fast unit test for this change.

Red (source reverted, new tests):

cd tests && PYTHONPATH=$PWD/..:$PWD /root/venv/bin/python -m pytest \
  test_checkpoint_awq_scales_dtype_6153.py -q --tb=line
# E   CheckpointError: checkpoint tensor schema differs: proj
# 1 failed, 2 passed in 3.67s

Green (fix applied):

cd tests && PYTHONPATH=$PWD/..:$PWD /root/venv/bin/python -m pytest \
  test_checkpoint_awq_scales_dtype_6153.py -q
# 3 passed in 3.67s

Checkpoint family (no regressions):

cd tests && PYTHONPATH=$PWD/..:$PWD /root/venv/bin/python -m pytest \
  test_checkpoint_awq_scales_dtype_6153.py test_checkpoint_bias_dtype_4324.py \
  test_checkpoint_scale_dtype.py test_checkpoint_modules.py \
  test_checkpoint_quant_buffer_dtypes_4458.py test_checkpoint_resume_nonpersistent_4777.py \
  test_awq_checkpoint_bias_dtype_5828.py test_checkpoint_store.py \
  test_checkpoint_metadata_contracts.py -q -rs
# 117 passed in 24.82s

cd tests && PYTHONPATH=$PWD/..:$PWD /root/venv/bin/python -m pytest \
  test_checkpoint_resume_nf12_macaq_4792.py test_checkpoint_extension.py \
  test_checkpoint_processor_adapter.py -q -rs
# 29 passed in 5.99s

Lint: ruff check 0.14.2 on both changed files: all checks passed.
No skips in any run above.

Measured Impact

Functional before/after for the adapter round trip (CPU, synthetic BF16 AWQ
bundle):

Case Before After
BF16 AWQ resume (scales bf16 in bundle) CheckpointError: tensor schema differs restores, scales bf16
FP16 AWQ resume restores restores, no config change
Bundle corrupted to a different width rejected rejected

No VRAM/perf change: the checkpoint stores the same tensors.

Model Support / Module Plan

Not applicable: no model, alias, definition, or module-plan change.

AWQ onboarding safety

Not applicable to onboarding: no new model/alias/definition and no change to AWQ
grouping, search, replay or fold. This only records and restores the dtype of the
already-packed scales buffer.

Logic Flow Documentation

  • This change does not alter a major logic flow.

It extends the existing per-module dtype round trip (bias_dtype) with one more
recorded buffer width; the capture/restore ordering is unchanged.

Review Requirements

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface.
  • Considered and eliminated potential regressions.

Kernel Accuracy Requirements

Not applicable: no kernel change.

Notes

The recorded width is the live buffer dtype, which is exactly what the bundle
stores. That also keeps the CPU AVX512 AWQ path consistent: transform_cpu
widens scales to FP32 in place, and both the bundle and the recorded config
then carry FP32.

`AwqGEMMLinear.pack` keeps the source scale width (`scales.dtype if
scales.dtype in (fp16, bf16) else fp16`), so a BF16 model's committed bundle
holds BF16 `scales`. `restore_packed_module` rebuilt the template from the
kernel constructor, which allocates `scales` at FP16, and
`packed_module_config` recorded no scale dtype. Every resume of a BF16 AWQ run
therefore failed `checkpoint tensor schema differs` before layer 0.

Record `scales_dtype` when the stored width is not the FP16 template default,
and restore it on the meta template the same way `bias_dtype` is restored
(#4324). FP16 needs no entry, so existing GPTQ and FP16 AWQ checkpoint configs
are unchanged. The recorded width always equals the bundle's, because capture
serializes the live `state_dict()`.

Fixes #6153
@Qubitium
Qubitium marked this pull request as ready for review November 28, 2026 08:52
@Qubitium
Qubitium merged commit ec6cb38 into main Nov 28, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/6153-awq-scales-dtype branch November 28, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant