Port to Cython 3.0#8457
Conversation
46ba61c to
6b381f3
Compare
|
Thanks for your help!
My suggestion is to use the compiler flag added in cython/cython#6243 to silence the build-time warning for the time being. IIRC (though I can't find the thread where this was discussed...) we wanted to investigate some lightweight codegen to address this, but I dunno if it'd be prioritized any time soon. The deprecation of |
It seems the flag has not made it to the 3.0.x releases... |
|
I meet an issue after upgrading to cython3: |
It is caused by |
|
Turns out Line 36 in af5e961 cdef public externc to generate extern "C";cdef public externc, so I will try just use extern "C++" in cupy_thrust.cu
|
6b381f3 to
2d57e83
Compare
Reference: cupy#8457 (comment) Signed-off-by: Yiyang Wu <[email protected]>
Reference: cupy#8457 (comment) Signed-off-by: Yiyang Wu <[email protected]>
2d57e83 to
084261e
Compare
|
MEMO: Encountering many performance warnings like this:
cpdef intptr_t ctxGetCurrent() except? 0:
initialize()
cdef Context ctx
with nogil:
status = cuCtxGetCurrent(&ctx) # <- HERE!
check_status(status)
return <intptr_t>ctx |
It seems invocations of function pointers (assigned to variables) are emitting this warning. I'm curious if anything has changed in Cython 3.0, or there was a slient overhead even in Cython 0.29. Can you check with this @EarlMilktea? |
|
Fortunately it seems that we can easily resolve most of the warnings by just replacing
(Check EarlMilktea@3c1a3bd for more details). Of course we should check this replacement is valid, but I feel it's OK as these files just wrap the low-level CUDA APIs, which are also available in C codes... |
|
This pull request is now in conflicts. Could you fix it @littlewu2508? 🙏 |
084261e to
e261596
Compare
Reference: cupy#8457 (comment) Signed-off-by: Yiyang Wu <[email protected]>
cupy/_core/_kernel.pyx:1159:24: '__module__' redeclared Fixed by removing "readonly object __module__" cupy/_core/dlpack.pyx:152:25: Cannot assign type 'void (DLManagedTensor *) except * nogil' to 'void (*)(DLManagedTensor *) noexcept'. Exception values are incompatible. Suggest adding 'noexcept' to the type of 'deleter'. cupy/_core/dlpack.pyx:154:57: Cannot assign type 'void (object) except *' to 'PyCapsule_Destructor' (alias of 'void (*)(object) noexcept'). Exception values are incompatible. Suggest adding 'noexcept' to the type of 'pycapsule_deleter'. Fixed by adding noexcept to those functions Closes: cupy#4610 Signed-off-by: Yiyang Wu <[email protected]>
Compatible with Cython-0.x Bug: cupy#5893 Signed-off-by: Yiyang Wu <[email protected]>
Reference: cupy#8457 (comment) Signed-off-by: Yiyang Wu <[email protected]>
e261596 to
8bf3964
Compare
|
FYI @kmaehashi we noticed (conda-forge/cupy-feedstock#295 (comment)) that this PR blocks the Python 3.13 support (#8651) even for the regular (with-GIL) builds, because Cython 0.29.x simply has no wheel or conda package released for 3.13. |
`if module['name'] == 'numpy_allocator':` pass was never used
Due to cupy/cupy#8457 can't be easily backported to an ancient commit, change cupy codebase to v13 tree.
|
/test mini |
|
Here is a quote of the commit 8c41181 + Cython 0.29.37:commit 8c41181 + 6db06e4 (this PR) + Cython 3.0.12: |
|
I think we need to add two Cython compiler directives.
After adding these two options, I get the performance close to the current main branch: |
This comment was marked as outdated.
This comment was marked as outdated.
|
/test mini |
|
@kmaehashi Failed to backport automatically. |
|
Tests passed, merging! Thanks again, @littlewu2508 and @EarlMilktea! |
|
I'll take care of backport after merging #8951 |
|
Wow! This is fantastic 🤩 Thank you all for your hard work on Cython 3 compatibility 👏 |
Port to Cython 3.0
Port to Cython 3.0
Port to Cython 3.0
These should be the necessary changes for Cython-3:
special binary operatorset to True.I applied these 2 patches on top of #8319, and built cupy-13.2.0 on ROCm 6. My cupy application run without errors.
I also observed one deprecation warning regarding Cython, which is currently not a blocker but may become one in the future: