Skip to content

Commit eb4f272

Browse files
authored
Merge branch 'main' into docs-pinned-mr-allocate-params
2 parents fc1d657 + 590a8bf commit eb4f272

127 files changed

Lines changed: 58297 additions & 3160 deletions

File tree

Some content is hidden

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

‎.clang-format‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# A clang-format style derived from Python's PEP 7 (4-space indent, Stroustrup braces,
6+
# return type on its own line), except that the column limit is 120 rather than 79.
7+
# Based on https://gist.github.com/pganssle/0e3a5f828b4d07d79447f6ced8e7e4db
8+
BasedOnStyle: Google
9+
BreakAfterReturnType: AllDefinitions
10+
AllowShortIfStatementsOnASingleLine: Never
11+
BreakBeforeBraces: Stroustrup
12+
ColumnLimit: 120
13+
DerivePointerAlignment: false
14+
IndentWidth: 4
15+
Language: Cpp
16+
PointerAlignment: Right
17+
ReflowComments: Always
18+
SpaceBeforeParens: ControlStatements
19+
SpacesInParens: Never
20+
TabWidth: 4
21+
UseTab: Never
22+
23+
# Keep include order as written; reordering can break order-sensitive builds.
24+
SortIncludes: {Enabled: false}
25+
26+
# Ruff-like wrapping: break after "(", indent arguments, put ")" on its own line.
27+
# This does not contradict PEP7, but extends it to the consistent style where
28+
# calls either fit on a single line or they are broken across multiple lines with
29+
# one argument per line (indented).
30+
AlignAfterOpenBracket: true
31+
BreakAfterOpenBracketBracedList: true
32+
BreakAfterOpenBracketFunction: true
33+
BreakAfterOpenBracketIf: true
34+
BreakBeforeCloseBracketBracedList: true
35+
BreakBeforeCloseBracketFunction: true
36+
BreakBeforeCloseBracketIf: true
37+
PackArguments: {BinPack: OnePerLine}
38+
PackParameters: {BinPack: OnePerLine}
39+
AllowAllArgumentsOnNextLine: false

