Skip to content

Commit 172a8b5

Browse files
authored
Merge branch 'main' into 297-twine-check
2 parents 0512550 + f0c304f commit 172a8b5

File tree

19 files changed

+260
-139
lines changed

19 files changed

+260
-139
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Preview or clean up docs built from PRs
2+
3+
# A re-implementation based on the logic of https://github.com/rossjrw/pr-preview-action/blob/41a957c44a456a34718e9bcf825363194db5e6d5/README.md, due to limitations illustrated in NVIDIA/cuda-python#380.
4+
5+
inputs:
6+
source-folder:
7+
required: true
8+
type: string
9+
10+
runs:
11+
using: composite
12+
steps:
13+
# The steps below are executed only when testing in a PR.
14+
# Note: the PR previews will be removed once merged to main (see below)
15+
- name: Get PR info
16+
if: ${{ github.ref_name != 'main' }}
17+
uses: nv-gha-runners/get-pr-info@main
18+
id: get-pr-info
19+
20+
- name: Extract PR number from info
21+
if: ${{ github.ref_name != 'main' }}
22+
shell: bash --noprofile --norc -xeuo pipefail {0}
23+
run: |
24+
PR_NUMBER="${{ fromJSON(steps.get-pr-info.outputs.pr-info).number }}"
25+
if [[ "$PR_NUMBER" == "" ]]; then
26+
echo "cannot extract PR number"
27+
exit 1
28+
else
29+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
30+
fi
31+
32+
- name: Deploy doc preview
33+
if: ${{ github.ref_name != 'main' }}
34+
uses: JamesIves/github-pages-deploy-action@v4
35+
with:
36+
git-config-name: cuda-python-bot
37+
git-config-email: [email protected]
38+
folder: ${{ inputs.source-folder }}
39+
target-folder: docs/pr-preview/pr-${{ env.PR_NUMBER }}/
40+
commit-message: "Deploy doc preview for PR ${{ env.PR_NUMBER }} (${{ github.sha }})"
41+
42+
- name: Leave a comment after deployment
43+
if: ${{ github.ref_name != 'main' }}
44+
uses: marocchino/sticky-pull-request-comment@v2
45+
with:
46+
header: pr-preview
47+
number: ${{ env.PR_NUMBER }}
48+
skip_unchanged: true
49+
message: |
50+
Doc Preview CI
51+
:---:
52+
| <p></p> :rocket: View preview at <br> https://nvidia.github.io/cuda-python/pr-preview/pr-${{ env.PR_NUMBER }}/ <br><br>
53+
| <h6><br> Preview will be ready when the GitHub Pages deployment is complete. <br><br></h6>
54+
55+
# The steps below are executed only when building on main.
56+
- name: Get PR data
57+
if: ${{ github.ref_name == 'main' }}
58+
uses: actions/github-script@v7
59+
id: get-pr-data
60+
with:
61+
script: |
62+
return (
63+
await github.rest.repos.listPullRequestsAssociatedWithCommit({
64+
commit_sha: context.sha,
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
})
68+
).data[0];
69+
70+
- name: Extract PR number from data
71+
if: ${{ github.ref_name == 'main' }}
72+
shell: bash --noprofile --norc -xeuo pipefail {0}
73+
run: |
74+
PR_NUMBER="${{ fromJSON(steps.get-pr-data.outputs.result).number }}"
75+
if [[ "$PR_NUMBER" == "" ]]; then
76+
echo "cannot extract PR number"
77+
exit 1
78+
else
79+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
80+
fi
81+
82+
- name: Remove doc preview
83+
if: ${{ github.ref_name == 'main' }}
84+
uses: JamesIves/github-pages-deploy-action@v4
85+
with:
86+
git-config-name: cuda-python-bot
87+
git-config-email: [email protected]
88+
folder: ${{ inputs.source-folder }}
89+
target-folder: docs/pr-preview/pr-${{ env.PR_NUMBER }}/
90+
commit-message: "Clean up doc preview for PR ${{ env.PR_NUMBER }} (${{ github.sha }})"
91+
92+
- name: Leave a comment after removal
93+
if: ${{ github.ref_name == 'main' }}
94+
uses: marocchino/sticky-pull-request-comment@v2
95+
with:
96+
header: pr-preview
97+
number: ${{ env.PR_NUMBER }}
98+
hide_and_recreate: true
99+
hide_classify: "OUTDATED"
100+
message: |
101+
Doc Preview CI
102+
:---:
103+
Preview removed because the pull request was closed or merged.

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
name: Build (${{ matrix.host-platform }}, Python ${{ matrix.python-version }}, CUDA ${{ matrix.cuda-version }})
3636
if: ${{ github.repository_owner == 'nvidia' }}
3737
permissions:
38-
id-token: write # This is required for configure-aws-credentials
3938
contents: read # This is required for actions/checkout
4039
runs-on: ${{ (matrix.host-platform == 'linux-64' && 'linux-amd64-cpu8') ||
4140
(matrix.host-platform == 'linux-aarch64' && 'linux-arm64-cpu8') ||
@@ -77,7 +76,7 @@ jobs:
7776
REPO_DIR=$(cygpath -w $PWD)
7877
fi
7978
80-
echo "PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
79+
echo "CUDA_BINDINGS_PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
8180
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}"
8281
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
8382
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
@@ -140,10 +139,10 @@ jobs:
140139
# CIBW mounts the host filesystem under /host
141140
CIBW_ENVIRONMENT_LINUX: >
142141
CUDA_PATH=/host/${{ env.CUDA_PATH }}
143-
PARALLEL_LEVEL=${{ env.PARALLEL_LEVEL }}
142+
CUDA_BINDINGS_PARALLEL_LEVEL=${{ env.CUDA_BINDINGS_PARALLEL_LEVEL }}
144143
CIBW_ENVIRONMENT_WINDOWS: >
145144
CUDA_HOME="$(cygpath -w ${{ env.CUDA_PATH }})"
146-
# PARALLEL_LEVEL=${{ env.PARALLEL_LEVEL }}
145+
CUDA_BINDINGS_PARALLEL_LEVEL=${{ env.CUDA_BINDINGS_PARALLEL_LEVEL }}
147146
with:
148147
package-dir: ./cuda_bindings/
149148
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
@@ -229,14 +228,18 @@ jobs:
229228
- 0 # use CTK wheels
230229
runner:
231230
- default
231+
exclude:
232+
# To test this combo would require nontrivial installation steps.
233+
- cuda-version: "12.0.1"
234+
local-ctk: 0
232235
include:
233236
- host-platform: linux-64
234237
python-version: "3.12"
235238
cuda-version: "12.6.2"
239+
local-ctk: 1
236240
runner: H100
237241
name: Test (${{ matrix.host-platform }}, Python ${{ matrix.python-version }}, CUDA ${{ matrix.cuda-version }}, Runner ${{ matrix.runner }}, ${{ (matrix.local-ctk == '1' && 'local CTK') || 'CTK wheels' }})
238-
# The build stage could fail but we want the CI to keep moving.
239-
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
242+
if: ${{ github.repository_owner == 'nvidia' }}
240243
permissions:
241244
contents: read # This is required for actions/checkout
242245
needs:
@@ -254,12 +257,12 @@ jobs:
254257

255258
doc:
256259
name: Docs
257-
# The build stage could fail but we want the CI to keep moving.
258-
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
260+
if: ${{ github.repository_owner == 'nvidia' }}
259261
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
260262
permissions:
261263
id-token: write
262264
contents: write
265+
pull-requests: write
263266
needs:
264267
- build
265268
secrets: inherit

.github/workflows/build-docs.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ jobs:
5050
# WAR: Building the doc currently requires CTK installed (NVIDIA/cuda-python#326,327)
5151
- name: Set up mini CTK
5252
uses: ./.github/actions/fetch_ctk
53-
continue-on-error: false
5453
with:
5554
host-platform: linux-64
5655
cuda-version: ${{ inputs.build-ctk-ver }}
@@ -126,22 +125,29 @@ jobs:
126125
mkdir -p artifacts/docs
127126
mv cuda_python/docs/build/html/* artifacts/docs/
128127
129-
# Note: currently this is only for manual inspection. This step will become
130-
# required once we switch to use GHA for doc deployment (see the bottom).
128+
# create an empty folder for removal use
129+
mkdir -p artifacts/empty_docs
130+
131+
# TODO: Consider removing this step?
131132
- name: Upload doc artifacts
132133
uses: actions/upload-pages-artifact@v3
133134
with:
134135
path: artifacts/
135136
retention-days: 3
136137

137-
# The step below is not executed unless when building on main.
138+
- name: Deploy or clean up doc preview
139+
uses: ./.github/actions/doc_preview
140+
with:
141+
source-folder: ${{ (github.ref_name != 'main' && 'artifacts/docs') ||
142+
'artifacts/empty_docs' }}
143+
138144
- name: Deploy doc update
139-
if: ${{ github.ref_name == 'main' && success() }}
145+
if: ${{ github.ref_name == 'main' }}
140146
uses: JamesIves/github-pages-deploy-action@v4
141147
with:
142-
folder: artifacts/docs/
143148
git-config-name: cuda-python-bot
144149
git-config-email: [email protected]
150+
folder: artifacts/docs/
145151
target-folder: docs/
146152
commit-message: "Deploy latest docs: ${{ github.sha }}"
147153
clean: false

.github/workflows/test-wheel.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,17 @@ jobs:
122122
echo "LATEST_PRIOR_RUN_ID not found!"
123123
exit 1
124124
fi
125+
125126
gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python
126127
ls -al $OLD_BASENAME
127128
mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
128129
mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"/
130+
rmdir $OLD_BASENAME
129131
130132
gh run download $LATEST_PRIOR_RUN_ID -p cuda-python-wheel -R NVIDIA/cuda-python
133+
ls -al cuda-python-wheel
131134
mv cuda-python-wheel/*.whl .
135+
rmdir cuda-python-wheel
132136
133137
- name: Display structure of downloaded cuda-python artifacts
134138
run: |

cuda_bindings/cuda/bindings/_lib/cyruntime/cyruntime.pyx.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4639,7 +4639,7 @@ cdef cudaError_t _cudaGraphExecGetFlags(cudaGraphExec_t graphExec, unsigned long
46394639
err = m_global.lazyInitContextState()
46404640
if err != cudaSuccess:
46414641
return err
4642-
err = <cudaError_t>cydriver._cuGraphExecGetFlags(<cydriver.CUgraphExec>graphExec, flags)
4642+
err = <cudaError_t>cydriver._cuGraphExecGetFlags(<cydriver.CUgraphExec>graphExec, <cydriver.cuuint64_t *>flags)
46434643
if err != cudaSuccess:
46444644
_setLastError(err)
46454645
return err

cuda_bindings/docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
release.md
1212
environment_variables.md
1313
api.rst
14+
tips_and_tricks.rst
1415

1516

1617
Indices and tables
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Tips and Tricks
2+
---------------
3+
4+
Getting the address of underlying C objects from the low-level bindings
5+
=======================================================================
6+
7+
All CUDA C types are exposed to Python as Python classes. For example, the :class:`~cuda.bindings.driver.CUstream` type is exposed as a class with methods :meth:`~cuda.bindings.driver.CUstream.getPtr()` and :meth:`~cuda.bindings.driver.CUstream.__int__()` implemented.
8+
9+
There is an important distinction between the ``getPtr()`` method and the behaviour of ``__int__()``. If you need to get the pointer address *of* the underlying ``CUstream`` C object wrapped in the Python class, you can do so by calling ``int(instance_of_CUstream)``, which returns the address as a Python `int`, while calling ``instance_of_CUstream.getPtr()`` returns the pointer *to* the ``CUstream`` C object (that is, ``&CUstream``) as a Python `int`.

cuda_core/cuda/core/experimental/_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from dataclasses import dataclass
66

7-
from cuda import cuda
7+
from cuda.core.experimental._utils import driver
88

99

1010
@dataclass
@@ -20,7 +20,7 @@ def __init__(self):
2020

2121
@staticmethod
2222
def _from_ctx(obj, dev_id):
23-
assert isinstance(obj, cuda.CUcontext)
23+
assert isinstance(obj, driver.CUcontext)
2424
ctx = Context.__new__(Context)
2525
ctx._handle = obj
2626
ctx._id = dev_id

0 commit comments

Comments
 (0)