Commit 6121573
refactor(pathfinder): descriptor-driven library discovery and loading (NVIDIA#1685)
* refactor(pathfinder): introduce LibDescriptor and registry
Add a per-library descriptor dataclass that consolidates all metadata
(sonames, DLLs, site-packages paths, dependencies, loader flags) into
a single frozen object. The registry is built at import time from the
existing data tables -- zero behavioral change.
291 parametrized tests verify the registry is a faithful representation
of the source dicts.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): extract composable search steps
Introduce SearchContext and FindStep to replace the monolithic finder class.
Each search mechanism (site-packages, conda, CUDA_HOME) becomes a standalone
step with a uniform (SearchContext) -> FindResult | None signature.
Keep already-loaded handling and dependency loading as orchestration concerns.
Delete the old find_nvidia_dynamic_lib module after migrating its logic.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): make anchor-point dirs descriptor-driven
Add per-platform anchor-relative directory lists to LibDescriptor and use them
for CUDA_HOME/conda anchor resolution.
This removes special-case branching (e.g. nvvm) from the anchor-point search.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): thread LibDescriptor through loader layer
Update the platform-specific loader code to consume LibDescriptor directly
instead of consulting supported_nvidia_libs tables at runtime.
This makes the loading path data-driven (desc.linux_sonames/windows_dlls,
desc.requires_* flags, desc.dependencies).
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): add and simplify PlatformLoader seam
Introduce the platform loader boundary for dlopen calls and fold the immediate wrapper cleanup into the same change so loader dispatch stays straightforward while preserving behavior.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): add SearchPlatform seam for search steps
Introduce search_platform.py, exporting a single PLATFORM instance that
implements the per-OS filesystem search behavior.
search_steps routes all platform differences through SearchContext.platform,
removing OS branching from the search step implementations.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): inline SearchPlatform lib-dir lookup helpers
Inline single-use lib-dir lookup helpers into the platform implementations to
reduce helper surface area while keeping shared rel-dir scanning helpers.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): remove unused LibDescriptor properties
Drop the platform-dispatch convenience properties that became unused after
introducing PlatformLoader/SearchPlatform.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): add authored descriptor catalog and parity tests
Add a canonical descriptor catalog module that contains one DescriptorSpec per
supported dynamic library.
Add exhaustive parity tests asserting the catalog matches the current
LIB_DESCRIPTORS registry field-for-field before runtime wiring is flipped.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): build LIB_DESCRIPTORS from authored catalog
Switch lib_descriptor.py from "assemble-from-supported tables" to
"registry-from-authored catalog".
Keep backward-compatible names (`LibDescriptor`, `Strategy`, and
`LIB_DESCRIPTORS`) while making descriptor_catalog the canonical source.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): derive legacy tables from descriptor catalog
Replace the hand-authored supported_nvidia_libs tables with compatibility
constants derived from DESCRIPTOR_CATALOG while preserving historical export
names and behaviors.
This makes descriptor data the single authored source and keeps
supported_nvidia_libs as a derived-views shim for existing imports.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(pathfinder): tighten refactor follow-ups across search and tests
Consolidate post-refactor fixes for driver-lib test alignment, platform search-path edge cases, and typing/import cleanup so behavior and diagnostics remain stable.
Co-authored-by: Cursor <cursoragent@cursor.com>
* test(pathfinder): rewrite tautological catalog tests as structural invariants
The previous tests compared catalog entries against LIB_DESCRIPTORS,
which is built directly from the same catalog -- always passing by
construction. Replace with parametrized checks that verify real
properties: name uniqueness, valid identifiers, strategy values,
dependency graph integrity, soname/dll format, and driver lib
constraints.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(pathfinder): trim descriptor catalog defaults and import layout
Simplify catalog entries by relying on DescriptorSpec defaults and fold companion import-order cleanup into the same readability-focused change.
EOF && git cherry-pick -n 5d5547f a804f26c4 && git commit --trailer "Co-authored-by: Cursor <cursoragent@cursor.com>" -F - <<'EOF'
refactor(pathfinder): split add-nv-library core flow from optional UI
Keep add-nv-library lightweight by default with prompt/CLI-first behavior while moving Textual chrome behind explicit UI tasks and lockfile feature splits.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(pathfinder): restore descriptor-driven CTK canary fallback
Reinstate CTK-root canary discovery in the refactored loader path and define canary eligibility/anchors on per-library descriptors so fallback policy lives with the rest of library metadata.
Co-authored-by: Cursor <cursoragent@cursor.com>
* style(pathfinder): fix pre-commit formatting and mypy return type
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(toolshed): add shared catalog writer for descriptor_catalog.py
Provides helpers to import, update, and rewrite the descriptor catalog
file in place. Each toolshed extraction script can merge its findings
(sonames, DLLs, site-packages paths) into the authored catalog without
touching fields it doesn't own.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(toolshed): update extraction scripts to write descriptor_catalog.py in place
Replace print-to-stdout workflow (manual copy-paste) with direct
in-place catalog updates via the shared _catalog_writer module.
- build_pathfinder_sonames.py: scans directories for .so files and
extracts SONAMEs via readelf (replaces find_sonames.sh pipeline)
- build_pathfinder_dlls.py: parses 7z listings, updates windows_dlls
- make_site_packages_libdirs.py: parses collected paths, updates
site_packages_linux or site_packages_windows
All three scripts now derive the set of known library names from the
catalog itself, eliminating the duplicated LIBNAMES_IN_SCOPE constant.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(toolshed): add unified update_catalog.py entry point
Platform-aware dispatcher: runs sonames extraction on Linux, DLL
listing parsing on Windows. Single command to update descriptor_catalog.py
from CTK installations.
Made-with: Cursor
* fix(pathfinder): use platform descriptor fields for supported libnames
Prevent import-time failures after the descriptor-catalog refactor by deriving availability from linux/windows descriptor fields instead of removed helpers. Remove an unused catalog-writer variable so pre-commit remains green.
Made-with: Cursor
* refactor(pathfinder): rename descriptor strategy to packaged_with
Use a more descriptive field name for library classification so descriptor semantics are explicit in runtime and toolshed code paths. This aligns terminology with review feedback while preserving behavior and compatibility.
Made-with: Cursor
* refactor(pathfinder): drop unused Strategy alias
Remove the `Strategy = PackagedWith` alias from the descriptor catalog and related re-exports to avoid confusing, unused terminology.
Made-with: Cursor
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>1 parent bcba37c commit 6121573
23 files changed
Lines changed: 2147 additions & 1084 deletions
File tree
- cuda_pathfinder
- cuda/pathfinder/_dynamic_libs
- tests
- toolshed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
Lines changed: 6 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 9 | + | |
14 | 10 | | |
15 | 11 | | |
16 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
17 | 16 | | |
18 | | - | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
0 commit comments