Skip to content

Bump Cython to >=3.3,<3.4 - #2771

Open
juenglin wants to merge 1 commit into
NVIDIA:mainfrom
juenglin:cython-3.3-upgrade
Open

Bump Cython to >=3.3,<3.4#2771
juenglin wants to merge 1 commit into
NVIDIA:mainfrom
juenglin:cython-3.3-upgrade

Conversation

@juenglin

@juenglin juenglin commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

Bumps the Cython build/test pin from >=3.2.5,<3.3 to >=3.3,<3.4 across cuda_bindings, cuda_core, cuda_pathfinder, and docs environment files.

No motivating issue -- routine dependency upgrade.

Motivation

  • Python 3.15 support path: Cython 3.3 adapts to 3.15 and its Limited API; our test dependency groups already carry python_version < '3.15' guards to be removed once 3.15 is officially supported.
  • Free-threading improvements: critical sections on auto-generated functions, prange/parallel() without releasing the GIL, pymutex.locked().
  • Runtime performance improvements in generated code: faster memoryview indexing/slicing, vectorcall-based extension type instantiation.

Required code changes

Cython 3.3 added a new critical_section misuse warning (cython/cython#6766), promoted to a build error by our warning_errors=True builds. It flagged three real patterns in cuda_core:

  • cuda/core/_memory/_buffer.pyx, cuda/core/_memoryview.pyx: narrowed @cython.critical_section coverage to only the cdef-attribute check-and-set; Python-level construction/reads now happen outside the lock, since the lock never actually protected them (see cython/cython#7324 for upstream discussion of this exact limitation).
  • cuda/core/_device_resources.pyx: WorkqueueResourceOptions now uses @dataclass(init=False) with a hand-written __init__, because Cython 3.3 unconditionally wraps dataclass-generated __init__ in a critical section and then warns about its own generated call to __post_init__.

Two cuda_bindings tests (test_eglFrame, test_cudart_eglFrame) were updated to pass CUarray/cudaArray_t objects instead of raw ints, because Cython 3.3 now enforces declared container item types (list[CUarray]) at runtime. The setter's type annotation comes from generated code; the code generator may want to revisit it separately.

Build times

Clean full-rebuild times (cache disabled, median of 3 runs) are essentially unchanged between Cython 3.2.9 and 3.3.0 for both cuda_bindings and cuda_core on this hardware.

Test parity

Identical results before/after on a local GPU (CUDA 13.2):

  • cuda_bindings: 552 passed / 26 skipped (+ 9 passed in tests/cython)
  • cuda_core: 3977 passed / 237 skipped / 4 xfailed (+ 1 passed in tests/cython)

Known follow-up (out of scope here)

Relocking pixi.lock for cuda_bindings/cuda_core to reflect the new Cython pin incidentally triggers a full re-solve of the unconstrained default environment, which also bumps its CUDA toolchain from 12.9 to 13.3 (pre-existing lock drift relative to ci/versions.yml, unrelated to Cython). That drift and its long-term fix are tracked separately in #2770; pixi.lock files are intentionally left untouched in this PR.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module cuda.pathfinder Everything related to the cuda.pathfinder module labels Sep 4, 2026
@juenglin juenglin added this to the cuda.bindings next milestone Sep 4, 2026
@juenglin juenglin added dependencies Pull requests that update a dependency file and removed cuda.pathfinder Everything related to the cuda.pathfinder module labels Sep 4, 2026
@juenglin juenglin self-assigned this Sep 4, 2026
@juenglin
juenglin requested a review from mdboom September 4, 2026 21:08
@juenglin juenglin added the P1 Medium priority - Should do label Sep 4, 2026
@juenglin

juenglin commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 6f24210

@juenglin
juenglin marked this pull request as ready for review September 4, 2026 21:26
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module dependencies Pull requests that update a dependency file P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant