Skip to content

test(vom-gpu): gate on CUDA, not gpu_available — MPS was initialised in the parent - #131

Merged
CSSFrancis merged 1 commit into
mainfrom
fix/vom-gpu-cuda-pin
Aug 9, 2026
Merged

test(vom-gpu): gate on CUDA, not gpu_available — MPS was initialised in the parent#131
CSSFrancis merged 1 commit into
mainfrom
fix/vom-gpu-cuda-pin

Conversation

@CSSFrancis

Copy link
Copy Markdown
Owner

Fixes main's red macos-latest-py3.13 leg (also red on every branch cut since): Fatal Python error: Aborted immediately after test_vector_orientation_gpu.py's three subprocess tests return their results.

Mechanism — not just a skip: gpu_available() is True on Apple MPS, and this file calls it at module level, so on a Mac runner pytest collection initialises Metal in the parent process. That parent never does GPU work — the whole point of this file is that torch runs in a hard-exiting subprocess (the Windows CUDA-segfault pattern). Probing MPS at import defeats that isolation on the other platform, leaving an initialised Metal context in a long-lived process that goes on to run ~1300 more tests.

The default path now checks torch.cuda.is_available() and imports nothing from the GPU module, so the parent stays Metal-free. SPYDE_GPU_TESTS=1 restores the old predicate for reproducing on a Mac.

Mac accelerator coverage is unchanged: test_device_lock.py pins that every torch call site serialises through the shared lock, and the fit runs in the real app. This is the third instance of the same policy (EBSD wizard → SPYDE_EBSD_DEVICE=cpu in #125; neural batch-memory → CUDA-specific skip in #127): accelerator work under the pytest harness belongs in a subprocess or not at all.

Verified on the CUDA dev box: 3 passed, 20.4 s (the tests still run where they're meant to).

macos-latest-py3.13 aborts (SIGABRT) immediately after this file's three
subprocess tests return, on main and every branch since. gpu_available() is
True on Apple MPS, and it is called at MODULE level -- so on a Mac runner
pytest COLLECTION initialises Metal in the parent process, which never does
GPU work itself and only shells out. The subprocess pattern exists precisely
to keep torch out of the pytest process (Windows CUDA segfault); probing MPS
at collection defeats it on the other platform.

Default path now checks torch.cuda.is_available() and imports nothing from
the GPU module, so the parent stays Metal-free. SPYDE_GPU_TESTS=1 restores
the old predicate for a Mac repro. Mac accelerator coverage is unchanged:
test_device_lock.py pins the serialisation contract and the fit runs in the
real app.
@CSSFrancis
CSSFrancis marked this pull request as ready for review August 9, 2026 21:32
@CSSFrancis
CSSFrancis merged commit 343a0c6 into main Aug 9, 2026
31 checks passed
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.

1 participant