cuda-python icon indicating copy to clipboard operation
cuda-python copied to clipboard

cuda.bindings: make cythonization warnings clean

Open juenglin opened this issue 4 months ago • 5 comments

A recent PR added -Werror to the cythonization step in cuda.core. This fails a build when cython warns about code issues (see the mentioned PR for examples).

We want to add the -Werror flag to the cythonization step in cuda.bindings as well but first need to work on the cybind bindings generator for it to produce warnings-free cython code.

juenglin avatar Jul 29 '26 16:07 juenglin

Working on this in a PR.

Inventory (local Cythonize of cuda.bindings with warning_errors=True against CTK headers from pip wheels):

  1. cudla.pxd / cudla.pyx — noexcept clause is ignored for function returning Python object on device_get_attribute / module_get_attributes (except * on Python-returning cpdefs)
  2. _lib/windll.pxd — Assignment in pxd file will not be executed for LOAD_LIBRARY_SEARCH_SYSTEM32

Fix (see upcoming PR):

  • Remove ignored except * on those cudla cpdefs (resealed)
  • Declare the Win32 flag as const DWORD (hand-written _lib)
  • Enable _CythonOptions.warning_errors = True in cuda_bindings/build_hooks.py
  • Add source-level regression tests

Note for cybind: the cudla emitter should stop attaching exception clauses to cpdefs that return Python objects, so the next sync does not reintroduce warning (1).

atiaomar1978-hub avatar Jul 31 '26 04:07 atiaomar1978-hub

PR opened: https://github.com/NVIDIA/cuda-python/pull/2463

atiaomar1978-hub avatar Jul 31 '26 04:07 atiaomar1978-hub

Hi maintainers — I've opened a fix for this in https://github.com/NVIDIA/cuda-python/pull/2463 and would like to continue owning the follow-through (review feedback, cybind sync note, CI).

Could you please assign this issue to me (@atiaomar1978-hub)? Happy to adjust the PR based on your guidance.

atiaomar1978-hub avatar Jul 31 '26 15:07 atiaomar1978-hub

Follow-up: the fix PR is ready at https://github.com/NVIDIA/cuda-python/pull/2463 (still awaiting CPR vetting + review).

Could a maintainer please assign this issue to me (@atiaomar1978-hub)? I’ll keep owning review feedback and any follow-ups. cc @juenglin

atiaomar1978-hub avatar Aug 04 '26 18:08 atiaomar1978-hub

Hi @juenglin,

Thank you for assigning this issue to me, and for the helpful guidance on coordinating with the cybind generator work.

I've prepared a PR for this: https://github.com/NVIDIA/cuda-python/pull/2463

Whenever you have time, I'd really appreciate a review (and assigning yourself as reviewer if that's helpful). I'm happy to make any changes you suggest.

Thanks again for your support.

atiaomar1978-hub avatar Aug 11 '26 03:08 atiaomar1978-hub