Skip to content

Commit 42346c5

Browse files
Merge branch 'main' into ksimpson/tcc_memory_resource
2 parents f0d6ae2 + fd71ced commit 42346c5

File tree

83 files changed

+3844
-2738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3844
-2738
lines changed

.github/actions/build/action.yml.j2 renamed to .github/actions/build/action.yml

+25-30
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,14 @@ inputs:
2222
upload-enabled:
2323
required: true
2424
type: boolean
25+
python-version:
26+
required: true
27+
type: string
2528

2629
runs:
2730
using: composite
2831
steps:
2932

30-
<% for package_id, package_info in packages.items() %>
31-
- name: Download <<package_info.repo>> (artifacts)
32-
uses: ./.github/actions/download-artifacts
33-
with:
34-
artifact-repo: "<<package_info.repo>>"
35-
artifact-name: "<<package_info.artifact_name | replace_placeholder('repo', package_info.repo) | replace_placeholder('git_tag', package_info.git_tag) >>"
36-
target-device: "${{ inputs.target-device }}"
37-
git_sha: "<<package_info.git_tag>>"
38-
host-platform: ${{ inputs.host-platform }}
39-
dest-dir: ${{ env.ARTIFACTS_DIR }}
40-
dependencies-workflow: <<package_info.artifact_workflow>>
41-
<% endfor %>
42-
43-
<% if packages %>
44-
45-
- name: Display structure of downloaded artifacts
46-
shell: bash --noprofile --norc -xeuo pipefail {0}
47-
run: |
48-
pwd
49-
ls -lahR ${{ env.ARTIFACTS_DIR }}
50-
<% endif %>
51-
5233
- if: ${{ inputs.use-container }}
5334
name: Build (in container)
5435
shell: bash --noprofile --norc -xeuo pipefail {0}
@@ -60,14 +41,16 @@ runs:
6041
-e AWS_ACCESS_KEY_ID \
6142
-e AWS_SECRET_ACCESS_KEY \
6243
-e GITHUB_TOKEN \
63-
-e ARTIFACTS_DIR="$ARTIFACTS_DIR" \
44+
-e BINDINGS_ARTIFACTS_DIR="$BINDINGS_ARTIFACTS_DIR" \
45+
-e CORE_ARTIFACTS_DIR="$CORE_ARTIFACTS_DIR" \
6446
-e UPLOAD_ENABLED="$UPLOAD_ENABLED" \
6547
-e USE_CUDA="$USE_CUDA" \
6648
-e REPO_DIR="$REPO_DIR" \
6749
-e LEGATE_CORE_BUILD_MODE="$LEGATE_CORE_BUILD_MODE" \
6850
-e PYTHON_VERSION="$PYTHON_VERSION" \
6951
-v "${{ env.REPO_DIR }}:${{ env.REPO_DIR }}" \
70-
-v "${{ env.ARTIFACTS_DIR }}:${{ env.ARTIFACTS_DIR }}" \
52+
-v "${{ env.BINDINGS_ARTIFACTS_DIR }}:${{ env.BINDINGS_ARTIFACTS_DIR }}" \
53+
-v "${{ env.CORE_ARTIFACTS_DIR }}:${{ env.CORE_ARTIFACTS_DIR }}" \
7154
--rm "${{ inputs.docker-image }}" \
7255
/bin/bash -c "${{ env.REPO_DIR }}/continuous_integration/scripts/entrypoint ${{ env.REPO_DIR }}/continuous_integration/scripts/build ${{ inputs.build-type}} ${{ inputs.target-device }}"
7356
@@ -77,14 +60,26 @@ runs:
7760
run: |
7861
"${{ env.REPO_DIR }}/continuous_integration/scripts/entrypoint" "${{ env.REPO_DIR }}/continuous_integration/scripts/build" "${{ inputs.build-type}}" "${{ inputs.target-device }}"
7962
80-
- name: Display structure of the artifacts folder (post build)
63+
- name: Display structure of the bindings artifacts folder (post build)
64+
shell: bash --noprofile --norc -xeuo pipefail {0}
65+
run: |
66+
sudo chown -R $(whoami) ${{ env.BINDINGS_ARTIFACTS_DIR }}
67+
ls -lahR ${{ env.BINDINGS_ARTIFACTS_DIR }}
68+
69+
- name: Upload bindings build artifacts
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: ${{ env.BINDINGS_ARTIFACT_NAME }}
73+
path: ${{ env.BINDINGS_ARTIFACTS_DIR }}
74+
75+
- name: Display structure of the core artifacts folder (post build)
8176
shell: bash --noprofile --norc -xeuo pipefail {0}
8277
run: |
83-
sudo chown -R $(whoami) ${{ env.ARTIFACTS_DIR }}
84-
ls -lahR ${{ env.ARTIFACTS_DIR }}
78+
sudo chown -R $(whoami) ${{ env.CORE_ARTIFACTS_DIR }}
79+
ls -lahR ${{ env.CORE_ARTIFACTS_DIR }}
8580
86-
- name: Upload build artifacts
81+
- name: Upload core build artifacts
8782
uses: actions/upload-artifact@v4
8883
with:
89-
name: ${{ env.ARTIFACT_NAME }}
90-
path: ${{ env.ARTIFACTS_DIR }}
84+
name: ${{ env.CORE_ARTIFACT_NAME }}
85+
path: ${{ env.CORE_ARTIFACTS_DIR }}

