Skip to content

Commit c128381

Browse files
mdboomleofang
andauthored
Move driver and nvrtc cython and internal layers to new generator (#1972)
* Move driver and nvrtc cython and internal layers to new generator * Fix Cython interop tests * Handle headers differently * Fix compilation * Make const match * Fix compilation again * Attempt to fix Windows build * Fix Windows again * Fix not found error code * Look up pointers in a different way * Get first version right * Get first appearing versions correct * Fix weird special case * Fix exception signature to match what was there before * Also fix exception declaration in nvrtc * Fix PTDS and add PTDS testing * Update .gitignore Co-authored-by: Leo Fang <leof@nvidia.com> --------- Co-authored-by: Leo Fang <leof@nvidia.com>
1 parent bd2dc6c commit c128381

39 files changed

Lines changed: 32150 additions & 39854 deletions

.github/workflows/test-wheel-linux.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ jobs:
161161
SKIP_BINDINGS_TEST_OVERRIDE: ${{ inputs.skip-bindings-test && '1' || '0' }}
162162
run: ./ci/tools/env-vars test
163163

164+
- name: Apply extra matrix environment variables
165+
if: ${{ matrix.ENV }}
166+
env:
167+
MATRIX_ENV: ${{ toJSON(matrix.ENV) }}
168+
run: echo "$MATRIX_ENV" | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> "$GITHUB_ENV"
169+
164170
- name: Download cuda-pathfinder build artifacts
165171
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
166172
with:

.github/workflows/test-wheel-windows.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ jobs:
149149
shell: bash --noprofile --norc -xeuo pipefail {0}
150150
run: ./ci/tools/env-vars test
151151

152+
- name: Apply extra matrix environment variables
153+
if: ${{ matrix.ENV }}
154+
env:
155+
MATRIX_ENV: ${{ toJSON(matrix.ENV) }}
156+
shell: bash --noprofile --norc -xeuo pipefail {0}
157+
run: echo "$MATRIX_ENV" | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> "$GITHUB_ENV"
158+
152159
- name: Download cuda-pathfinder build artifacts
153160
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
154161
with:

.gitignore

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,23 @@ __pycache__/
1818
cache_driver
1919
cache_runtime
2020
cache_nvrtc
21-
cuda_bindings/cuda/bindings/_lib/utils.pxi
2221

2322
# CUDA Python specific (auto-generated)
24-
cuda_bindings/cuda/bindings/_bindings/cydriver.pxd
25-
cuda_bindings/cuda/bindings/_bindings/cydriver.pyx
2623
cuda_bindings/cuda/bindings/_bindings/cyruntime.pxd
2724
cuda_bindings/cuda/bindings/_bindings/cyruntime.pyx
2825
cuda_bindings/cuda/bindings/_bindings/cyruntime_ptds.pxd
2926
cuda_bindings/cuda/bindings/_bindings/cyruntime_ptds.pyx
30-
cuda_bindings/cuda/bindings/_internal/_nvml.pyx
27+
cuda_bindings/cuda/bindings/_internal/driver.pyx
28+
cuda_bindings/cuda/bindings/_internal/nvrtc.pyx
3129
cuda_bindings/cuda/bindings/_internal/cufile.pyx
3230
cuda_bindings/cuda/bindings/_internal/nvfatbin.pyx
3331
cuda_bindings/cuda/bindings/_internal/nvjitlink.pyx
3432
cuda_bindings/cuda/bindings/_internal/nvml.pyx
3533
cuda_bindings/cuda/bindings/_internal/nvvm.pyx
36-
cuda_bindings/cuda/bindings/_lib/utils.pxd
37-
cuda_bindings/cuda/bindings/_lib/utils.pyx
38-
cuda_bindings/cuda/bindings/cydriver.pxd
39-
cuda_bindings/cuda/bindings/cydriver.pyx
4034
cuda_bindings/cuda/bindings/cyruntime.pxd
4135
cuda_bindings/cuda/bindings/cyruntime.pyx
4236
cuda_bindings/cuda/bindings/cyruntime_functions.pxi
4337
cuda_bindings/cuda/bindings/cyruntime_types.pxi
44-
cuda_bindings/cuda/bindings/driver.pxd
45-
cuda_bindings/cuda/bindings/driver.pyx
4638
cuda_bindings/cuda/bindings/runtime.pxd
4739
cuda_bindings/cuda/bindings/runtime.pyx
4840
cuda_bindings/cuda/bindings/utils/_get_handle.pyx

ci/test-matrix.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
# install scripts swap the driver themselves).
2424
# - DRIVER: 'earliest' does not work with CUDA 12.9.1
2525
# - DRIVER: a custom version is not supported with FLAVOR=wsl on Linux.
26+
# - ENV: optional map of extra environment variables to inject into the test
27+
# job. Every key/value pair is written to GITHUB_ENV after the standard
28+
# environment-variable setup step, so the variables are visible to all
29+
# subsequent steps (including the cuda.bindings and cuda.core test
30+
# steps). Example:
31+
# ENV: { CUDA_PYTHON_PER_THREAD_DEFAULT_STREAM: '1' }
2632

2733
linux:
2834
pull-request:
@@ -33,7 +39,7 @@ linux:
3339
- { ARCH: 'amd64', PY_VER: '3.11', CUDA_VER: '12.9.1', LOCAL_CTK: '0', GPU: 'rtxpro6000', GPU_COUNT: '1', DRIVER: 'latest' }
3440
- { ARCH: 'amd64', PY_VER: '3.11', CUDA_VER: '13.0.2', LOCAL_CTK: '1', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest' }
3541
- { ARCH: 'amd64', PY_VER: '3.11', CUDA_VER: '13.3.0', LOCAL_CTK: '1', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest' }
36-
- { ARCH: 'amd64', PY_VER: '3.12', CUDA_VER: '12.9.1', LOCAL_CTK: '1', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest' }
42+
- { ARCH: 'amd64', PY_VER: '3.12', CUDA_VER: '12.9.1', LOCAL_CTK: '1', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest', ENV: { CUDA_PYTHON_PER_THREAD_DEFAULT_STREAM: '1' } }
3743
- { ARCH: 'amd64', PY_VER: '3.12', CUDA_VER: '13.0.2', LOCAL_CTK: '0', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest' }
3844
- { ARCH: 'amd64', PY_VER: '3.12', CUDA_VER: '13.3.0', LOCAL_CTK: '0', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest' }
3945
- { ARCH: 'amd64', PY_VER: '3.13', CUDA_VER: '12.9.1', LOCAL_CTK: '0', GPU: 'v100', GPU_COUNT: '1', DRIVER: 'latest' }
@@ -107,7 +113,7 @@ windows:
107113
- { ARCH: 'amd64', PY_VER: '3.12', CUDA_VER: '13.3.0', LOCAL_CTK: '1', GPU: 'a100', GPU_COUNT: '1', DRIVER: 'latest', DRIVER_MODE: 'TCC' }
108114
- { ARCH: 'amd64', PY_VER: '3.13', CUDA_VER: '12.9.1', LOCAL_CTK: '1', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest', DRIVER_MODE: 'TCC' }
109115
- { ARCH: 'amd64', PY_VER: '3.13', CUDA_VER: '13.0.2', LOCAL_CTK: '0', GPU: 'rtxpro6000', GPU_COUNT: '1', DRIVER: 'latest', DRIVER_MODE: 'MCDM' }
110-
- { ARCH: 'amd64', PY_VER: '3.13', CUDA_VER: '13.3.0', LOCAL_CTK: '0', GPU: 'rtxpro6000', GPU_COUNT: '1', DRIVER: 'latest', DRIVER_MODE: 'MCDM' }
116+
- { ARCH: 'amd64', PY_VER: '3.13', CUDA_VER: '13.3.0', LOCAL_CTK: '0', GPU: 'rtxpro6000', GPU_COUNT: '1', DRIVER: 'latest', DRIVER_MODE: 'MCDM', ENV: { CUDA_PYTHON_PER_THREAD_DEFAULT_STREAM: '1' } }
111117
- { ARCH: 'amd64', PY_VER: '3.14', CUDA_VER: '12.9.1', LOCAL_CTK: '0', GPU: 'v100', GPU_COUNT: '1', DRIVER: 'latest', DRIVER_MODE: 'TCC' }
112118
- { ARCH: 'amd64', PY_VER: '3.14', CUDA_VER: '13.0.2', LOCAL_CTK: '1', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest', DRIVER_MODE: 'MCDM' }
113119
- { ARCH: 'amd64', PY_VER: '3.14', CUDA_VER: '13.3.0', LOCAL_CTK: '1', GPU: 'l4', GPU_COUNT: '1', DRIVER: 'latest', DRIVER_MODE: 'MCDM' }

cuda_bindings/build_hooks.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ def _get_cuda_path() -> str:
7878
# Header parsing helpers (called only from _build_cuda_bindings)
7979

8080
_REQUIRED_HEADERS = {
81-
"driver": [
82-
"cuda.h",
83-
"cudaProfiler.h",
84-
],
8581
"runtime": [
8682
"driver_types.h",
8783
"vector_types.h",
@@ -449,9 +445,6 @@ def _cleanup_dst_files():
449445
cuda_bindings_files = [f for f in cuda_bindings_files if "cufile" not in f]
450446
sources_list = [
451447
# private
452-
(["cuda/bindings/_bindings/cydriver.pyx", "cuda/bindings/_bindings/loader.cpp"], None),
453-
# cynvrtc.pyx is now in cuda/bindings/ (pre-generated by cybind),
454-
# picked up by the cuda_bindings_files glob below.
455448
(["cuda/bindings/_bindings/cyruntime.pyx"], static_runtime_libraries),
456449
(["cuda/bindings/_bindings/cyruntime_ptds.pyx"], static_runtime_libraries),
457450
# utils

0 commit comments

Comments
 (0)