Skip to content

fix(fused-train-state): rebuild a meta snapshot without running the inverse - #5533

Merged
Qubitium merged 1 commit into
mainfrom
fix/fused-train-state-meta-snapshot
Nov 19, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/fused-train-state-meta-snapshot

Conversation

@ZX-ModelCloud

Copy link
Copy Markdown
Collaborator

Summary

Moving a quantized module to meta discards the runtime words, so
_rebuild_checkpoint_qweight() cannot reproduce them. Its checkpoint-layout
identity check calls aten::equal, which has no meta implementation:

NotImplementedError: aten::equal: attempted to run this operator with Meta
tensors, but there was no fake impl or Meta kernel registered.

test_device_move_restores_checkpoint_layout hits this for TorchAtenLinear
and TorchFusedLinear.

What Changed

  • _materialize_snapshot_entry returns an empty tensor on the snapshot's
    device when the live module's qweight is already on meta, instead of
    running the inverse against meta operands.
  • A meta tensor carries only shape and dtype, and the RebuiltCheckpointTensor
    descriptor already knows both, so nothing is lost by not rebuilding.
  • The non-meta path is unchanged.

Tests

cd tests
python -m pytest test_kernel_audit_regressions.py -o addopts= -q --timeout=900
# before: test_device_move_restores_checkpoint_layout[torch_aten_kernel-TorchAtenLinear]
#         and [torch_fused-TorchFusedLinear] fail with the NotImplementedError
# after:  82 passed

The existing test_device_move_restores_checkpoint_layout is the regression;
it is red without this change and green with it.

Note: the GPU devices were detached from this container before the final
re-run. The 82-passed figure is from the run that had the devices; the fix
itself is device-agnostic (it branches on device.type == "meta").

  • Unit tests have been executed and passed, or the reason they are not applicable is documented.
  • I added a new simple/fast unit test for this change, or documented why that is not applicable.

Not applicable: the existing device-move test already fails for exactly this
defect, so it is the regression.

…nverse

Moving a quantized module to `meta` discards the runtime words, so
`_rebuild_checkpoint_qweight()` cannot reproduce them: its `aten::equal`
identity check has no meta implementation and raises
`NotImplementedError: aten::equal: attempted to run this operator with Meta
tensors`.

A meta tensor carries only shape and dtype, and the snapshot descriptor
already knows both, so materialize an empty tensor on that device instead of
running the inverse against meta operands.

Red: test_kernel_audit_regressions.py::test_device_move_restores_checkpoint_layout
  [gptqmodel.nn_modules.qlinear.torch_aten_kernel-TorchAtenLinear] and
  [gptqmodel.nn_modules.qlinear.torch_fused-TorchFusedLinear] fail with the
  NotImplementedError.
Green: test_kernel_audit_regressions.py 82 passed.
@Qubitium
Qubitium marked this pull request as ready for review November 19, 2026 10:40
@Qubitium
Qubitium merged commit 371b75e into main Nov 19, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/fused-train-state-meta-snapshot branch November 19, 2026 10:41
Qubitium added a commit that referenced this pull request Nov 29, 2026
…5325) (#6273)

A5 was a product defect, not a stale test: a meta move ran the int4pack
inverse (and its aten::equal identity check) against meta operands until
#5533 materialized the snapshot from its shape/dtype descriptor. A14 was
realigned by #5564, and the compiled entry now stages its operands outside
the traced graph (#5955), so the caches are published again. Both items are
green at main 2d3261d.

Extend the device-move test to assert every checkpoint operand's shape and
dtype is restored, not just qweight. Restore the cache expectations the A14
tests are named for: the compiled dequant publishes the g_idx cache on the
compute device, load_state_dict clears both metadata caches, and a full
forward still matches F.linear after the g_idx offload.

Co-authored-by: OpenAI Agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants