Skip to content

[TEST] test_checkpoint_interop_4053::test_load_state_dict_round_trip_preserves_v1_model[gptq_triton] is red on main after #4871: _logits() forwards CPU input_ids into a CUDA model #4908

Closed

Description

@Qubitium

Found on origin/main @ d8758c48.

PYTHONPATH=<main> /root/venv/bin/python -m pytest tests/test_checkpoint_interop_4053.py -q -p no:randomly
1 failed, 26 passed, 1 skipped   (exit 1)

FAILED tests/test_checkpoint_interop_4053.py::test_load_state_dict_round_trip_preserves_v1_model[gptq_triton]
E  RuntimeError: Expected all tensors to be on the same device, but got index is on cpu,
   different from other tensors on cuda:0 (when checking argument in method wrapper_CUDA__index_select)
   torch/nn/functional.py:2621 (F.embedding)

Bisect

commit result
6ec93e63 (#4859, base of my branches) 2 passed
1ba67030 (#4871, "drop the reference cycles a single-device GPU load leaves behind") 1 failed, 1 passed
d8758c48 (main) 1 failed, 26 passed, 1 skipped

#4871 is the first bad commit. It is a regression of the test, not of the product: its commit message states the intended contract change — "direct CPU-tensor forwards now require the model device, which is what accelerate and transformers do when no hook is installed" — and simple_dispatch_model now skips AlignDevicesHook for a single-device map, so nothing moves inputs any more.

Cause

tests/test_checkpoint_interop_4053.py:75

def _logits(model):
    with torch.inference_mode():
        return model(input_ids=torch.tensor([[1, 3, 4, 5]]), use_cache=False).logits.float()

The tensor is always on the CPU, but the [gptq_triton] case loads the model with device="cuda". Before #4871 the per-module AlignDevicesHook(io_same_device=True) moved the input; now the forward raises.

Fix

Move the fixture's inputs to the model's device (or the test's device argument) so the test exercises the round-trip identity rather than the removed implicit move. The [gptq_torch] CPU case must keep working. generate() on CPU input_ids is unaffected (transformers moves them), so the product contract from #4871 stands.

This is the only failing case in the file; no other test in it forwards CPU tensors into a CUDA model.

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim released: agent-53ba17eb4d83 finished this issue.

    Pull request: #4911

    Fix the stale direct-forward fixture in tests/test_checkpoint_interop_4053.py: move _logits() inputs to the model device after #4871 removed the implicit input move; verify gptq_torch (CPU) and gptq_triton (CUDA) cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions