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): give the CTK-root canary probe its own module - #3621
The probe that finds the CUDA Toolkit root lived inside the library loader, but header and binary discovery use it too. Headers imported a private function from the loader to get at it, and binaries imported the loader lazily.
The probe now lives in _dynamic_libs/canary_probe.py. The code is moved byte for byte. The loader, headers and binaries all import resolve_ctk_root_via_canary from there, and the header step calls it instead of repeating its two lines. load_nvidia_dynamic_lib.py is left with loading only (330 -> 246 lines since the start of the stack).
Tests: patches and imports of the probe point at the new module. The three private names that moved are not re-exported, so a patch aimed at their old location fails loudly instead of silently doing nothing. One name is different: resolve_ctk_root_via_canary is still reachable on load_nvidia_dynamic_lib, because the loader imports and calls it. A patch there succeeds but affects only the loader, not headers or binaries.
No behavior change. 1294 passed, 6 skipped, and the comparisons against main are still byte-identical, including simulated Windows.
Testing
Full cuda_pathfinder test suite at this commit: 1294 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, now in canary_probe.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 c4ecbb2 and 75d1050.
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
Improvements
CUDA Toolkit root detection uses the resolved location of a canary library across library, header, and binary discovery.
Detection runs in a separate process with a 10-second timeout. Unsuccessful probes are handled without disrupting existing fallback behavior.
Header discovery continues to respect CUDA_HOME priority and treats missing results as non-fatal.
Documentation
Updated package architecture documentation to describe the CUDA Toolkit discovery flow.
The canary subprocess lookup and CTK-root resolver now live in canary_probe.py. Binary and header discovery use the resolver. The dynamic-library module imports it, and tests and architecture documentation reference the canary-probe module.
Changes: CTK canary discovery
Layer / File(s)
Summary
Implement the canary probe cuda_pathfinder/cuda/pathfinder/_dynamic_libs/canary_probe.py, cuda_pathfinder/tests/test_ctk_root_discovery.py
The cached subprocess lookup handles timeouts and child-process failures. It parses successful output and returns a resolved path when the payload status is STATUS_OK. The resolver derives the CTK root from that path. Probe tests now target the new module.
Use the shared resolver in discovery cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py, cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py, cuda_pathfinder/cuda/pathfinder/_headers/find_nvidia_headers.py, cuda_pathfinder/tests/*, cuda_pathfinder/AGENTS.md
Binary and header discovery use the resolver from canary_probe. The dynamic-library module removes its local subprocess implementation. Related tests and architecture documentation reference the canary-probe module.
Suggested reviewers:aryanputta
Change: Refactor
Merge Risk: Minimal · previous review db480
This is a behavior-preserving refactor that moves the CUDA Toolkit root probe into its own module. No defects were identified, and it is low risk to merge.
Architecture risk: Low · up to db480
CTK-root canary resolution is now owned by a dedicated module, allowing binary and header discovery to depend on that resolver instead of embedding or importing the canary workflow through the dynamic-library loader.
Changed areas:cuda_pathfinder
Review details
Systems and components
observed — 9 changed files mapped to cuda_pathfinder.
- [ ] 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; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
The PR description says this lets the binaries module drop the lazy import, but the import is still inside the function body. It only changed which module it points at.
canary_probe imports only search_steps, subprocess_protocol and the stdlib, and only cuda/pathfinder/__init__.py imports _binaries, so there is no cycle left to avoid. Could you move it to module level and keep the _resolve_ctk_root_via_canary wrapper? The tests that patch the wrapper are unaffected. I tried it on this head: fresh imports are clean and the Linux suite gives 1301 passed, 6 skipped.
The reason will be displayed to describe this comment to others. Learn more.
Done in db48030. The import is at module level now and the _resolve_ctk_root_via_canary wrapper is unchanged. I kept the typed local in the wrapper, because mypy-pathfinder reports no-any-return without it. Linux suite: 1301 passed, 6 skipped.
@juenglin the lazy import is fixed in db48030. Could you take another look? This PR is still marked "changes requested", and it blocks the rest of the stack above it.
The probe that finds the CUDA Toolkit root lived inside the library
loader, but header and binary discovery use it too. Headers imported a
private function from the loader to get at it, and binaries imported
the loader lazily.
The probe now lives in `_dynamic_libs/canary_probe.py`. The code is
moved byte for byte. The loader, headers and binaries all import
`resolve_ctk_root_via_canary` from there, and the header step calls it
instead of repeating its two lines. `load_nvidia_dynamic_lib.py` is
left with loading only (330 -> 246 lines since the start of the stack).
Tests: patches and imports of the probe point at the new module. The
old names are not re-exported, so a patch aimed at the old location
fails loudly instead of silently doing nothing.
No behavior change. 1293 passed, 6 skipped, and the comparisons against
`main` are still byte-identical, including simulated Windows.
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 16 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.The probe that finds the CUDA Toolkit root lived inside the library loader, but header and binary discovery use it too. Headers imported a private function from the loader to get at it, and binaries imported the loader lazily.
The probe now lives in
_dynamic_libs/canary_probe.py. The code is moved byte for byte. The loader, headers and binaries all importresolve_ctk_root_via_canaryfrom there, and the header step calls it instead of repeating its two lines.load_nvidia_dynamic_lib.pyis left with loading only (330 -> 246 lines since the start of the stack).Tests: patches and imports of the probe point at the new module. The three private names that moved are not re-exported, so a patch aimed at their old location fails loudly instead of silently doing nothing. One name is different:
resolve_ctk_root_via_canaryis still reachable onload_nvidia_dynamic_lib, because the loader imports and calls it. A patch there succeeds but affects only the loader, not headers or binaries.No behavior change. 1294 passed, 6 skipped, and the comparisons against
mainare still byte-identical, including simulated Windows.Testing
cuda_pathfindertest suite at this commit: 1294 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, now incanary_probe.pyChecklist
🤖 Generated with Claude Code