Skip to content

refactor(pathfinder): give the CTK-root canary probe its own module - #3621

Open
rparolin wants to merge 3 commits into
pathfinder-readability/14-one-binaries-resolverfrom
pathfinder-readability/15-canary-probe-module
Open

rparolin wants to merge 3 commits into
pathfinder-readability/14-one-binaries-resolverfrom
pathfinder-readability/15-canary-probe-module

Conversation

@rparolin

@rparolin rparolin commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

— 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 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
License N/A - no dependencies changed
Container N/A - no container changed

Checklist

  • I have read the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rparolin
rparolin added this pull request to stack #3616 November 25, 2026 23:20
@github-actions github-actions Bot added the cuda.pathfinder Everything related to the cuda.pathfinder module label Nov 25, 2026
@rparolin rparolin added the enhancement Any code-related improvements label Nov 25, 2026
@rparolin rparolin added this to the cuda.pathfinder next milestone Nov 25, 2026
@rparolin rparolin self-assigned this Nov 25, 2026
@rparolin
rparolin requested review from juenglin and rwgk November 25, 2026 23:21
@rparolin
rparolin marked this pull request as ready for review November 26, 2026 15:54
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

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, handles timeouts and unsuccessful results, and preserves existing fallback behavior.
  • 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 that resolver, while the dynamic-library module imports it. 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.

Change: Refactor

Merge Risk: Minimal · up to 6e8a9

This is a refactor that moves the CUDA Toolkit canary probe into its own module with no intended behavior change. Callers and tests have been updated to use it. No merge-blocking risk was identified.

Security architecture risk: Minimal · up to 6e8a9

Library, header, and binary discovery still use the same CUDA Toolkit lookup and fallback behavior. The change centralizes the probe without expanding its authority or requiring an operator migration.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ba8472f and 6e8a91a.

Files selected for processing: 1

  • cuda_pathfinder/tests/test_load_nvidia_dynamic_lib_using_mocker.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

rparolin and others added 2 commits November 26, 2026 11:17
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>
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
@rwgk
rwgk removed this pull request from stack #3616 November 26, 2026 19:19
@rwgk
rwgk force-pushed the pathfinder-readability/15-canary-probe-module branch from 1d2ed4e to 6d23349 Compare November 26, 2026 19:19
@copy-pr-bot

copy-pr-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

…athfinder-readability/15-canary-probe-module

# Conflicts:
#	cuda_pathfinder/tests/test_load_nvidia_dynamic_lib_using_mocker.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.pathfinder Everything related to the cuda.pathfinder module enhancement Any code-related improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants