Repository navigation
fix(cuda): fall back to CUBIN when the driver rejects JIT'd PTX - #10
Merged
Merged
Conversation
The CUDA k-means kernels are JIT-compiled to PTX and assembled by the driver. When the NVRTC toolkit is newer than the installed driver (e.g. a CUDA 13.1 toolkit on a CUDA 13.0 driver), the driver rejects the PTX with CUDA_ERROR_UNSUPPORTED_PTX_VERSION and the GPU k-means path fails. Try the PTX path first; only on failure recompile the kernels to a device-specific CUBIN (SASS) via nvrtcGetCUBIN and load it directly, skipping the driver's PTX JIT. CUDA-only and strictly additive: the fallback runs only when the PTX load fails, so hosts where the GPU already works are unchanged.
raphaelsty
force-pushed
the
fix/cuda-cubin-fallback
branch
from
June 29, 2026 15:13
c7399f9 to
1979ea5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The CUDA k-means kernels are JIT-compiled to PTX and assembled by the driver. When the NVRTC toolkit is newer than the installed driver (e.g. a CUDA 13.1 toolkit on a CUDA 13.0 driver), the driver rejects the PTX with
CUDA_ERROR_UNSUPPORTED_PTX_VERSIONand the GPU k-means path dies (caller then falls back to CPU). This forces users into manual workarounds (hand-placing a driver-matched NVRTC onLD_LIBRARY_PATH).Fix
Try the PTX path first (unchanged); only on failure, recompile the same kernels to a device-specific CUBIN (SASS) via
nvrtcGetCUBINand load it withcuModuleLoadData, which skips the driver's PTX->SASS JIT entirely. No version match needed, noLD_LIBRARY_PATHjuggling.Safety / backward-compat
cuda.rs; non-CUDA builds are unaffected.--features cudaand--features cuda-13.Validation
On an H100 with a 13.1 toolkit / 13.0 driver, k-means clustering now runs on the GPU via the CUBIN fallback with no NVRTC workaround.
Release
Version bumped to 1.0.8 in this PR. After merge, tag
v1.0.8to trigger thecrates.io publish so downstreams (next-plaid) can depend on the fix.