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

   ### Related Issues
   
   <!-- Closes #123 -->
   
   ### Changes
   
   - [ ] Bug fix
   - [x] New feature
   - [ ] Refactoring
   - [ ] Documentation
   - [x] Test
   - [ ] CI/CD pipeline
   - [ ] Other
   
   ### Why
   
   Callers (Python bindings, benchmarks, future planning layers) currently have 
no first-class way to ask "what compute target is the Rust pipeline running 
against?". They either sniff engine state or rely on string-based feature 
detection.
   
   This adds a small `Backend` enum so that question has a typed answer.
   
   It is **not** a dispatch axis: there is currently only one Rust-side encoder 
implementation (CUDA / nvcc), so a 2-D `(Encoding, Backend) -> &'static dyn 
QuantumEncoder` table would have nothing extra to dispatch to. The AMD / Triton 
path that already exists lives entirely on the Python side 
(`qumat_qdp/backends/amd.py`) and does not have a matching Rust-level 
`QuantumEncoder` implementation — so it is **not** modelled here as a variant. 
Grow the enum and the dispatch table at the same time when a Rust-side AMD path 
is proposed, not before.
   
   ### How
   
   **Variants** (`qdp-core/src/types.rs`)
   
   - `CudaNvidia` — in-tree CUDA kernels (the historical default)
   - `TorchRef`   — pure-PyTorch reference, used by CPU / non-CUDA CI lanes
   
   **API**
   
   - `Backend::as_str()`      — stable lower-case name for logging 
(`"cuda-nvidia"` / `"torch-ref"`)
   - `Backend::from_str_ci()` — case-insensitive parse with convenience aliases 
(`cuda` / `nvidia` map to `CudaNvidia`; `torch` / `torchref` / `cpu` map to 
`TorchRef`). Names that look like AMD (`amd`, `triton`, `triton-amd`) get a 
dedicated error message pointing at the Python-side path so users don't think 
the Rust core silently dropped the flag.
   - `Backend::detect()`      — compile-time best guess (Linux → `CudaNvidia`, 
else `TorchRef`). Does **not** probe runtime CUDA availability; that remains 
the engine's responsibility.
   
   `Backend` is re-exported from `qdp_core::` next to `Encoding` / `Dtype` so 
callers can `use qdp_core::Backend;`.
   
   **Tests** (`qdp-core/tests/types.rs`) — 5 new
   
   - case-insensitive parse + aliases + whitespace tolerance
   - AMD names rejected with a message mentioning both "AMD" and "Python"
   - unknown names rejected
   - `as_str` round-trips through `from_str_ci` for every variant
   - `detect()` returns the platform-appropriate variant
   
   ### Local verification
   
   - `cargo test --tests` on `qdp-core`: all passing (11 type tests including 
the 5 new ones)
   - Clippy / fmt / license-header: clean
   - No call sites touched — this is a new public type, not a dispatch change
   
   ## Checklist
   
   - [x] Added or updated unit tests for all changes
   - [x] Added or updated documentation for all changes
   


-- 
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