Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
129ddab
refactor(pathfinder): introduce LibDescriptor and registry
cpcloud Feb 11, 2026
1df2d29
refactor(pathfinder): extract composable search steps
cpcloud Feb 11, 2026
7b7f49a
refactor(pathfinder): make anchor-point dirs descriptor-driven
cpcloud Feb 11, 2026
6801dc5
refactor(pathfinder): thread LibDescriptor through loader layer
cpcloud Feb 11, 2026
dc9e95f
refactor(pathfinder): add and simplify PlatformLoader seam
cpcloud Feb 24, 2026
9241ff2
refactor(pathfinder): add SearchPlatform seam for search steps
cpcloud Feb 11, 2026
cd9b4f7
refactor(pathfinder): inline SearchPlatform lib-dir lookup helpers
cpcloud Feb 11, 2026
68a33b7
refactor(pathfinder): remove unused LibDescriptor properties
cpcloud Feb 11, 2026
984afdb
refactor(pathfinder): add authored descriptor catalog and parity tests
cpcloud Feb 12, 2026
8fc585e
refactor(pathfinder): build LIB_DESCRIPTORS from authored catalog
cpcloud Feb 12, 2026
ba56283
refactor(pathfinder): derive legacy tables from descriptor catalog
cpcloud Feb 12, 2026
e7fe076
fix(pathfinder): tighten refactor follow-ups across search and tests
cpcloud Feb 20, 2026
42b1f5a
test(pathfinder): rewrite tautological catalog tests as structural in…
cpcloud Feb 14, 2026
0c0eb71
refactor(pathfinder): trim descriptor catalog defaults and import layout
cpcloud Feb 20, 2026
c7f3077
fix(pathfinder): restore descriptor-driven CTK canary fallback
cpcloud Feb 24, 2026
c989b32
style(pathfinder): fix pre-commit formatting and mypy return type
cpcloud Feb 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# cuda_pathfinder agent instructions

You are working on `cuda_pathfinder`, a Python sub-package of the
[cuda-python](https://github.com/NVIDIA/cuda-python) monorepo. It finds and
loads NVIDIA dynamic libraries (CTK, third-party, and driver) across Linux and
Windows.

## Workspace

The workspace root is `cuda_pathfinder/` inside the monorepo. Use the
`working_directory` parameter on the Shell tool when you need the monorepo root
(one level up).

## Conventions

- **Python**: all source is pure Python (no Cython in this sub-package).
- **Testing**: `pytest` with `pytest-mock` (`mocker` fixture). Use
`spawned_process_runner` for real-loading tests that need process isolation
(dynamic linker state leaks across tests otherwise). Use the
`info_summary_append` fixture to emit `INFO` lines visible in CI/QA logs.
- **STRICTNESS env var**: `CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS`
controls whether missing libs are tolerated (`see_what_works`, default) or
fatal (`all_must_work`).
- **Formatting/linting**: rely on pre-commit (runs automatically on commit). Do
not run formatters manually.
- **Imports**: use `from cuda.pathfinder._dynamic_libs...` for internal imports
in tests; public API is `from cuda.pathfinder import load_nvidia_dynamic_lib`.

## Testing guidelines

- **Real tests over mocks**: mocks are fine for hard-to-reach branches (e.g.
24-bit Python), but every loading path must also have a real-loading test that
runs in a spawned child process. Track results with `INFO` lines so CI logs
show what actually loaded.
- **No real lib names in negative tests**: when parametrizing unsupported /
invalid libnames, use obviously fake names (`"bogus"`, `"not_a_real_lib"`)
to avoid confusion when searching the codebase.
- **`functools.cache` awareness**: `load_nvidia_dynamic_lib` is cached. Tests
that patch internals it depends on must call
`load_nvidia_dynamic_lib.cache_clear()` first, or use a child process for
isolation.

## Key modules

- `cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py` -- main entry
point and dispatch logic (CTK vs driver).
- `cuda/pathfinder/_dynamic_libs/supported_nvidia_libs.py` -- canonical
registry of sonames, DLLs, site-packages paths, and dependencies.
- `cuda/pathfinder/_dynamic_libs/find_nvidia_dynamic_lib.py` -- CTK search
cascade (site-packages, conda, CUDA_HOME).
- `tests/child_load_nvidia_dynamic_lib_helper.py` -- lightweight helper
imported by spawned child processes (avoids re-importing the full test
module).

### Fix all code review findings from lib-descriptor-refactor review

**Request:** Fix all 8 findings from the external code review.

**Actions (in worktree `cuda_pathfinder_refactor`):**
1. `search_steps.py`: Restored `os.path.normpath(dirname)` in
`_find_lib_dir_using_anchor` (regression from pre-refactor fix). Added
`NoReturn` annotation to `raise_not_found`.
2. `search_platform.py`: Guarded `os.listdir(lib_dir)` in
`WindowsSearchPlatform.find_in_lib_dir` with `os.path.isdir` check to
prevent crash on missing directory.
3. `test_descriptor_catalog.py`: Rewrote tautological tests as structural
invariant tests (uniqueness, valid names, strategy values, dep graph,
soname/dll format, driver lib constraints). 237 new parametrized cases.
4. `platform_loader.py`: Eliminated `WindowsLoader`/`LinuxLoader` boilerplate
classes — assign the platform module directly as `LOADER`. Removed stale
`type: ignore`.
5. `descriptor_catalog.py`: Trimmed default-valued fields from all entries,
added `# ---` section comments (CTK / third-party / driver).
6. `load_nvidia_dynamic_lib.py`: Fixed import layout — `TYPE_CHECKING` block
now properly separated after unconditional imports.

All 742 tests pass, all pre-commit hooks green.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

import json

from cuda.pathfinder._dynamic_libs.lib_descriptor import LIB_DESCRIPTORS
from cuda.pathfinder._dynamic_libs.load_dl_common import DynamicLibNotFoundError, LoadedDL
from cuda.pathfinder._utils.platform_aware import IS_WINDOWS

if IS_WINDOWS:
from cuda.pathfinder._dynamic_libs.load_dl_windows import load_with_system_search
else:
from cuda.pathfinder._dynamic_libs.load_dl_linux import load_with_system_search
from cuda.pathfinder._dynamic_libs.platform_loader import LOADER


def _probe_canary_abs_path(libname: str) -> str | None:
desc = LIB_DESCRIPTORS.get(libname)
if desc is None:
raise ValueError(f"Unsupported canary library name: {libname!r}")
try:
loaded: LoadedDL | None = load_with_system_search(libname)
loaded: LoadedDL | None = LOADER.load_with_system_search(desc)
except DynamicLibNotFoundError:
return None
if loaded is None:
Expand Down
Loading