Skip to content

Enable runtime resolution of CUDA header path for NVRTC - #3252

Merged
ptrendx merged 6 commits into
NVIDIA:mainfrom
fheinecke:fred/nvrtc-runtime-header-resolution-1
Aug 11, 2026
Merged

Enable runtime resolution of CUDA header path for NVRTC#3252
ptrendx merged 6 commits into
NVIDIA:mainfrom
fheinecke:fred/nvrtc-runtime-header-resolution-1

Conversation

@fheinecke

Copy link
Copy Markdown
Collaborator

Description

NVRTC relies on having CUDA toolkit headers available at runtime for JIT compilation. The following directories are searched:

  1. ${NVTE_CUDA_INCLUDE_DIR}
  2. ${CUDA_HOME}
  3. ${CUDA_DIR}
  4. The build-time header path
  5. /usr/local/cuda

The build-time path may coincidentally line up with the runtime path, but may be incorrect when building TE on another machine or environment, or when building TE with build isolation enabled. This enables searching site-packages at runtime for the headers, allowing them to be resolved in more environments. If checked paths don't exist, then this will fall back to the existing behavior.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Enable runtime resolution of CUDA toolkit headers in site-packages for NVRTC

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@fheinecke

Copy link
Copy Markdown
Collaborator Author

/te-ci

@fheinecke

Copy link
Copy Markdown
Collaborator Author

Failing test is due to runner scheduling, should be unrelated to this

@fheinecke

Copy link
Copy Markdown
Collaborator Author

/te-ci

@fheinecke
fheinecke marked this pull request as ready for review August 3, 2026 22:03
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds runtime discovery of CUDA headers for NVRTC while retaining the existing configured and build-time fallbacks.

  • Resolves the loaded CUDA runtime major version in Python and C++.
  • Searches version-specific NVIDIA package directories, including the CUDA 12 legacy layout.
  • Supports namespace-package roots and validates that discovered paths contain cuda_runtime.h.
  • Links the common library against the platform dynamic-loader library.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the prior legacy and Python override issues are addressed by runtime-major-aware selection, and discovered paths are validated before use.

Important Files Changed

Filename Overview
transformer_engine/common/util/cuda_runtime.cpp Adds runtime-major-aware CUDA header discovery beside the installed shared library and preserves validated fallback behavior.
transformer_engine/common/init.py Makes the editable-install override runtime-major-aware and supports all NVIDIA namespace-package roots.
transformer_engine/common/CMakeLists.txt Links the common shared library with the platform dynamic-loading libraries required by dladdr.

Reviews (4): Last reviewed commit: "fix linter failure" | Re-trigger Greptile

Comment thread transformer_engine/common/util/cuda_runtime.cpp
Comment thread transformer_engine/common/util/cuda_runtime.cpp
Comment thread transformer_engine/common/util/cuda_runtime.cpp
fheinecke and others added 6 commits August 7, 2026 12:02
Signed-off-by: Fred Heinecke <fheinecke@nvidia.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Signed-off-by: fheinecke <23390735+fheinecke@users.noreply.github.com>
… of site-packages directory

Signed-off-by: Fred Heinecke <fheinecke@nvidia.com>
Signed-off-by: Fred Heinecke <fheinecke@nvidia.com>
Signed-off-by: Fred Heinecke <fheinecke@nvidia.com>
@fheinecke
fheinecke force-pushed the fred/nvrtc-runtime-header-resolution-1 branch from d11bc9e to c443baa Compare August 7, 2026 17:02
@ptrendx

ptrendx commented Aug 11, 2026

Copy link
Copy Markdown
Member

/te-ci

@ptrendx ptrendx assigned ptrendx and unassigned fheinecke Aug 11, 2026
@ptrendx
ptrendx merged commit b54bb1e into NVIDIA:main Aug 11, 2026
33 of 44 checks passed
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