Skip to content

refactor(pathfinder): unify header search architecture with library loading pattern#1738

Open
cpcloud wants to merge 1 commit intoNVIDIA:mainfrom
cpcloud:header-finding-refactor
Open

refactor(pathfinder): unify header search architecture with library loading pattern#1738
cpcloud wants to merge 1 commit intoNVIDIA:mainfrom
cpcloud:header-finding-refactor

Conversation

@cpcloud
Copy link
Contributor

@cpcloud cpcloud commented Mar 7, 2026

Summary

  • Introduces a HeaderDescriptorSpec descriptor catalog for headers, mirroring the DescriptorSpec catalog pattern already used for dynamic library loading. All per-header metadata (basename, site-packages dirs, anchor layout, platform availability, system install dirs) is now authored once in a single catalog tuple, rather than spread across several manually maintained dicts.
  • supported_nvidia_headers.py now derives its legacy table exports from the catalog (same approach as supported_nvidia_libs.py), and find_nvidia_headers.py operates on descriptors directly — eliminating the name-based if libname == "nvvm" / if libname == "cccl" branching in favor of descriptor fields (anchor_include_rel_dirs, include_subdirs, include_subdirs_windows).
  • Public API (LocatedHeaderDir, find_nvidia_header_directory, locate_nvidia_header_directory, SUPPORTED_HEADERS_CTK) is unchanged.

Intentional behavioral note: The old code raised RuntimeError when calling locate_nvidia_header_directory with a header name not available on the current platform (e.g., "cufile" on Windows). The new code returns None instead, since the descriptor exists but the search simply finds nothing. This is more consistent with how callers handle "not found" and mirrors the library side's distinction between unknown vs. unavailable.

Test plan

  • All existing header tests pass (test_find_nvidia_headers.py)
  • All descriptor catalog tests pass (test_descriptor_catalog.py)
  • Full test suite passes (882 passed, 1 skipped)
  • Verified all derived legacy tables produce identical values to the old hardcoded dicts

Made with Cursor

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Mar 7, 2026

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.

@cpcloud cpcloud force-pushed the header-finding-refactor branch from a65ef88 to 3c96fcc Compare March 7, 2026 00:40
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Mar 7, 2026

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

Contributors can view more details about this message here.

@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 7, 2026

/ok to test

@cpcloud cpcloud force-pushed the header-finding-refactor branch from 3c96fcc to 550bd47 Compare March 7, 2026 01:33
@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 7, 2026

/ok to test

@cpcloud cpcloud force-pushed the header-finding-refactor branch from 550bd47 to 643fec9 Compare March 7, 2026 01:56
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Mirror the dynamic-library descriptor-catalog pattern for headers.
All per-header metadata (basename, site-packages dirs, anchor layout,
platform availability, system install dirs) is now authored once in
HeaderDescriptorSpec entries in header_descriptor_catalog.py.

- header_descriptor_catalog.py: authored catalog with HeaderDescriptorSpec;
  each entry declares its own search capabilities via fields like
  use_ctk_root_canary, conda_targets_layout, and system_install_dirs
- header_descriptor.py: name-keyed HEADER_DESCRIPTORS registry and
  platform-dispatch helpers (platform_include_subdirs, resolve_conda_anchor)
- supported_nvidia_headers.py: derives legacy tables from the catalog
- find_nvidia_headers.py: composable HeaderFindStep functions with a single
  unified FIND_STEPS sequence and run_find_steps cascade runner; each step
  self-gates based on descriptor fields; search code is platform-agnostic

Public API (LocatedHeaderDir, find_nvidia_header_directory,
locate_nvidia_header_directory, SUPPORTED_HEADERS_CTK) is unchanged.

Made-with: Cursor
@cpcloud cpcloud force-pushed the header-finding-refactor branch from 643fec9 to b26cf85 Compare March 7, 2026 02:04
@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 7, 2026

/ok to test

3. **CUDA Toolkit environment variables** — ``CUDA_HOME`` / ``CUDA_PATH``.
4. **CTK root canary probe** — subprocess canary (descriptors with
``use_ctk_root_canary=True`` only).
5. **System install directories** — glob patterns from the descriptor.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: This seems like an extra thing that did not exist before (also find_nvidia_header_directory does not have)?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants