Skip to content

Commit b0f5456

Browse files
committed
fix(ci): patch gpu_backend by dotted path in the live-detection routing test
`HardwareProfile.detect()` dereferences `routing._gb.has_cuda_rust()`, where `_gb` is the `qector_decoder_v3.gpu_backend` entry in sys.modules. The test patched the package-level attribute `qd.gpu_backend` instead. Locally the two are the same object so it worked; in CI the patch did not take and `detect()` kept reading the real hardware, so the two cases expecting gpu=True/cuda=True failed on the GPU-less runner while passing on any developer machine with a GPU. monkeypatch's dotted-path form resolves the module through sys.modules, which is exactly what the code under test dereferences.
1 parent 0ffff05 commit b0f5456

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

python/tests/test_routing.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,14 @@ def test_code_object_is_classified_structurally():
137137
# ---------------------------------------------------------------------------
138138
@pytest.mark.parametrize("cuda_rust,gpu", [(False, False), (False, True), (True, True)])
139139
def test_detected_hardware_drives_huge_batch(monkeypatch, cuda_rust, gpu):
140-
monkeypatch.setattr(qd.gpu_backend, "has_cuda_rust", lambda: cuda_rust)
141-
monkeypatch.setattr(qd.gpu_backend, "gpu_available", lambda: gpu)
140+
# Patch the canonical module by dotted path, NOT via `qd.gpu_backend`.
141+
# `HardwareProfile.detect()` reads `routing._gb.has_cuda_rust()`, where `_gb`
142+
# is `qector_decoder_v3.gpu_backend` bound from sys.modules. The package-level
143+
# attribute `qd.gpu_backend` is not reliably that same object - in CI it is
144+
# shadowed, so patching it left `detect()` reading the real hardware and these
145+
# two cases failed on any machine without a GPU while passing on one with.
146+
monkeypatch.setattr("qector_decoder_v3.gpu_backend.has_cuda_rust", lambda: cuda_rust)
147+
monkeypatch.setattr("qector_decoder_v3.gpu_backend.gpu_available", lambda: gpu)
142148

143149
prof = HardwareProfile.detect()
144150
assert prof.cuda_rust is cuda_rust and prof.gpu is gpu

0 commit comments

Comments
 (0)