Repository navigation
fix(looper): make NF12 and MACaQ checkpoints resumable (#4792) - #4806
Merged
Merged
Conversation
`GPTQCheckpoint.restore` rebuilds an empty module template and requires the bundle's tensors to match `module.state_dict()` exactly in names, shapes and dtypes. Two kernels could never match, so every resume of an NF12 or MACaQ run died with `CheckpointError: checkpoint tensor schema differs` and the finished layers were lost. - NF12 allocates `nf12_escapes` with zero rows and `pack()` fills as many rows as the data needs, so the template's `(0, 8)` table never matched the bundle's `(589, 8)`. `packed_module_config` now records the escape row count and `restore_packed_module` rebuilds the table with that shape (validated; a malformed value raises `CheckpointError` instead of reaching the kernel). - MACaQ allocates `BH`/`pre_scale` at the run's compute dtype, not the source config's dtype the template used, so a fp16 run against a bf16 config mismatched. The module config now records `compute_dtype`, which the restore path already knows how to apply (the same mechanism `gptq_bitblas`/ `awq_bitblas` use), so the template is built at the run dtype. Tests: new `tests/test_checkpoint_resume_nf12_macaq_4792.py` builds each module, derives the checkpoint module config, rebuilds the template with `restore_packed_module`, and requires the full `state_dict()` schema (keys, shapes, dtypes) to match - the exact comparison that failed. A third case covers the malformed escape-row value. Red on unmodified main (b222457): all five cases fail. Green here: 5 passed, and the neighbouring `test_checkpoint_modules`, `test_nf12_codec` and `test_macaq_triton_forward_dtype_4315` suites give 107 passed with only the pre-existing `test_qqq_optional_group_scales_schema` failure (needs a buildable QQQ CUDA extension).
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.
Fixes #4792.
Problem
GPTQCheckpoint.restorerebuilds an empty module template and requires the bundle's tensors to matchmodule.state_dict()exactly in names, shapes and dtypes. Two supported methods could never match, so every resumeof an NF12 or MACaQ run died with
CheckpointError: checkpoint tensor schema differsafter the interrupted run hadalready written generations - the user only finds out after the crash.
nf12_escapes: (0, 8) int16(589, 8) int16- one row per escaped weight, data-dependentBH/pre_scalebfloat16 (source config dtype)Fix (
gptqmodel/looper/checkpoint_modules.py)packed_module_configrecords the escape row count (escape_rows), andrestore_packed_modulerebuildsnf12_escapeswith that many rows. A malformed value raisesCheckpointErrorrather than reaching the kernel.compute_dtype, which the restore path already applies (the same mechanismgptq_bitblas/awq_bitblasuse), so the template allocatesBH/pre_scale/biasat the run dtype.Both are additive config fields: a checkpoint written before this change has no such key and keeps the old
(template-derived) behaviour.
Tests (
tests/test_checkpoint_resume_nf12_macaq_4792.py)Each case builds the real module, derives the checkpoint module config, rebuilds the template with
restore_packed_moduleand requires the fullstate_dict()schema (keys, shapes, dtypes) to match - the exactcomparison that failed in
restore():test_nf12_restore_template_matches_a_data_dependent_escape_table(7 escape rows)test_macaq_restore_template_uses_the_run_compute_dtype(fp16 run against a bf16 config)test_invalid_nf12_escape_row_count_is_rejectedx3 (negative, float, string)Red on unmodified
main(b22245774): all 5 fail.Green on this branch: 5 passed;
test_checkpoint_modules,test_nf12_codecandtest_macaq_triton_forward_dtype_4315give 107 passed with only the pre-existingtest_qqq_optional_group_scales_schemafailure (needs a buildable QQQ CUDA extension).
ruff checkclean.Note: the 10
tests/test_checkpoint_method_compatibility.pyrecovery cases need CUDA plus a real model and take ~30minutes; they are not extended here, and the unit-level schema test above covers the exact step they die in.