-
Notifications
You must be signed in to change notification settings - Fork 616
Support building with headers from nvidia wheels #2623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There are two changes:
1. `import nvidia` returns a namespace package with `__file__` equal to `None`
2. Add the way to force headers from nvidia wheels. Without that envvar, it's practically impossible with CUDA installed system-wide.
I successfully built the package with torch using the following `uv` configuration:
```
[tool.uv.extra-build-dependencies]
"transformer-engine-torch" = [
"ninja",
"nvidia-cuda-crt==13.0.88",
"nvidia-cuda-cccl==13.0.85",
{ requirement = "torch", match-runtime = true },
{ requirement = "pytorch-triton", match-runtime = true },
{ requirement = "nvidia-cusolver", match-runtime = true },
{ requirement = "nvidia-curand", match-runtime = true },
{ requirement = "nvidia-cublas", match-runtime = true },
{ requirement = "nvidia-cusparse", match-runtime = true },
{ requirement = "nvidia-cudnn-cu13", match-runtime = true },
{ requirement = "nvidia-nvtx", match-runtime = true },
{ requirement = "nvidia-cuda-nvrtc", match-runtime = true },
{ requirement = "nvidia-cuda-runtime", match-runtime = true },
]
```
Signed-off-by: Vadim Markovtsev <[email protected]>
Greptile OverviewGreptile SummaryThis PR enables building TransformerEngine with headers from nvidia wheels by making two focused changes to the build system. First, it adds support for namespace packages where Key changes:
The changes are minimal, focused, and properly handle the edge case of namespace packages. The logic correctly prioritizes toolkit includes unless explicitly overridden. Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Build as Build System
participant Utils as build_tools/utils.py
participant Env as Environment
participant NV as nvidia package
participant FS as File System
Build->>Utils: get_cuda_include_dirs()
Utils->>Env: Check NVTE_BUILD_USE_NVIDIA_WHEELS
alt force_wheels=true OR toolkit not available
Utils->>NV: import nvidia
alt nvidia.__file__ is not None
NV-->>Utils: Return __file__
Utils->>FS: cuda_root = Path(__file__).parent
else nvidia.__file__ is None (namespace package)
NV-->>Utils: Return __path__[0]
Utils->>FS: cuda_root = Path(__path__[0])
end
Utils->>FS: Iterate subdirs with include/
FS-->>Utils: Return list of include dirs
else toolkit available AND not force_wheels
Utils->>Utils: cuda_toolkit_include_path()
Utils-->>Build: Return toolkit include path
end
Utils-->>Build: Return CUDA include directories
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No files reviewed, no comments
|
/te-ci L0 |
|
It looks like the red jobs are unrelated timeouts. |
There are two changes:
import nvidiareturns a namespace package with__file__equal toNoneI successfully built the package with torch using the following
uvconfiguration:Description
Please include a brief summary of the changes, relevant motivation and context.
Fixes # (issue)
Type of change
Checklist: