Skip to content

test(interop): forward the round-trip fixture's inputs on the model device (#4908) - #4911

Merged
Qubitium merged 1 commit into
mainfrom
fix/issue-4908
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/issue-4908

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4908.

Cause

#4871 deliberately stopped installing the per-module AlignDevicesHook for a single-device placement (the hooks pinned the model in a reference cycle), so a direct forward no longer moves CPU inputs to the accelerator. tests/test_checkpoint_interop_4053.py::_logits always built its input_ids on the CPU, and the [gptq_triton] case loads on cuda:

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)

Fix

_logits now forwards its inputs on the model's own device (_model_device helper, CPU fallback). The round-trip assertions are unchanged; generate() on CPU input_ids is unaffected because transformers moves its inputs.

Evidence

tree result
origin/main d8758c48 1 failed, 26 passed, 1 skipped
1ba67030 (#4871, first bad commit) 1 failed, 1 passed
6ec93e63 (before #4871) 2 passed
this PR 27 passed, 1 skipped
  • ruff check tests: clean
  • No other test in the file forwards CPU tensors into a CUDA model; the other direct-forward fixtures in tests/ load on the CPU.

Residual risk

  • The helper reads next(model.parameters()).device; a parameter-free model falls back to CPU, which is correct for every fixture in this file.

…evice (#4908)

#4871 stopped installing the per-module AlignDevicesHook for a single-device
placement, so a direct forward no longer moves CPU inputs to the accelerator.
The [gptq_triton] case of test_load_state_dict_round_trip_preserves_v1_model
loaded on cuda and forwarded CPU input_ids, raising
'Expected all tensors to be on the same device ... index is on cpu'.

Move the fixture's inputs to the model's device; the round-trip assertions are
unchanged. Red on main d8758c4 (1 failed), green here (27 passed, 1 skipped).
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