ryankert01 opened a new pull request, #1416:
URL: https://github.com/apache/mahout/pull/1416

   Follow-up to #1321 (now merged); addresses #1414.
   
   ## Why
   
   #1321 lets `_qdp` build and import **without the CUDA toolkit** (stub CUDA 
Runtime symbols). That breaks the long-standing assumption that "the `_qdp` 
extension imports" ⟺ "a GPU is usable", which the test suite relied on to gate 
GPU tests. #1321 patched the immediate breakage by skipping `@pytest.mark.gpu` 
tests on `torch.cuda.is_available()`, but that is a **proxy**: on this 
feature's headline scenario — a GPU host with PyTorch but no toolkit — `_qdp` 
is a stub build, yet `torch.cuda.is_available()` is still `True`, so the GPU 
tests would run against the stub and abort.
   
   This PR makes the engine report the truth.
   
   ## What
   
   - **`qdp-core`**: add `cuda_runtime_available()` — queries 
`cudaGetDeviceCount` and returns `true` only when a device is actually present. 
In a `qdp_no_cuda` (stub) build it resolves to the existing 999-sentinel stub, 
so it returns `false` with no `cfg` branching or dead code. Re-exported from 
the crate root.
   - **`_qdp`**: expose it as `_qdp.cuda_available()`.
   - **`qumat_qdp`**: add `is_cuda_available()` (mirrors the existing 
`is_triton_amd_available()`) as the single Python source of truth.
   - **`testing/conftest.py`**: gate the `@pytest.mark.gpu` auto-skip on the 
native signal, falling back to `torch` only if the helper is absent.
   - **`test_fallback.py`**: coverage that also runs on a stub build, guarding 
that querying availability returns a `bool` without aborting.
   
   ## Test plan
   
   Verified locally on 4× NVIDIA GPUs (CUDA 12.8), real build:
   
   - `_qdp.cuda_available()` / `qumat_qdp.is_cuda_available()` → `True` with a 
GPU, `False` under `CUDA_VISIBLE_DEVICES=""`.
   - `testing/qdp` + `testing/qdp_python` with CUDA hidden: **130 passed, 156 
skipped, 0 failed** (no aborts).
   - The 10 tests that crashed in #1321's CI run: **pass on GPU**, **skip when 
hidden**.
   - `qdp-core` builds in both real and `QDP_NO_CUDA=1` stub modes; full Rust 
suite, `clippy --all-features -D warnings`, `ruff`, and `ty` all clean.
   
   ## Out of scope (left in #1414)
   
   Making the stub path raise a clean `RuntimeError` instead of aborting for 
direct (non-test) callers, and collapsing the ~65 redundant inline 
`torch.cuda.is_available()` checks now that the conftest gate is accurate.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to