Skip to content

fix(looper): make NF12 and MACaQ checkpoints resumable (#4792) - #4806

Merged
Qubitium merged 1 commit into
mainfrom
fix/issue-4792-nf12-macaq-resume
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/issue-4792-nf12-macaq-resume

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4792.

Problem

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 supported methods could never match, so every resume
of an NF12 or MACaQ run died with CheckpointError: checkpoint tensor schema differs after the interrupted run had
already written generations - the user only finds out after the crash.

method template bundle
NF12 nf12_escapes: (0, 8) int16 (589, 8) int16 - one row per escaped weight, data-dependent
MACaQ (fp16 run) BH/pre_scale bfloat16 (source config dtype) float16 (run compute dtype)

Fix (gptqmodel/looper/checkpoint_modules.py)

  • NF12: packed_module_config records the escape row count (escape_rows), and restore_packed_module rebuilds
    nf12_escapes with that many rows. A malformed value raises CheckpointError rather than reaching the kernel.
  • MACaQ: the module config records compute_dtype, which the restore path already applies (the same mechanism
    gptq_bitblas/awq_bitblas use), so the template allocates BH/pre_scale/bias at 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_module and requires the full state_dict() schema (keys, shapes, dtypes) to match - the exact
comparison 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_rejected x3 (negative, float, string)

Red on unmodified main (b22245774): all 5 fail.

Green on this branch: 5 passed; test_checkpoint_modules, test_nf12_codec and
test_macaq_triton_forward_dtype_4315 give 107 passed with only the pre-existing test_qqq_optional_group_scales_schema
failure (needs a buildable QQQ CUDA extension). ruff check clean.

Note: the 10 tests/test_checkpoint_method_compatibility.py recovery cases need CUDA plus a real model and take ~30
minutes; they are not extended here, and the unit-level schema test above covers the exact step they die in.

`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).
@Qubitium
Qubitium merged commit be3c732 into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the fix/issue-4792-nf12-macaq-resume branch November 17, 2026 15:26
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