Skip to content

Add cuda-13 build feature; let parent crates select the CUDA major - #9

Merged
raphaelsty merged 1 commit into
masterfrom
feat/cuda-13-build-option
Jun 16, 2026
Merged

raphaelsty merged 1 commit into
masterfrom
feat/cuda-13-build-option

Conversation

@raphaelsty

Copy link
Copy Markdown
Contributor

Why

cudarc binds exactly one CUDA major version at compile time — the cuBLAS/NVRTC SONAMEs (.so.12 vs .so.13) and generated bindings differ between majors. Today the cuda feature hard-pins cudarc/cuda-11080, so:

  • a downstream crate (e.g. next-plaid) cannot build fastkmeans-rs for CUDA 13 without vendoring it, and
  • on a CUDA-13-only host (driver 580 / toolkit 13.x, e.g. our H100 boxes) the kernels fail at runtime — the .so.12 libraries don't exist, and feeding mismatched libs trips CUDA_ERROR_UNSUPPORTED_PTX_VERSION.

What

Decouple “enable the CUDA code” from “choose the CUDA major”:

feature CUDA notes
cuda 11.8 / 12.x unchanged behaviour — existing users unaffected
cuda-13 13.x new; for hosts where only .so.13 exists
_cuda — internal gate, pulls in cudarc + compiles the CUDA code (don't enable directly)
  • cudarc no longer pins a version feature in its dependency line; the version is selected by cuda / cuda-13.
  • All library/example/test #[cfg(feature = "cuda")] gates now key off _cuda, so they compile under either major.
  • Enabling both cuda and cuda-13 fails to compile by design (mutually exclusive).

Validation

cargo build passes for: default (no CUDA), --features cuda, and --features cuda-13. --features cuda,cuda-13 fails as expected. Runtime-verified on a CUDA-13 H100 host (driver 580.126.09).

Release

Version bumped to 1.0.7. This needs to be published to crates.io before next-plaid can depend on the cuda-13 feature (see companion PR lightonai/next-plaid).

🤖 Generated with Claude Code

cudarc binds exactly one CUDA major version at compile time (the cuBLAS/NVRTC
SONAMEs and generated bindings differ between majors). Previously the `cuda`
feature hard-pinned `cudarc/cuda-11080`, so a downstream crate could not build
fastkmeans-rs for CUDA 13 without vendoring — and on a CUDA-13-only host the
kernels fail to load (`.so.12` SONAMEs are absent / wrong PTX toolchain).

Decouple "enable the CUDA code" from "choose the CUDA major":

  * cudarc no longer pins a version feature in its dependency declaration.
  * internal `_cuda` feature pulls in cudarc and gates all CUDA code.
  * public `cuda` keeps the historical default (CUDA 11.8 / 12.x) — no behaviour
    change for existing users.
  * new public `cuda-13` selects `cudarc/cuda-13000` for CUDA 13.x hosts.

Enabling both `cuda` and `cuda-13` fails to compile by design (the versions are
mutually exclusive). All library/example/test cfg gates now key off `_cuda`, so
they build under either CUDA major.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@raphaelsty
raphaelsty merged commit 3907915 into master Jun 16, 2026
10 checks passed
raphaelsty added a commit to lightonai/next-plaid that referenced this pull request Jun 16, 2026
* Add `cuda-13` build feature and make `--force-gpu` truly force the GPU

## cuda-13 build option

cudarc binds exactly one CUDA major version at compile time, so a single binary
cannot serve both CUDA 12 and CUDA 13 hosts. Expose the choice as a feature
instead of hard-pinning it:

  * `cuda`    -> CUDA 11.8 / 12.x  (default, unchanged behaviour)
  * `cuda-13` -> CUDA 13.x         (hosts where only .so.13 libraries exist)
  * `_cuda`   -> internal gate that compiles the CUDA code; reached via either
                 public feature (do not enable directly)

cudarc no longer pins a version in its dependency line; `cuda` / `cuda-13`
select it (and the matching `fastkmeans-rs` feature). All `next-plaid` and
`colgrep` `#[cfg(feature = "cuda")]` gates now key off `_cuda` so they compile
under either major. Enabling both `cuda` and `cuda-13` fails by design. Applied
across next-plaid, colgrep and next-plaid-api; requires fastkmeans-rs >= 1.0.7
(companion PR lightonai/fastkmeans-rs#9).

## --force-gpu must not silently fall back to CPU

ORT registers execution providers best-effort: a CUDA EP that fails to
initialize is silently dropped and the session quietly runs on the CPU, so
`--force-gpu` could still encode on the CPU. Mark the CUDA EP
`error_on_failure()` when the GPU is forced, and turn the CUDA-init panic branch
into a hard error under force-gpu instead of returning a CPU builder.

Verified on a CUDA-13 H100 host: `--force-gpu` indexes on CUDA, and hard-errors
(no CPU fallback) when the GPU is hidden.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Lockfile: fastkmeans-rs 1.0.7

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Raphael Sourty <raphael.sourty@lighton.ai>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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