.github/actions/download-artifacts/action.yml

-59
This file was deleted.

.github/actions/setup/action.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ inputs:
2020
required: true
2121
type: boolean
2222
python-version:
23-
required: false
23+
required: true
2424
type: string
2525

2626
runs:
@@ -57,12 +57,16 @@ runs:
5757
PKG_DIR="${BUILD_MODE}/${TARGET_PLATFORM}"
5858
fi
5959
60-
echo "ARTIFACT_NAME=${{ inputs.host-platform }}-${{ inputs.build-type }}-${{ inputs.client-repo }}-python${{ inputs.python-version }}-${{ inputs.target-device }}${BUILD_MODE_STR}${WITH_TESTS_STR}-${{ github.sha }}" >> $GITHUB_ENV
61-
echo "ARTIFACTS_DIR=$(realpath "$(pwd)/dist")" >> $GITHUB_ENV
60+
PYTHON_VERSION_FORMATTED=$(echo '${{ inputs.python-version }}' | tr -d '.')
61+
62+
echo "BINDINGS_ARTIFACT_NAME=${{ inputs.host-platform }}-${{ inputs.build-type }}-cuda_bindings-python${PYTHON_VERSION_FORMATTED}-${{ inputs.target-device }}${BUILD_MODE_STR}${WITH_TESTS_STR}-${{ github.sha }}" >> $GITHUB_ENV
63+
echo "BINDINGS_ARTIFACTS_DIR=$(realpath "$(pwd)/cuda_bindings/dist")" >> $GITHUB_ENV
64+
echo "CORE_ARTIFACT_NAME=${{ inputs.host-platform }}-${{ inputs.build-type }}-cuda_core-python${PYTHON_VERSION_FORMATTED}-${{ inputs.target-device }}${BUILD_MODE_STR}${WITH_TESTS_STR}-${{ github.sha }}" >> $GITHUB_ENV
65+
echo "CORE_ARTIFACTS_DIR=$(realpath "$(pwd)/cuda_core/dist")" >> $GITHUB_ENV
6266
echo "USE_CUDA=${{ (inputs.target-device == 'cpu' && 'OFF') || 'ON' }}" >> $GITHUB_ENV
6367
echo "UPLOAD_ENABLED=${{ (inputs.upload-enabled == 'true' && 'ON') || 'OFF' }}" >> $GITHUB_ENV
6468
echo "LEGATE_CORE_BUILD_MODE=${BUILD_MODE}" >> $GITHUB_ENV
6569
echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
6670
echo "TARGET_PLATFORM=${TARGET_PLATFORM}" >> $GITHUB_ENV
6771
echo "PKG_DIR=${PKG_DIR}" >> $GITHUB_ENV
68-
echo "PYTHON_VERSION=${{ inputs.python-version }}" >> $GITHUB_ENV
72+
echo "PYTHON_VERSION=${{ inputs.python-version }}" >> $GITHUB_ENV

