You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(cuda.bindings): return False from check_nvvm_compiler_options without libNVVM - #3598
This PR changes library behavior so that a test that has never run in CI can pass. When libNVVM cannot be found, cuda.bindings.utils.check_nvvm_compiler_options() now returns False. Before, it raised cuda.pathfinder.DynamicLibNotFoundError.
🧑🔬 Needs a domain expert before merging 🧑🔬
Either the library or the test is wrong, and this PR assumes it is the library. If raising is the intended behavior, keep the library unchanged and rewrite the test to expect DynamicLibNotFoundError. Either way the test now runs in CI; only its expected result differs. The history below supports both answers.
Summary
test_check_nvvm_compiler_options_no_libnvvm skipped whenever libNVVM was present, which is every CI configuration, so it never ran. When run with libNVVM missing, it fails: the function raises instead of returning False.
check_nvvm_compiler_options(options)
import cuda.bindings.nvvm # missing module -> False
- _inspect_function_pointer("__nvvmCreateProgram") # missing libNVVM -> DynamicLibNotFoundError escapes+ try: _inspect_function_pointer("__nvvmCreateProgram")+ except DynamicLibNotFoundError: return False # missing libNVVM -> False
compile a small NVVM IR program with `options`
ERROR_INVALID_OPTION -> False
-> True
The test now simulates a missing libNVVM, so it runs everywhere. NVVM is loaded once per process, so the simulation runs in a fresh interpreter:
-if libNVVM is available: skip # true on every CI runner-assert check_nvvm_compiler_options(["-arch=compute_90"]) is False+in a fresh interpreter:+ replace the libNVVM loader with one that raises DynamicLibNotFoundError+ assert check_nvvm_compiler_options(["-arch=compute_90"]) is False+ assert the replacement loader was called
Other changes:
The test's "not currently run in any CI job" marker is removed.
New paired 13.6.0 release notes: the cuda-bindings note lists this under "Behavior changes". The cuda-python note is a placeholder that the release-note pairing pre-commit check requires.
The CUDA 12 bindings (cuda_bindings_12) have no check_nvvm_compiler_options, so there is no counterpart change.
History: library or test?
Both the function and the test were added in #1837.
For returning False (this PR):
The test, added in the same PR, asserts False when libNVVM is missing.
The test's _is_libnvvm_available() helper catches DynamicLibNotFoundError, following a review suggestion: "The only expected exception is DynamicLibNotFoundError (or subclasses) when libNVVM isn't installed."
The function already returns False when the nvvm module is missing.
For raising (current behavior): during review, the reviewer asked that this call not be guarded: "If that import works, we don't want to guard the _inspect_function_pointer import, or the _inspect_function_pointer() call. If those don't work, that's a bug we want to surface." (discussion_r3019673778). That comment replaced a broad except Exception. This PR catches only DynamicLibNotFoundError, so other loader failures still raise.
Evidence
Run locally on Linux with CUDA 13 bindings:
Before:test_check_nvvm_compiler_options_no_libnvvm FAILED with DynamicLibNotFoundError: simulated: nvvm not found.
After: PASSED. All 38 tests in cuda_bindings_13/tests/test_utils.py pass, including the libNVVM-present tests (valid, invalid, empty, multiple_valid, arch_detection).
On Windows the NVVM loader calls the same replaceable load_nvidia_dynamic_lib, so the test should run there too. That is not run locally.
Confirming it runs in CI: in this PR's CI run, every CUDA 13 bindings test job should report test_check_nvvm_compiler_options_no_libnvvm PASSED, where main reports it SKIPPED. For example:
gh run view <CI run id> --repo NVIDIA/cuda-python --log | grep -F "test_check_nvvm_compiler_options_no_libnvvm"
Merge Danger
Door: two-way. A one-line change in the function's exception handling, plus the test.
Blast Radius: callers of check_nvvm_compiler_options() on systems without libNVVM. Code that caught DynamicLibNotFoundError from this function now gets False instead. Callers that treat False as "option unsupported" now get that answer, where before they had to handle an exception.
In this repository, only cuda_core/tests/test_program.py calls it, in skipif conditions. Without libNVVM, those cases now skip instead of erroring during collection.
The function was abstracted from numba-cuda (its docstring cites numba-cuda PR 681), so numba-cuda is the main external caller to check.
Reviewers: please feel free to push commits directly to this PR to improve it.
…hout libNVVM
check_nvvm_compiler_options() raised DynamicLibNotFoundError when libNVVM
could not be found, but test_check_nvvm_compiler_options_no_libnvvm
expected False. The test skipped whenever libNVVM was present, so it never
ran in CI and the mismatch went unnoticed.
Catch DynamicLibNotFoundError around the libNVVM lookup and return False.
Rewrite the test to simulate a missing libNVVM in a fresh interpreter, so
it runs in every configuration. Add paired cuda-bindings and cuda-python
13.6.0 release notes recording the behavior change.
ClosesNVIDIA#3565.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checking NVVM compiler options now returns False when the NVVM compiler library is unavailable, instead of raising an error.
Documentation
Updated release notes with the NVVM behavior change and guidance for resolving a possible upgrade issue when installing CUDA Python over version 12.6.2.post1 or earlier.
check_nvvm_compiler_options now returns False when libNVVM cannot be found. A subprocess test simulates that condition. The release notes describe the change and CUDA Python 13.6.0.
Changes: NVVM availability fallback
Layer / File(s)
Summary
Missing-library fallback and release coverage cuda_bindings_13/cuda/bindings/utils/_nvvm_utils.py, cuda_bindings_13/tests/test_utils.py, cuda_bindings_13/docs/source/release/13.6.0-notes.rst, cuda_python/docs/source/release/13.6.0-notes.rst
The compiler-option check returns False when the NVVM function-pointer lookup raises DynamicLibNotFoundError. A subprocess test simulates the missing library and checks the result and load attempt. The release notes describe the change and CUDA Python 13.6.0.
Assessment against linked issues
Objective
Addressed
Explanation
#3565: Return False instead of raising DynamicLibNotFoundError when libNVVM is missing, and test the behavior in a subprocess.
✅
Suggested reviewers:abhilash1910, rwgk
Change: Bug fix
Merge Risk: Low · up to bbe68
When libNVVM is missing, check_nvvm_compiler_options now returns False instead of raising. The public API reference does not yet list the function, so the new return value is not documented there. Add the entry before or shortly after merging.
Security architecture risk: Minimal · up to bbe68
This is a compatibility change, not a change to which libraries or compiler operations callers can access. Code that caught the missing-library exception will now receive False from the check.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The direct exposure is to processes calling the existing option check. The changed branch reports a negative result without creating a compiler program; it adds no entrypoint or route to native compilation. External callers' handling of False was not verified.
Trust Boundaries and Controls
observed — The native loader still receives the fixed library name nvvm. Caller-provided options are passed to compilation only after the existing pointer check succeeds and a program is created; the new catch does not bypass those steps.
Resilience and Maintainability Implications
inferred — A failed load still exits the existing initialization lock without setting the completion flag or publishing the pointer map. Linux can write some slots before the failure, but a later attempt still runs initialization rather than treating those slots as a completed table. The new catch changes what the caller sees, not what a retry sees.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 8 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Maintainability & Code Quality · Quick win
Add check_nvvm_compiler_options to the utils module reference.
docs/source/module/utils.rst autosummary omits check_nvvm_compiler_options, even though cuda.bindings.utils exports it. Its return contract changes in this PR, so the module reference should list it. This keeps the new False return documented where users look for the API.
Preview will be ready when the GitHub Pages deployment is complete.
This branch has not been deployed
No deployments
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
bugSomething isn't workingcuda.bindingsEverything related to the cuda.bindings moduletestImprovements or additions to tests
1 participant
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.
Closes #3565. Part of #2077.
Warning
This PR changes library behavior so that a test that has never run in CI can pass. When libNVVM cannot be found,
cuda.bindings.utils.check_nvvm_compiler_options()now returnsFalse. Before, it raisedcuda.pathfinder.DynamicLibNotFoundError.🧑🔬 Needs a domain expert before merging 🧑🔬
Either the library or the test is wrong, and this PR assumes it is the library. If raising is the intended behavior, keep the library unchanged and rewrite the test to expect
DynamicLibNotFoundError. Either way the test now runs in CI; only its expected result differs. The history below supports both answers.Summary
test_check_nvvm_compiler_options_no_libnvvmskipped whenever libNVVM was present, which is every CI configuration, so it never ran. When run with libNVVM missing, it fails: the function raises instead of returningFalse.The test now simulates a missing libNVVM, so it runs everywhere. NVVM is loaded once per process, so the simulation runs in a fresh interpreter:
Other changes:
cuda-bindingsnote lists this under "Behavior changes". Thecuda-pythonnote is a placeholder that the release-note pairing pre-commit check requires.cuda_bindings_12) have nocheck_nvvm_compiler_options, so there is no counterpart change.History: library or test?
Both the function and the test were added in #1837.
False(this PR):Falsewhen libNVVM is missing._is_libnvvm_available()helper catchesDynamicLibNotFoundError, following a review suggestion: "The only expected exception isDynamicLibNotFoundError(or subclasses) when libNVVM isn't installed."Falsewhen thenvvmmodule is missing._inspect_function_pointerimport, or the_inspect_function_pointer()call. If those don't work, that's a bug we want to surface." (discussion_r3019673778). That comment replaced a broadexcept Exception. This PR catches onlyDynamicLibNotFoundError, so other loader failures still raise.Evidence
Run locally on Linux with CUDA 13 bindings:
test_check_nvvm_compiler_options_no_libnvvmFAILED withDynamicLibNotFoundError: simulated: nvvm not found.cuda_bindings_13/tests/test_utils.pypass, including the libNVVM-present tests (valid,invalid,empty,multiple_valid,arch_detection).On Windows the NVVM loader calls the same replaceable
load_nvidia_dynamic_lib, so the test should run there too. That is not run locally.Confirming it runs in CI: in this PR's CI run, every CUDA 13 bindings test job should report
test_check_nvvm_compiler_options_no_libnvvm PASSED, wheremainreports it SKIPPED. For example:Merge Danger
Door: two-way. A one-line change in the function's exception handling, plus the test.
Blast Radius: callers of
check_nvvm_compiler_options()on systems without libNVVM. Code that caughtDynamicLibNotFoundErrorfrom this function now getsFalseinstead. Callers that treatFalseas "option unsupported" now get that answer, where before they had to handle an exception.cuda_core/tests/test_program.pycalls it, inskipifconditions. Without libNVVM, those cases now skip instead of erroring during collection.Reviewers: please feel free to push commits directly to this PR to improve it.
🤖 Generated with Claude Code