Repository navigation
Bump Cython to >=3.3,<3.4 - #2771
Conversation
|
/ok to test 6f24210 |
|
mdboom
left a comment
There was a problem hiding this comment.
From the description:
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.
This is related to some dependencies having not released 3.15 support or wheels yet (at the time we started Python 3.15 support). Seems totally unrelated to this PR, but we should file separate PRs to check the status of those dependencies and see if they support Python 3.15 now.
Free-threading improvements: critical sections on auto-generated functions, prange/parallel() without releasing the GIL, pymutex.locked().
These are Cython improvements? They don't seem to be related to this PR or be relevant to us since we don't use those features.
|
We should do a benchmark run on this and make sure there are no major regressions as well. |
Good call. I ran the benchmark and it showed a regression, so we will need to work that out first. I will dig into it on the side. |
The comment said only that build_hooks.py uses Cython 3.2.x. Upstream's own move to 3.3 (NVIDIA/cuda-python#2771) is still open over a benchmark regression, and 3.3 changes runtime type checks, so the cap stays and the comment now says why. Comment only; 13.5.0 is not yet pushed.
Bump the remaining Cython pins (build dependency groups added on main, cuda_bindings_12, and the cython-lint pre-commit hook) and raise the floor to 3.3.1. The stubgen-pyx hook stays on Cython 3.2.9 because stubgen-pyx 0.2.23 requires Cython<3.3. Update the cuda_bindings_12 eglFrame tests the same way as cuda_bindings_13: Cython 3.3 enforces the generated list[CUarray] / list[cudaArray_t] setter annotations at runtime.
6f24210 to
532e44c
Compare
There no longer is a performance regression thanks to #2904. |
Generated with `pixi update --no-install cython` using the CI-pinned Pixi v0.82.1, so the only package change is cython 3.2.9 -> 3.3.1. cuda_bindings_12 also drops a few orphaned package records that no environment referenced.
|
/ok to test 79ecfe4 |
Cython 3.3 enforces declared list item types at runtime. The pArray setters on CUeglFrame.frame and cudaEglFrame.frame were annotated as list[CUarray] / list[cudaArray_t], so passing plain ints raised TypeError. The fix is a generator change (cybind !621, cython_gen): widen the annotation to list[CUarray | int] / list[cudaArray_t | int]. The setter body already converts each element with int() before casting, so accepting plain ints was always safe; the annotation was just narrower than the implementation. Generated files updated from cybind branch accept-int-handle-arrays (da353763) against CTK 12.9 (cuda_bindings_12) and 13.5 (cuda_bindings_13). Seals recomputed. Test workarounds that wrapped plain ints in handle objects are reverted to their original plain-int form.
|
/ok to test 64feee6 |
mdboom
left a comment
There was a problem hiding this comment.
Did you fully regenerate the files? I would have expected all of the changes from #3410 as well.
I worry that if the agent just hand-wrote these updates instead they may get clobbered by the next generation update.
I think we should merge #3410, and then fully regenerate this (and maybe hold of on the 12.9.x updates for now).
|
No actionable comments were generated in the recent review. Summary
Change: Other Merge Risk:
|
No, I regenerated the driver and runtime files only. |
# Conflicts: # cuda_bindings_12/cuda/bindings/driver.pyx # cuda_bindings_12/cuda/bindings/runtime.pyx # cuda_bindings_12/pixi.toml # cuda_bindings_12/pyproject.toml # cuda_bindings_13/cuda/bindings/driver.pyx # cuda_bindings_13/cuda/bindings/runtime.pyx # cuda_bindings_13/pixi.lock # cuda_bindings_13/pyproject.toml # cuda_core/pyproject.toml
|
/ok to test 44b5d59 |
|
/ok to test b3f6187 |
Description
Bumps the Cython build/test pin from
>=3.2.5,<3.3to>=3.3.1,<3.4acrosscuda_bindings_12,cuda_bindings_13,cuda_core,cuda_pathfinder, the docs environment files, and thecython-lintpre-commit hook. The minimum stays at 3.3.1; thecuda_bindings_12/cuda_bindings_13pixi lock files and thecython-linthook resolve Cython 3.3.2.No motivating issue -- routine dependency upgrade to stay on a supported Cython release line.
Why 3.3.1 rather than 3.3.0
Cython 3.3.1 is mostly a fix release for 3.3.0 regressions, several of which generated incorrect C code (e.g. cython/cython#7991, #7937, #7907). It also fixes Cython file-cache problems that affect our cached builds: concurrent processes deleting each other's cache files (#7983, #7985, #8090) and a cache key that ignored compiler directives (#7532).
Required code changes
Cython 3.3 added a new
critical_sectionmisuse warning (cython/cython#6766), promoted to a build error by ourwarning_errors=Truebuilds. It flags three patterns incuda_core; all still fire with 3.3.1:cuda/core/_memory/_buffer.pyx,cuda/core/_memoryview.pyx: narrowedcython.critical_sectioncoverage to only thecdef-attribute check-and-set; Python-level construction/reads now happen outside the lock, since the lock never actually protected them (see cython/cython#7324).cuda/core/_device_resources.pyx:WorkqueueResourceOptionsnow uses@dataclass(init=False)with a hand-written__init__, because Cython 3.3 wraps the dataclass-generated__init__in a critical section and then warns about its own generated call to__post_init__.Cython 3.3 also enforces declared container item types at runtime. The generated
pArraysetters ofCUeglFrame/cudaEglFramewere annotatedlist[CUarray]/list[cudaArray_t], so assigning a list of plain ints raisedTypeError.mainnow carries the generator fix that widens the annotation tolist[CUarray | int]/list[cudaArray_t | int], so the generated bindings are identical tomainand thetest_eglFrame/test_cudart_eglFrametests are unchanged and pass with plain ints.The
stubgen-pyxpre-commit hook stays on Cython 3.2.9 becausestubgen-pyx0.2.23 requiresCython<3.3.pixi lock files
The
cuda_bindings_12andcuda_bindings_13lock files resolve Cython 3.3.2 (3.3.1 is the minimum allowed by the pins). Conflicts withmainin the lock files were resolved by regenerating them with Pixi 0.83.0.cuda_coreandcuda_pathfinderlock files still resolve Cython 3.3.1, which satisfies the pins.Performance
The launch-path slowdown observed with Cython 3.3.0 earlier in this PR's history no longer reproduces: the hot loop in
_HelperKernelParamswas rewritten by #2904, so the 3.3.0 codegen changes that caused it are no longer on that path. Same sources, only the Cython version changed (pinned P-core,performancegovernor, 12 interleaved rounds, gcc 13.3), ratio vs. 3.2.9 (min):_HelperKernelParams, 512c_intargslaunch_256_argslaunch_512_argsbench_launchcasesRe-measured for Cython 3.3.2 on the current branch (merged with
main): the samecuda_bindings_13sources built three times with Cython 3.2.9, 3.3.1 and 3.3.2 (CUDA 13.5 headers, Python 3.12, gcc 13.3), repobench_launch.pyfunctions plus a direct timing of_HelperKernelParamswith 512c_intargs, fresh process per measurement pinned to one P-core, 12 interleaved rounds. The CPU governor waspowersavefor this run, notperformance. Ratio of the min:_HelperKernelParams, 512c_intargslaunch_256_argslaunch_512_argsbench_launchcasesCython 3.3.2 is indistinguishable from 3.3.1 on these benchmarks (all 3.3.2 / 3.3.1 ratios within 0.5%), and neither shows a slowdown relative to 3.2.9.
Testing
Local GPU (RTX 6000 Ada), clean builds in fresh virtual environments with Cython 3.3.2, after merging
main:cuda_bindings_13(CUDA 13.5): 770 passed / 38 skippedcuda_bindings_12(CUDA 12.9): 399 passed / 37 skipped / 9 failed. The same 9 tests fail onmainwith Cython 3.2.9 (8sm_60cases intest_nvjitlink.pywithERROR_UNSUPPORTED_ARCHandtest_cufile.py::test_set_get_parameter_bool), so they are not caused by this change.Earlier results with Cython 3.3.1, before merging
main(cuda_corewas not re-run on 3.3.2):cuda_bindings_13(cu13): 779 passed / 38 skippedcuda_bindings_12(cu12): 416 passed / 38 skippedcuda_core(cu13): 4191 passed / 337 skipped / 4 xfailedChecklist