.github/workflows/ci-gh.yml

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
- release
2525
upload-enabled:
2626
- false
27+
python-version:
28+
#TODO cover the whole python and cuda matrix
29+
- 3.12
2730
uses:
2831
./.github/workflows/gh-build-and-test.yml
2932
with:
@@ -32,4 +35,5 @@ jobs:
3235
build-mode: ${{ matrix.build-mode }}
3336
build-type: ci
3437
upload-enabled: ${{ matrix.upload-enabled }}
38+
python-version: ${{ matrix.python-version }}
3539
secrets: inherit

.github/workflows/gh-build-and-test.yml

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ on:
1616
upload-enabled:
1717
type: boolean
1818
required: true
19+
python-version:
20+
type: string
21+
required: true
1922
jobs:
2023
build:
2124
if: ${{ github.repository_owner == 'nvidia' }}
@@ -31,4 +34,5 @@ jobs:
3134
dependencies-file: ""
3235
build-mode: ${{ inputs.build-mode }}
3336
upload-enabled: ${{ inputs.upload-enabled }}
37+
python-version: ${{ inputs.python-version }}
3438
secrets: inherit

.github/workflows/gh-build.yml

+1-22
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ on:
3333
required: true
3434
type: boolean
3535
python-version:
36-
required: false
36+
required: true
3737
type: string
3838

3939
jobs:
@@ -63,27 +63,6 @@ jobs:
6363
upload-enabled: ${{ inputs.upload-enabled }}
6464
python-version: ${{ inputs.python-version }}
6565

66-
- name: Render templates
67-
shell: bash --noprofile --norc -xeuo pipefail {0}
68-
run: |
69-
pip -q install jinja2
70-
71-
DEPENDENCIES_FILE=""
72-
73-
if [ -z "${{ inputs.dependencies-file }}" ]; then
74-
DEPENDENCIES_FILE="${REPO_DIR}/continuous_integration/no_dependencies.json"
75-
else
76-
DEPENDENCIES_FILE="${REPO_DIR}/${{ inputs.dependencies-file }}"
77-
fi
78-
79-
${REPO_DIR}/continuous_integration/scripts/render-template.py .github/actions/build/action.yml.j2 "${DEPENDENCIES_FILE}" .github/actions/build/action.yml
80-
81-
- name: Dump templates
82-
shell: bash --noprofile --norc -xeuo pipefail {0}
83-
run: |
84-
echo ${REPO_DIR}/.github/actions/build/action.yml
85-
cat ${REPO_DIR}/.github/actions/build/action.yml
86-
8766
- name: Call build action
8867
uses: ./.github/actions/build
8968
with:

.pre-commit-config.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2024, NVIDIA CORPORATION.
2+
3+
repos:
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.6.4
6+
hooks:
7+
- id: ruff
8+
args: [--fix, --show-fixes]
9+
- id: ruff-format
10+
11+
default_language_version:
12+
python: python3

README.md

+25-62
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,39 @@
1-
# CUDA-Python
1+
# cuda-python
22

