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
refactor(pathfinder): static and bitcode finders share one search - #3608
find_static_lib.py was written as a copy of find_bitcode_lib.py (#1690). Each had its own finder class, its own copy of the three search steps, and its own error formatter, and later changes had to be made twice (#2493, #2708, #3418).
Both now call locate_file() in the new _static_libs/locate_file.py: site-packages, then $CONDA_PREFIX, then $CUDA_PATH. It returns the hit. On a miss it raises the caller's own documented error: each public function passes its error class. The two finder classes and their scratch lists are gone (379 -> 275 lines in _static_libs/).
An unreachable fallback message ("No search paths available") is dropped: the last search step always reported a reason.
Tests: the 15 monkeypatch.setattr(..., "find_sub_dirs_all_sitepackages") calls now patch locate_file, where that lookup lives. Nothing else changes.
No behavior change. Checked beyond the test suite: 831 scenarios (every supported name; Linux, Windows x64, Windows arm64; file in each search location or nowhere; CONDA_PREFIX set, unset, empty; CUDA_PATH, CUDA_HOME, unset, missing directory, relative path) give the same result, error type and error text as main, byte for byte.
Also in this PR: describe the shared static/bitcode search accurately.
The not-found message describes the first CUDA_PATH directory tried, not the last place searched; its docstring now says so. AGENTS.md names _static_libs/locate_file.py as the search both finders share.
Also in this PR: build the not-found error from the root that was searched.
A first version read get_cuda_path_or_home() twice: once to search and once to write the error. The original finders read it once. If two threads looked up at the same time on a cold cache while CUDA_HOME changed, the error could name a directory that was never searched. CodeRabbit found this.
locate_file now raises the finder's error itself, from the root it read. The message text is unchanged. A new test fails on the two-read version and passes now, and the 831 scenarios are still byte-identical to main.
Testing
Full cuda_pathfinder test suite at this commit: 1651 passed, 6 skipped (Linux, Python 3.14).
pre-commit clean, including mypy-pathfinder.
Not run on Windows. Windows rules are exercised by tests that simulate Windows on Linux.
PLC Local Security Evidence (Advisory)
Local advisory checks only, run over the whole stack. Not release-gate results.
Check
Status
Tool
Details
Secrets
SKIP
Pulse Secret Scanner
scanner image not available locally (registry login); the repo trufflehog pre-commit hook passed
SAST
WARN
Semgrep
1 finding, not from this stack: the existing subprocess.run call in the canary probe in load_nvidia_dynamic_lib.py
Dependencies
WARN
pip-audit / osv-scanner
no manifest or lockfile in scope, so the local scan could not run; this stack changes no dependencies
Reviewing files that changed from the base of the PR and between db618f7 and 358af9b.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Static and bitcode library discovery now use a consistent search order across package directories, Conda environments, and CUDA Toolkit paths, including Windows Conda installations.
When a library is not found, the error identifies the first CUDA directory searched or indicates that CUDA_HOME/CUDA_PATH is unset.
Static and bitcode library lookup now uses a shared helper to search site-packages, Conda, and CUDA Toolkit locations. The helper returns the resolved path and source label, or raises the caller’s configured error with a not-found diagnostic.
Changes: CUDA library lookup
Layer / File(s)
Summary
Shared search and diagnostics cuda_pathfinder/cuda/pathfinder/_static_libs/locate_file.py, cuda_pathfinder/AGENTS.md
Adds ordered file lookup and shared not-found diagnostics. The architecture documentation identifies the helper and its callers.
Static and bitcode lookup integration cuda_pathfinder/cuda/pathfinder/_static_libs/find_static_lib.py, cuda_pathfinder/cuda/pathfinder/_static_libs/find_bitcode_lib.py, cuda_pathfinder/tests/test_find_static_lib.py, cuda_pathfinder/tests/test_find_bitcode_lib.py
Both lookup functions delegate searches to the shared helper. Tests patch site-packages discovery through the helper module. A bitcode test checks that the error reports the CUDA root used for the search.
Possibly related PRs
NVIDIA/cuda-python#3418: Both PRs change static and bitcode lookup path resolution and CUDA root handling.
Suggested reviewers:abhilash1910, cpcloud
Change: Refactor
Merge Risk: Minimal · previous review db618
This refactor merges the static and bitcode library lookups into one shared search without changing behavior. Not-found errors now name the CUDA root that was actually searched, and a test covers this. No merge-blocking risk remains.
Security architecture risk: Minimal · up to db618
The refactor preserves where both finders look, which file they select, and how they report a miss. It does not give callers access to new search locations.
- [ ] 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; 0 remain after this review.
suggestion: Report the CUDA Toolkit root that locate_file searched.
When two lookups overlap on a cold get_cuda_path_or_home() cache, a CUDA_HOME change between their reads can replace the cached root. locate_file probes the root it read. not_found_message then reads the cache again. On a miss, the error can name a directory the lookup never searched, and it can list a file that exists there. The exception type stays the same. The base revision formatted the error from the root it searched.
The trigger is narrow. It needs overlapping cold-cache lookups and an environment change during them. A single-threaded change does not trigger it, because locate_file fills the cache before not_found_message runs.
Have locate_file return the searched root or the formatted diagnostic in its miss result. Use that value in each finder that raises a not-found error. Keep the early return on a hit. This also removes the second get_cuda_path_or_home() read on the miss path.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 3 remain after this review.
`find_static_lib.py` was written as a copy of `find_bitcode_lib.py`
(#1690). Each had its own finder class, its own copy of the three
search steps, and its own error formatter, and later changes had to be
made twice (#2493, #2708, #3418).
Both now call `locate_file()` in the new `_static_libs/locate_file.py`:
site-packages, then `$CONDA_PREFIX`, then `$CUDA_PATH`. It returns the
hit or `None`, and each public function raises its own documented
error. The two finder classes and their scratch lists are gone
(379 -> 275 lines in `_static_libs/`).
An unreachable fallback message ("No search paths available") is
dropped: the last search step always reported a reason.
Tests: the 15 `monkeypatch.setattr(..., "find_sub_dirs_all_sitepackages")`
calls now patch `locate_file`, where that lookup lives. Nothing else
changes.
No behavior change. Checked beyond the test suite: 831 scenarios (every
supported name; Linux, Windows x64, Windows arm64; file in each search
location or nowhere; `CONDA_PREFIX` set, unset, empty; `CUDA_PATH`,
`CUDA_HOME`, unset, missing directory, relative path) give the same
result, error type and error text as `main`, byte for byte.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.com>
`not_found_message` describes the first `CUDA_PATH` directory tried,
not the last place searched; its docstring now says so. `AGENTS.md`
names `_static_libs/locate_file.py` as the search both finders share.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.com>
…d errors
`locate_file` read `get_cuda_path_or_home()` to search, and
`not_found_message` read it a second time to write the error. The
original finders read it once. If two threads looked up at the same
time on a cold cache while `CUDA_HOME` changed, the error could name a
directory that was never searched. A review bot found this.
`locate_file` now raises the finder's own error itself, from the root
it read. The callers pass their error class and lose their `if found is
None` branch. The message text is unchanged.
A new test fails on the old code and passes now. The static and bitcode
comparison against the original code is still byte-identical (831
scenarios).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.com>
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
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.
— codex on behalf of Ralf —
Description
Part 8 of 23 of a readability stack for
cuda.pathfinder(stack: #3623 → #3602 → #3603 → #3604 → #3605 → #3606 → #3607 → #3608 → #3609 → #3610 → #3611 → #3613 → #3618 → #3619 → #3620 → #3621 → #3622 → #3627 → #3628 → #3629 → #3630 → #3631 → #3632). No behavior change.find_static_lib.pywas written as a copy offind_bitcode_lib.py(#1690). Each had its own finder class, its own copy of the three search steps, and its own error formatter, and later changes had to be made twice (#2493, #2708, #3418).Both now call
locate_file()in the new_static_libs/locate_file.py: site-packages, then$CONDA_PREFIX, then$CUDA_PATH. It returns the hit. On a miss it raises the caller's own documented error: each public function passes its error class. The two finder classes and their scratch lists are gone (379 -> 275 lines in_static_libs/).An unreachable fallback message ("No search paths available") is dropped: the last search step always reported a reason.
Tests: the 15
monkeypatch.setattr(..., "find_sub_dirs_all_sitepackages")calls now patchlocate_file, where that lookup lives. Nothing else changes.No behavior change. Checked beyond the test suite: 831 scenarios (every supported name; Linux, Windows x64, Windows arm64; file in each search location or nowhere;
CONDA_PREFIXset, unset, empty;CUDA_PATH,CUDA_HOME, unset, missing directory, relative path) give the same result, error type and error text asmain, byte for byte.Also in this PR: describe the shared static/bitcode search accurately.
The not-found message describes the first
CUDA_PATHdirectory tried, not the last place searched; its docstring now says so.AGENTS.mdnames_static_libs/locate_file.pyas the search both finders share.Also in this PR: build the not-found error from the root that was searched.
A first version read
get_cuda_path_or_home()twice: once to search and once to write the error. The original finders read it once. If two threads looked up at the same time on a cold cache whileCUDA_HOMEchanged, the error could name a directory that was never searched. CodeRabbit found this.locate_filenow raises the finder's error itself, from the root it read. The message text is unchanged. A new test fails on the two-read version and passes now, and the 831 scenarios are still byte-identical tomain.Testing
cuda_pathfindertest suite at this commit: 1651 passed, 6 skipped (Linux, Python 3.14).mypy-pathfinder.PLC Local Security Evidence (Advisory)
Local advisory checks only, run over the whole stack. Not release-gate results.
subprocess.runcall in the canary probe inload_nvidia_dynamic_lib.pyChecklist
🤖 Generated with Claude Code