‎.github/CODERABBIT.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!-- SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -->
2+
<!-- SPDX-License-Identifier: Apache-2.0 -->
3+
4+
# CodeRabbit Configuration
5+
6+
This document explains how CodeRabbit is configured for CUDA Python. For review
7+
commands and guidance, see the
8+
[CodeRabbit section of the contributing guide](../CONTRIBUTING.md#coderabbit).
9+
For complete product documentation, see the
10+
[CodeRabbit documentation](https://docs.coderabbit.ai/).
11+
12+
CUDA Python configures CodeRabbit through [`.coderabbit.yaml`](../.coderabbit.yaml)
13+
in the repository root. For pull requests from a branch in the same repository,
14+
the configuration in that branch is used for the review. Pull requests from
15+
forks use the target branch's configuration instead, so changes to
16+
`.coderabbit.yaml` in a fork do not affect that review.
17+
18+
When setting up or updating CodeRabbit:
19+
20+
1. Keep repository-specific settings in `.coderabbit.yaml`.
21+
2. Use `@coderabbitai configuration` on a pull request to inspect the resolved
22+
configuration. This is useful when checking whether CodeRabbit is using the
23+
expected repository settings for that pull request.
24+
3. Use `@coderabbitai generate configuration` to export the resolved
25+
configuration if a new baseline is needed. This is useful when moving
26+
settings into a reviewable repository configuration file.
27+
4. Keep configuration changes small and reviewable.
28+
5. Use `reviews.path_instructions` for path-specific review guidance.
29+
6. Use `knowledge_base.code_guidelines.filePatterns` for CUDA Python guidance
30+
files that CodeRabbit should read as review context.
31+
32+
The CUDA Python configuration should keep comments focused on correctness, API
33+
stability, performance, security, and other high-impact issues. Avoid enabling
34+
features that add noisy generated comments or code by default.

‎.pre-commit-config.yaml‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,21 @@ repos:
2424
- id: secret-scan-trufflehog
2525

2626
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: a56c0b927e6465d37cae3e97d35d4d18ab2b96cd # frozen: v0.16.9
27+
rev: f368fb366ff7f2f808dd324b83a6d32267799e19 # frozen: v0.17.2
2828
hooks:
2929
- id: ruff-check
3030
args: [--fix, --show-fixes]
3131
exclude: (^cuda_bindings_(?:12|13)/cuda/bindings/_internal/_fast_enum\.py$)|(.*\.pyi$)
3232
- id: ruff-format
3333
exclude: .*\.pyi$
3434

35+
- repo: https://github.com/pre-commit/mirrors-clang-format
36+
rev: 98ad4ddb9c057de2f5b9e93e44e6db959807d68c # frozen: v23.1.3
37+
hooks:
38+
- id: clang-format
39+
types_or: [c, c++, cuda]
40+
exclude: ^cuda_core/(cuda/core/_include/(dlpack|aoti_shim)\.h|third_party/)
41+
3542
- repo: local
3643
hooks:
3744
- id: check-precommit-installed
@@ -104,7 +111,7 @@ repos:
104111
files: ^cuda_core/cuda/.*\.(pyx|pxd)$
105112
pass_filenames: false
106113
additional_dependencies:
107-
- stubgen-pyx==0.2.22
114+
- stubgen-pyx==0.2.23
108115
- Cython==3.2.9
109116

110117
# Link checking for authored documentation files
@@ -155,7 +162,7 @@ repos:
155162
rev: "3e8a8703264a2f4a69428a0aa4dcb512790b2c8c" # frozen: v6.0.0
156163
hooks:
157164
- id: check-added-large-files
158-
exclude: '^(?:cuda_bindings_13/cuda/bindings/nvml\.pyx|cuda_bindings_12/cuda/bindings/(?:driver\.pyx|runtime\.pyx\.in|nvml\.pyx))$'
165+
exclude: '^(?:cuda_bindings_13/cuda/bindings/(?:nvml\.pyx|_v2/driver\.pyx)|cuda_bindings_12/cuda/bindings/(?:driver\.pyx|runtime\.pyx\.in|nvml\.pyx))$'
159166
- id: check-case-conflict
160167
- id: check-docstring-first
161168
- id: check-merge-conflict
@@ -184,7 +191,7 @@ repos:
184191
- id: rst-inline-touching-normal
185192

186193
- repo: https://github.com/pre-commit/mirrors-mypy
187-
rev: 7ff8d35ae36a7d2b968f2f90b4c723e292e594ee # frozen: v2.3.1
194+
rev: 2834ec6639549dd6796205c8f011dedcd587288b # frozen: v2.4.0
188195
hooks:
189196
- id: mypy
190197
alias: mypy-pathfinder
@@ -209,7 +216,7 @@ repos:
209216
exclude: ^\.github/workflows/coverage.yml$
210217

211218
- repo: https://github.com/MarcoGorelli/cython-lint
212-
rev: "eb2f695bb80387913b8cb1f91ba7ff6cb3026715" # frozen: v0.21.1
219+
rev: "35dbc940c2bd4499ebf39aba00ad717e05cec9b5" # frozen: v0.22.0
213220
hooks:
214221
- id: cython-lint
215222
args: [--no-pycodestyle]

‎CONTRIBUTING.md‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Thank you for your interest in contributing to CUDA Python! Based on the type of
2828
- [Enabling git symlinks](#enabling-git-symlinks)
2929
- [Type stubs for cuda.core](#type-stubs-for-cudacore)
3030
- [Pre-commit](#pre-commit)
31+
- [CodeRabbit](#coderabbit)
32+
- [Review Guidance](#review-guidance)
33+
- [Pull Request Reviews](#pull-request-reviews)
3134
- [Pixi lockfiles](#pixi-lockfiles)
3235
- [Signing Your Work](#signing-your-work)
3336
- [Code signing](#code-signing)
@@ -235,6 +238,55 @@ between commits, leaving stale headers or out-of-date stubs in the history.
235238
If the hook isn't installed, `pre-commit run` will print a visible warning
236239
reminding you to run `pre-commit install`.
237240

241+
C, C++ and CUDA sources are formatted with `clang-format` using the
242+
[`.clang-format`](.clang-format) at the repository root, which follows PEP 7
243+
except for a 120-column limit. The
244+
pre-commit hook installs its own pinned `clang-format` (from PyPI) into the
245+
hook environment, so no system-wide installation is required. Vendored code
246+
(for example `dlpack.h` and `cuda_core/third_party/`) is excluded in
247+
`.pre-commit-config.yaml`. To format in your editor, install the same version
248+
with `pip install clang-format==23.1.3`.
249+
250+
## CodeRabbit
251+
252+
This section explains how to use CodeRabbit for CUDA Python pull request review.
253+
For complete product documentation, see the
254+
[CodeRabbit documentation](https://docs.coderabbit.ai/).
255+
256+
### Review Guidance
257+
258+
We treat CodeRabbit feedback as review assistance, not as a merge requirement by
259+
itself. Maintainers remain responsible for deciding whether comments are
260+
actionable and whether a pull request has adequate tests and CI coverage.
261+
262+
### Pull Request Reviews
263+
264+
Automatic reviews may be disabled or restricted by the repository
265+
configuration. PR authors and maintainers can request a review explicitly by
266+
posting a comment on the pull request:
267+
268+
```text
269+
@coderabbitai review
270+
```
271+
272+
Use a full review when the pull request should be reviewed again from scratch:
273+
274+
```text
275+
@coderabbitai full review
276+
```
277+
278+
Other useful commands:
279+
280+
- `@coderabbitai help` shows the current command reference.
281+
- `@coderabbitai configuration` shows the active configuration.
282+
- `@coderabbitai summary` can be placed in the pull request description as a
283+
placeholder for the generated summary.
284+
- `@coderabbitai pause` and `@coderabbitai resume` pause or resume automatic
285+
review behavior. This is useful when a pull request is still being updated
286+
frequently and should not be reviewed again until it is ready.
287+
- `@coderabbitai ignore` can be placed in the pull request description to
288+
disable automatic reviews.
289+
238290
## Pixi lockfiles
239291

240292
The repository checks in a `pixi.lock` next to each `pixi.toml`. Those lockfiles

‎benchmarks/cuda_bindings/benchmarks/cpp/bench_ctx_device.cpp‎

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
#include <cstdlib>
1010
#include <iostream>
1111

12-
13-
static void check_cu(CUresult status, const char* message) {
12+
static void
13+
check_cu(CUresult status, const char *message)
14+
{
1415
if (status != CUDA_SUCCESS) {
15-
const char* error_name = nullptr;
16+
const char *error_name = nullptr;
1617
cuGetErrorName(status, &error_name);
1718
std::cerr << message << ": " << (error_name ? error_name : "unknown") << '\n';
1819
std::exit(1);
1920
}
2021
}
2122

22-
23-
int main(int argc, char** argv) {
23+
int
24+
main(int argc, char **argv)
25+
{
2426
bench::Options options = bench::parse_args(argc, argv);
2527

2628
// Setup: init CUDA and create a context
@@ -45,25 +47,19 @@ int main(int argc, char** argv) {
4547

4648
// --- ctx_set_current ---
4749
{
48-
suite.run("ctx_device.ctx_set_current", [&]() {
49-
check_cu(cuCtxSetCurrent(ctx), "cuCtxSetCurrent failed");
50-
});
50+
suite.run("ctx_device.ctx_set_current", [&]() { check_cu(cuCtxSetCurrent(ctx), "cuCtxSetCurrent failed"); });
5151
}
5252

5353
// --- ctx_get_device ---
5454
{
5555
CUdevice dev;
56-
suite.run("ctx_device.ctx_get_device", [&]() {
57-
check_cu(cuCtxGetDevice(&dev), "cuCtxGetDevice failed");
58-
});
56+
suite.run("ctx_device.ctx_get_device", [&]() { check_cu(cuCtxGetDevice(&dev), "cuCtxGetDevice failed"); });
5957
}
6058

6159
// --- device_get ---
6260
{
6361
CUdevice dev;
64-
suite.run("ctx_device.device_get", [&]() {
65-
check_cu(cuDeviceGet(&dev, 0), "cuDeviceGet failed");
66-
});
62+
suite.run("ctx_device.device_get", [&]() { check_cu(cuDeviceGet(&dev, 0), "cuDeviceGet failed"); });
6763
}
6864

6965
// --- device_get_attribute ---
@@ -80,21 +76,15 @@ int main(int argc, char** argv) {
8076
// --- device_primary_ctx_retain ---
8177
// Outer retain so the benchmarked retain/release pair just bumps the refcount.
8278
CUcontext primary_outer = nullptr;
83-
check_cu(
84-
cuDevicePrimaryCtxRetain(&primary_outer, device),
85-
"cuDevicePrimaryCtxRetain (setup) failed"
86-
);
79+
check_cu(cuDevicePrimaryCtxRetain(&primary_outer, device), "cuDevicePrimaryCtxRetain (setup) failed");
8780
{
8881
CUcontext primary = nullptr;
8982
suite.run("ctx_device.device_primary_ctx_retain", [&]() {
9083
check_cu(cuDevicePrimaryCtxRetain(&primary, device), "cuDevicePrimaryCtxRetain failed");
9184
check_cu(cuDevicePrimaryCtxRelease(device), "cuDevicePrimaryCtxRelease failed");
9285
});
9386
}
94-
check_cu(
95-
cuDevicePrimaryCtxRelease(device),
96-
"cuDevicePrimaryCtxRelease (teardown) failed"
97-
);
87+
check_cu(cuDevicePrimaryCtxRelease(device), "cuDevicePrimaryCtxRelease (teardown) failed");
9888

9989
// Cleanup
10090
check_cu(cuCtxDestroy(ctx), "cuCtxDestroy failed");

‎benchmarks/cuda_bindings/benchmarks/cpp/bench_event.cpp‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
#include <cstdlib>
1010
#include <iostream>
1111

12-
13-
static void check_cu(CUresult status, const char* message) {
12+
static void
13+
check_cu(CUresult status, const char *message)
14+
{
1415
if (status != CUDA_SUCCESS) {
15-
const char* error_name = nullptr;
16+
const char *error_name = nullptr;
1617
cuGetErrorName(status, &error_name);
1718
std::cerr << message << ": " << (error_name ? error_name : "unknown") << '\n';
1819
std::exit(1);
1920
}
2021
}
2122

22-
23-
int main(int argc, char** argv) {
23+
int
24+
main(int argc, char **argv)
25+
{
2426
bench::Options options = bench::parse_args(argc, argv);
2527

2628
// Setup
@@ -47,9 +49,7 @@ int main(int argc, char** argv) {
4749
bench::BenchmarkSuite suite(options);
4850
// Drain the persistent stream after calibration so event_record (which
4951
// enqueues onto the stream) and event_synchronize start from a known state.
50-
suite.set_post_calibrate([&]() {
51-
check_cu(cuStreamSynchronize(stream), "post-calibrate sync failed");
52-
});
52+
suite.set_post_calibrate([&]() { check_cu(cuStreamSynchronize(stream), "post-calibrate sync failed"); });
5353

5454
// --- event_create_destroy ---
5555
{
@@ -62,9 +62,7 @@ int main(int argc, char** argv) {
6262

6363
// --- event_record ---
6464
{
65-
suite.run("event.event_record", [&]() {
66-
check_cu(cuEventRecord(event, stream), "cuEventRecord failed");
67-
});
65+
suite.run("event.event_record", [&]() { check_cu(cuEventRecord(event, stream), "cuEventRecord failed"); });
6866
}
6967

7068
// Re-sync so event is in a known completed state after the record benchmark

0 commit comments

Comments
 (0)