3-
CUDA Python is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python. Checkout the [Overview](https://nvidia.github.io/cuda-python/overview.html) for the workflow and performance results.
3+
CUDA Python is the home for accessing NVIDIA’s CUDA platform from Python. It consists of multiple components:
44

5-
## Installing
5+
* [cuda.core](https://nvidia.github.io/cuda-python/cuda-core/latest): Pythonic access to CUDA Runtime and other core functionalities
6+
* [cuda.bindings](https://nvidia.github.io/cuda-python/cuda-bindings/latest): Low-level Python bindings to CUDA C APIs
7+
* [cuda.cooperative](https://nvidia.github.io/cccl/cuda_cooperative/): Pythonic exposure of CUB cooperative algorithms
8+
* [cuda.parallel](https://nvidia.github.io/cccl/cuda_parallel/): Pythonic exposure of Thrust parallel algorithms
69

7-
CUDA Python can be installed from:
10+
For access to NVIDIA CPU & GPU Math Libraries, please refer to [nvmath-python](https://docs.nvidia.com/cuda/nvmath-python/latest).
811

9-
* PYPI
10-
* Conda (nvidia channel)
11-
* Source builds
12+
CUDA Python is currently undergoing an overhaul to improve existing and bring up new components. All of the previously available functionalities from the cuda-python package will continue to be available, please refer to the [cuda.bindings](https://nvidia.github.io/cuda-python/cuda-bindings/latest) documentation for installation guide and further detail.
1213

13-
There're differences in each of these options that are described further in [Installation](https://nvidia.github.io/cuda-python/install.html) documentation. Each package will guarantee minor version compatibility.
14+
## cuda-python as a metapackage
1415

15-
## Runtime Dependencies
16+
`cuda-python` is being re-structured to become a metapackage that contains a collection of subpackages. Each subpackage is versioned independently, allowing installation of each component as needed.
1617

17-
CUDA Python is supported on all platforms that CUDA is supported. Specific dependencies are as follows:
18+
### Subpackage: `cuda.core`
1819

19-
* Driver: Linux (450.80.02 or later) Windows (456.38 or later)
20-
* CUDA Toolkit 12.0 to 12.6
20+
The `cuda.core` package offers idiomatic, pythonic access to CUDA Runtime and other functionalities.
2121

22-
Only the NVRTC redistributable component is required from the CUDA Toolkit. [CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/index.html) Installation Guides can be used for guidance. Note that the NVRTC component in the Toolkit can be obtained via PYPI, Conda or Local Installer.
22+
The goals are to
2323

24-
### Supported Python Versions
24+
1. Provide **idiomatic ("pythonic")** access to CUDA Driver, Runtime, and JIT compiler toolchain
25+
2. Focus on **developer productivity** by ensuring end-to-end CUDA development can be performed quickly and entirely in Python
26+
3. **Avoid homegrown** Python abstractions for CUDA for new Python GPU libraries starting from scratch
27+
4. **Ease** developer **burden of maintaining** and catching up with latest CUDA features
28+
5. **Flatten the learning curve** for current and future generations of CUDA developers
2529

26-
CUDA Python follows [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html) for supported Python version guarantee.
30+
### Subpackage: `cuda.bindings`
2731

28-
Before dropping support, an issue will be raised to look for feedback.
32+
The `cuda.bindings` package is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python.
2933

30-
Source builds work for multiple Python versions, however pre-build PyPI and Conda packages are only provided for a subset:
34+
The list of available interfaces are:
3135

32-
* Python 3.9 to 3.12
33-
34-
## Testing
35-
36-
### Requirements
37-
38-
Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/requirements.txt).
39-
40-
### Unit-tests
41-
42-
You can run the included tests with:
43-
44-
```
45-
python -m pytest tests/
46-
```
47-
48-
### Benchmark
49-
50-
You can run benchmark only tests with:
51-
52-
```
53-
python -m pytest --benchmark-only benchmarks/
54-
```
55-
56-
### Samples
57-
58-
You can run the included tests with:
59-
60-
```
61-
python -m pytest examples/
62-
```
63-
64-
## Examples
65-
66-
CUDA Samples rewriten using CUDA Python are found in `examples`.
67-
68-
Custom extra included examples:
69-
70-
- `examples/extra/jit_program_test.py`: Demonstrates the use of the API to compile and
71-
launch a kernel on the device. Includes device memory allocation /
72-
deallocation, transfers between host and device, creation and usage of
73-
streams, and context management.
74-
- `examples/extra/numba_emm_plugin.py`: Implements a Numba External Memory Management
75-
plugin, showing that this CUDA Python Driver API can coexist with other
76-
wrappers of the driver API.
36+
* CUDA Driver
37+
* CUDA Runtime
38+
* NVRTC
39+
* nvJitLink

continuous_integration/no_dependencies.json

-1
This file was deleted.

continuous_integration/scripts/build

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
build_ci() {
44
set -xeou pipefail
55

6-
cd "${REPO_DIR}"
7-
86
export CUDA_HOME="${CONDA_PREFIX}/targets/x86_64-linux"
97
export PARALLEL_LEVEL=$(nproc --ignore 1)
108

9+
cd "${REPO_DIR}/cuda_bindings"
10+
python setup.py bdist_wheel
11+
12+
cd "${REPO_DIR}/cuda_core"
1113
python setup.py bdist_wheel
1214
}
1315

0 commit comments

Comments
 (0)