Skip to content

test: select CUDA devices relative to the host, not cuda:6/7/8 (#4768) - #4857

Merged
Qubitium merged 1 commit into
mainfrom
test/issue-4768-device-indices
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
test/issue-4768-device-indices

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Part 2 of #4768 (parts 1, 3 and 4 landed in #4787). Five test sites gated on a
device index from the lab's 8-GPU box, so they skipped on every host with fewer
than seven GPUs and never ran in CI. AGENTS.md requires capability-relative
device selection, not a fixed index.

File Stale Fix
tests/test_gptq.py (TestGPTQAddBatchCPU, TestGPTQHessianChunking) device_count() <= 6 gate, cuda:6 CUDA-availability skip, torch.cuda.current_device()
tests/test_g2h_tensor_quality.py gpu_index = 6 + count skip torch.cuda.current_device()
tests/test_cuda_event_stream_activation_buffer.py device_count() <= 6 gate, cuda:6 CUDA-availability skip, torch.cuda.current_device()
tests/test_fp4_llama3_fp4.py parametrized cuda:7/cuda:8 the visible devices: current, plus the last one when a second GPU exists

tests/test_hessian.py (the fifth site in the issue) already uses cuda:0 and
a 2-device gate since #4787.

Regression guard

tests/test_device_index_gates_4768.py fails if any of the four files
reintroduces a device_count() <= N gate with N > 0, a torch.device("cuda", N) / "cuda:N" literal with N > 0, or gpu_index = N with N > 0.

  • On unmodified main: 4 failed.
  • With this change: 4 passed.

Evidence (1x GB10, sm_121)

# before (main)
tests/test_gptq.py -k "AddBatchCPU or HessianChunking"        -> 2 skipped
tests/test_g2h_tensor_quality.py -k roundtrip_lossless         -> 6 skipped
tests/test_cuda_event_stream_activation_buffer.py -k benchmark -> 1 skipped
tests/test_fp4_llama3_fp4.py -k module_gpu_consistency         -> 2 skipped
= 11 skipped

# after
tests/test_gptq.py -k "AddBatchCPU or HessianChunking"        -> 2 passed
tests/test_g2h_tensor_quality.py -k roundtrip_lossless         -> 6 passed
tests/test_cuda_event_stream_activation_buffer.py -k benchmark -> 1 passed
tests/test_fp4_llama3_fp4.py -k module_gpu_consistency         -> 1 skipped (checkpoint absent)
= 9 passed, 1 skipped

ruff check passes on all five files.

Closes #4768.

Part 2 of #4768. Four files gated on a lab-specific device index, so they
skipped on every host with fewer than seven GPUs:

- ``tests/test_gptq.py``: ``TestGPTQAddBatchCPU`` and ``TestGPTQHessianChunking``
  gated on ``device_count() <= 6`` and ran on ``cuda:6``; they now need only
  CUDA and use ``torch.cuda.current_device()``.
- ``tests/test_g2h_tensor_quality.py``: hard-coded ``gpu_index = 6`` replaced
  with the current device.
- ``tests/test_cuda_event_stream_activation_buffer.py``: same gate and index
  replaced with a CUDA-availability skip and the current device.
- ``tests/test_fp4_llama3_fp4.py``: ``cuda:7``/``cuda:8`` parametrization
  replaced with the visible devices (current, plus the last one when a second
  GPU exists).

``tests/test_device_index_gates_4768.py`` guards the four files against a fixed
index above 0 coming back; it fails on ``main`` and passes with this change.

Measured on a 1-GPU host (GB10, sm_121): the selected tests go from 11 skipped
to 9 passed + 1 skipped (the FP4 checkpoint is absent) plus the two benchmark
classes now passing.
@Qubitium
Qubitium merged commit f2963ca into main Nov 17, 2026
6 checks passed
@Qubitium
Qubitium deleted the test/issue-4768-device-indices branch November 17, 2026 17:30
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