Repository navigation
fix(checkpoint): record the AWQ scale dtype for resume (#6153) - #6161
Merged
Merged
Conversation
`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
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
AwqGEMMLinear.packkeeps the source scale width:so a BF16 model's committed bundle holds BF16
scales.restore_packed_modulerebuilt the template from the kernel constructor, and
AWQuantLinear.__init__registers
scalesat FP16.packed_module_configrecorded no scale dtype, sothe template never matched and every resume of a stopped BF16 AWQ run failed
before layer 0:
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
gptqmodel/looper/checkpoint_modules.py:packed_module_configrecordsscales_dtypewhen the module's storedscaleswidth differs from the FP16 template default. The recorded widthalways equals the bundle's, because capture serializes the live
state_dict().restore_packed_modulereallocates the metascalesplaceholder at thatwidth, mirroring the existing
bias_dtyperestore ([BUG] Checkpoint resume fails with "checkpoint tensor schema differs" for any model whose quantized layers have a non-fp16 bias (Qwen2/2.5, OPT, Bloom…) #4324)._deserialize_float_dtypehelper; the error messages are unchanged.tests/test_checkpoint_awq_scales_dtype_6153.pydriving thereal adapter capture/restore path.
Behaviour change: checkpoint module configs for non-FP16 scale widths gain a
scales_dtypeentry. FP16 configs are unchanged, so existing checkpointsrestore 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
Red (source reverted, new tests):
Green (fix applied):
Checkpoint family (no regressions):
Lint:
ruff check0.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):
scalesbf16 in bundle)CheckpointError: tensor schema differsscalesbf16No 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
scalesbuffer.Logic Flow Documentation
It extends the existing per-module dtype round trip (
bias_dtype) with one morerecorded buffer width; the capture/restore ordering is unchanged.
Review Requirements
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_cpuwidens
scalesto FP32 in place, and both the bundle and the recorded configthen carry FP32.