From 4135a2f7657ec1463acecaac7d8480f028919b04 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Fri, 20 Dec 2024 14:23:32 -0500 Subject: [PATCH 1/9] `cuda.core` v0.1.1 final doc touch (#301) * minor changes to the release note * add missing entries * Update 0.1.1-notes.md * update * address comments * mention Python/OS support matrix --- cuda_core/docs/source/install.md | 2 ++ cuda_core/docs/source/release/0.1.0-notes.md | 2 +- cuda_core/docs/source/release/0.1.1-notes.md | 25 ++++++++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cuda_core/docs/source/install.md b/cuda_core/docs/source/install.md index 42b78b73..a09653cd 100644 --- a/cuda_core/docs/source/install.md +++ b/cuda_core/docs/source/install.md @@ -12,6 +12,8 @@ dependencies are as follows: [^1]: Including `cuda-python`. +`cuda.core` supports Python 3.9 - 3.12, on Linux (x86-64, arm64) and Windows (x86-64). + ## Installing from PyPI `cuda.core` works with `cuda.bindings` (part of `cuda-python`) 11 or 12. For example with CUDA 12: diff --git a/cuda_core/docs/source/release/0.1.0-notes.md b/cuda_core/docs/source/release/0.1.0-notes.md index 2131ed90..5d1c7fd5 100644 --- a/cuda_core/docs/source/release/0.1.0-notes.md +++ b/cuda_core/docs/source/release/0.1.0-notes.md @@ -1,4 +1,4 @@ -# `cuda.core` Release notes +# `cuda.core` v0.1.0 Release notes Released on Nov 8, 2024 diff --git a/cuda_core/docs/source/release/0.1.1-notes.md b/cuda_core/docs/source/release/0.1.1-notes.md index 58e511aa..ac21c210 100644 --- a/cuda_core/docs/source/release/0.1.1-notes.md +++ b/cuda_core/docs/source/release/0.1.1-notes.md @@ -1,25 +1,28 @@ -# `cuda.core` Release notes +# `cuda.core` v0.1.1 Release notes -Released on Dec XX, 2024 +Released on Dec 20, 2024 ## Hightlights - Add `StridedMemoryView` and `@args_viewable_as_strided_memory` that provide a concrete implementation of DLPack & CUDA Array Interface supports. -- Add `Linker` that can link one or multiple `ObjectCode` instances generated by `Program`s. Under - the hood, it uses either the nvJitLink or cuLink APIs depending on the CUDA version detected - in the current environment. -- Add a `cuda.core.experimental.system` module for querying system- or process- wide information. -- Support TCC devices with a default synchronous memory resource to avoid the use of memory pools +- Add `Linker` that can link one or multiple `ObjectCode` instances generated by `Program`. Under + the hood, it uses either the nvJitLink or driver (`cuLink*`) APIs depending on the CUDA version + detected in the current environment. +- Support `pip install cuda-core`. Please see the Installation Guide for further details. ## New features +- Add a `cuda.core.experimental.system` module for querying system- or process- wide information. - Add `LaunchConfig.cluster` to support thread block clusters on Hopper GPUs. ## Enchancements -- Ensure "ltoir" is a valid code type to `ObjectCode`. -- Improve test coverage. +- The internal handle held by `ObjectCode` is now lazily initialized upon first touch. +- Support TCC devices with a default synchronous memory resource to avoid the use of memory pools. +- Ensure `"ltoir"` is a valid code type to `ObjectCode`. +- Document the `__cuda_stream__` protocol. +- Improve test coverage & documentation cross-references. - Enforce code formatting. ## Bug fixes @@ -35,4 +38,6 @@ Released on Dec XX, 2024 not supported. This will be fixed in a future release. - Some `LinkerOptions` are only available when using a modern version of CUDA. When using CUDA <12, the backend is the cuLink api which supports only a subset of the options that nvjitlink does. - Further, some options aren't available on CUDA versions <12.6 + Further, some options aren't available on CUDA versions <12.6. +- To use `cuda.core` with Python 3.13, it currently requires building `cuda-python` from source + prior to `pip install`. This extra step will be fixed soon. From 8e95441bbc18a86ba17ed5f2518497f491fe7c30 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sat, 28 Dec 2024 20:01:01 -0500 Subject: [PATCH 2/9] Fix triagelabel workflow --- .github/workflows/triagelabel.yml | 32 +++++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/workflows/triagelabel.yml b/.github/workflows/triagelabel.yml index 74127b0c..bea3e5cd 100644 --- a/.github/workflows/triagelabel.yml +++ b/.github/workflows/triagelabel.yml @@ -2,27 +2,21 @@ name: Add Triage Label on: issues: - types: [opened] + types: + - reopened + - opened jobs: triage: runs-on: ubuntu-latest + permissions: + issues: write steps: - - name: Check for existing labels - id: check_labels - uses: actions/github-script@v6 - with: - script: | - const labels = await github.issues.listLabelsOnIssue({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number - }); - return labels.data.length > 0; - - - name: Add Triage Label - if: steps.check_labels.outputs.result == 'false' - uses: actions-ecosystem/action-add-labels@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: triage + - name: Add or check for existing labels + # add the triage label only if no label has been added + if: ${{ github.event.issue.labels[0] != null }} + run: gh issue edit "$NUMBER" --add-label "triage" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} From 0c5061c19cc2efd7ca026df22733ffa9003a4eff Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sat, 28 Dec 2024 20:06:40 -0500 Subject: [PATCH 3/9] flip the check logic --- .github/workflows/triagelabel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/triagelabel.yml b/.github/workflows/triagelabel.yml index bea3e5cd..e22f491c 100644 --- a/.github/workflows/triagelabel.yml +++ b/.github/workflows/triagelabel.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Add or check for existing labels # add the triage label only if no label has been added - if: ${{ github.event.issue.labels[0] != null }} + if: ${{ github.event.issue.labels[0] == null }} run: gh issue edit "$NUMBER" --add-label "triage" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 8cbea18708e06ddbb64f2d2d92f97b62b6e61ef8 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 30 Dec 2024 02:03:21 +0000 Subject: [PATCH 4/9] switch to use new random impl --- cuda_core/examples/saxpy.py | 9 +++++---- cuda_core/examples/vector_add.py | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cuda_core/examples/saxpy.py b/cuda_core/examples/saxpy.py index 8caa4d4a..d1d7211f 100644 --- a/cuda_core/examples/saxpy.py +++ b/cuda_core/examples/saxpy.py @@ -47,8 +47,9 @@ # prepare input/output size = cp.uint64(64) a = dtype(10) -x = cp.random.random(size, dtype=dtype) -y = cp.random.random(size, dtype=dtype) +rng = cp.random.default_rng() +x = rng.random(size, dtype=dtype) +y = rng.random(size, dtype=dtype) out = cp.empty_like(x) dev.sync() # cupy runs on a different stream from s, so sync before accessing @@ -73,8 +74,8 @@ # prepare input size = cp.uint64(128) a = dtype(42) -x = cp.random.random(size, dtype=dtype) -y = cp.random.random(size, dtype=dtype) +x = rng.random(size, dtype=dtype) +y = rng.random(size, dtype=dtype) dev.sync() # prepare output diff --git a/cuda_core/examples/vector_add.py b/cuda_core/examples/vector_add.py index 550eaf2a..17265327 100644 --- a/cuda_core/examples/vector_add.py +++ b/cuda_core/examples/vector_add.py @@ -42,8 +42,9 @@ # prepare input/output size = 50000 -a = cp.random.random(size, dtype=dtype) -b = cp.random.random(size, dtype=dtype) +rng = cp.random.default_rng() +a = rng.random(size, dtype=dtype) +b = rng.random(size, dtype=dtype) c = cp.empty_like(a) # cupy runs on a different stream from s, so sync before accessing From b900413e4eecec93f15baca3be89bc59ad68aaf5 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 30 Dec 2024 02:03:34 +0000 Subject: [PATCH 5/9] enable cupy in test --- .github/workflows/gh-build-and-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/gh-build-and-test.yml b/.github/workflows/gh-build-and-test.yml index 51f4bd87..5ccde272 100644 --- a/.github/workflows/gh-build-and-test.yml +++ b/.github/workflows/gh-build-and-test.yml @@ -317,8 +317,6 @@ jobs: pushd ./cuda_core # TODO: add requirements.txt for test deps? - pip install pytest - # TODO: add CuPy to test deps (which would require cuRAND) - # pip install "cupy-cuda${TEST_CUDA_MAJOR}x" + pip install pytest "cupy-cuda${TEST_CUDA_MAJOR}x" pytest -rxXs tests/ popd From 58116046d1081f4b91cc4d8dfa5c551b16527e4b Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 30 Dec 2024 02:54:06 +0000 Subject: [PATCH 6/9] cupy is not yet supported on PY313 --- .github/workflows/gh-build-and-test.yml | 7 +++---- cuda_core/tests/requirements-cu11.txt | 2 ++ cuda_core/tests/requirements-cu12.txt | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 cuda_core/tests/requirements-cu11.txt create mode 100644 cuda_core/tests/requirements-cu12.txt diff --git a/.github/workflows/gh-build-and-test.yml b/.github/workflows/gh-build-and-test.yml index 5ccde272..c2dc50c6 100644 --- a/.github/workflows/gh-build-and-test.yml +++ b/.github/workflows/gh-build-and-test.yml @@ -300,9 +300,9 @@ jobs: - name: Run cuda.core tests shell: bash --noprofile --norc -xeuo pipefail {0} run: | - if [[ $SKIP_CUDA_BINDINGS_TEST == 1 ]]; then + if [[ ${{ matrix.python-version }} == "3.13" ]]; then # TODO: remove this hack once cuda-python has a cp313 build - if [[ ${{ matrix.python-version }} == "3.13" ]]; then + if [[ $SKIP_CUDA_BINDINGS_TEST == 1 ]]; then echo "Python 3.13 + cuda-python ${{ matrix.cuda-version }} is not supported, skipping the test..." exit 0 fi @@ -316,7 +316,6 @@ jobs: popd pushd ./cuda_core - # TODO: add requirements.txt for test deps? - pip install pytest "cupy-cuda${TEST_CUDA_MAJOR}x" + pip install -r "tests/requirements-cu${TEST_CUDA_MAJOR}.txt" pytest -rxXs tests/ popd diff --git a/cuda_core/tests/requirements-cu11.txt b/cuda_core/tests/requirements-cu11.txt new file mode 100644 index 00000000..2e8135b7 --- /dev/null +++ b/cuda_core/tests/requirements-cu11.txt @@ -0,0 +1,2 @@ +# TODO: remove this hack once cupy has a cp313 build +cupy-cuda12x; python_version < "3.13" diff --git a/cuda_core/tests/requirements-cu12.txt b/cuda_core/tests/requirements-cu12.txt new file mode 100644 index 00000000..2e8135b7 --- /dev/null +++ b/cuda_core/tests/requirements-cu12.txt @@ -0,0 +1,2 @@ +# TODO: remove this hack once cupy has a cp313 build +cupy-cuda12x; python_version < "3.13" From 2e4a993e7a7299892654bc8d14c3878e2bbb00e9 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 30 Dec 2024 02:54:36 +0000 Subject: [PATCH 7/9] get_kernel requires a valid cuda context on CUDA 11 --- cuda_core/examples/strided_memory_view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuda_core/examples/strided_memory_view.py b/cuda_core/examples/strided_memory_view.py index 564d7fa0..2cc25989 100644 --- a/cuda_core/examples/strided_memory_view.py +++ b/cuda_core/examples/strided_memory_view.py @@ -91,6 +91,7 @@ gpu_prog = Program(gpu_code, code_type="c++") # To know the GPU's compute capability, we need to identify which GPU to use. dev = Device(0) + dev.set_current() arch = "".join(f"{i}" for i in dev.compute_capability) mod = gpu_prog.compile( target_type="cubin", @@ -156,7 +157,6 @@ def my_func(arr, work_stream): # This takes the GPU path if cp: - dev.set_current() s = dev.create_stream() # Create input array on GPU arr_gpu = cp.ones(1024, dtype=cp.int32) From fa3df13e5df832b63b7fcb44b2d8cd46e7e8b00c Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 30 Dec 2024 03:23:13 +0000 Subject: [PATCH 8/9] complete cuda-core test requirements --- cuda_core/tests/requirements-cu11.txt | 1 + cuda_core/tests/requirements-cu12.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/cuda_core/tests/requirements-cu11.txt b/cuda_core/tests/requirements-cu11.txt index 2e8135b7..2e82e12d 100644 --- a/cuda_core/tests/requirements-cu11.txt +++ b/cuda_core/tests/requirements-cu11.txt @@ -1,2 +1,3 @@ +pytest # TODO: remove this hack once cupy has a cp313 build cupy-cuda12x; python_version < "3.13" diff --git a/cuda_core/tests/requirements-cu12.txt b/cuda_core/tests/requirements-cu12.txt index 2e8135b7..2e82e12d 100644 --- a/cuda_core/tests/requirements-cu12.txt +++ b/cuda_core/tests/requirements-cu12.txt @@ -1,2 +1,3 @@ +pytest # TODO: remove this hack once cupy has a cp313 build cupy-cuda12x; python_version < "3.13" From 9756b1a863c066d3fa89bfb4ea7cfc81609a217a Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 30 Dec 2024 03:29:54 +0000 Subject: [PATCH 9/9] fix typo --- cuda_core/tests/requirements-cu11.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuda_core/tests/requirements-cu11.txt b/cuda_core/tests/requirements-cu11.txt index 2e82e12d..8fb37e92 100644 --- a/cuda_core/tests/requirements-cu11.txt +++ b/cuda_core/tests/requirements-cu11.txt @@ -1,3 +1,3 @@ pytest # TODO: remove this hack once cupy has a cp313 build -cupy-cuda12x; python_version < "3.13" +cupy-cuda11x; python_version < "3.13"