Fix #1169: correct NumPy skip conditions for DLPack host writes#2238
Conversation
Writing into a host-accessible array obtained via np.from_dlpack requires NumPy 2.2.5+, because earlier versions return a read-only array (numpy GH #28632). Several tests and examples guarded these writes at NumPy 2.1.0, so on NumPy 2.1.0-2.2.4 they would error instead of skip. Audit all NumPy version guards in cuda_core and bump the write-into-DLPack sites to 2.2.5 with a consistent reason matching the existing correct guard in test_launcher.py. Guards that only read DLPack arrays (e.g. strided_memory_view_constructors.py) or skip for an unrelated NumPy fix (test_utils.py, numpy#26501) are left at 2.1. Also fix examples/memory_ops.py, which used a plain string comparison (np.__version__ < "2.1.0") that is unreliable for multi-digit versions; replace it with np.lib.NumpyVersion to match the other examples, and standardize test_graph_builder.py off a hand-rolled tuple skipif onto requires_module. Update affected PEP 723 dependency pins to numpy>=2.2.5. Signed-off-by: Arsalan Shakil <shakil.arsalan@yahoo.com>
seberg
left a comment
There was a problem hiding this comment.
Thanks, straight forward and looks right. (Comments may be a bit unnecessarily long, but OK.)
|
/ok to test 4a07cb1 |
|
Sorry missed that scrolling through the diff: can you resolve the merge conflict? |
This comment has been minimized.
This comment has been minimized.
|
I will solve the merge conflicts soon, I am away on vacation will be back next end of next week |
|
Merge conflict with |
…ck-skip-conditions # Conflicts: # cuda_core/tests/graph/test_graph_builder.py
9aba315 to
f8ba7d9
Compare
|
/ok to test f8ba7d9 |
|
/ok to test f8ba7d9 |
|
The 3 red checks on
This PR's own tests passed. A re-run of the two failed jobs should go green — could you kick one off when convenient? Thanks! |
This comment has been minimized.
This comment has been minimized.
1 similar comment
|
What
Audit and fix the NumPy version skip/guard conditions across
cuda_core, per #1169.Why
Writing into a host-accessible array obtained via
np.from_dlpack(...)requires NumPy 2.2.5+: earlier versions return a read-only array (numpy GH #28632), so the write raisesValueError: assignment destination is read-only. Several tests and examples guarded these writes at NumPy2.1.0, which only covers basic DLPack support. On NumPy2.1.0–2.2.4those tests/examples would error instead of skip — exactly the situation #1169 (and parent epic #1168) flagged.Changes
Classification rule applied to every NumPy guard: writes into a
np.from_dlpackhost array → require 2.2.5; read-only DLPack usage → 2.1 is sufficient.Bumped to
2.2.5(with a consistentreason="need numpy 2.2.5+ (numpy GH #28632)", matching the already-correct guard intest_launcher.py):memory_ops.py,graph_update.py,memory_pool_resources.py(all write to pinned/managed DLPack arrays)test_launcher.py(2 sites),test_graph_builder.py(2 sites),test_graph_update.py(2),test_device_launch.py(2),test_graph_definition_mutation.py(2),test_graph_builder_conditional.py(4)Additional cleanups:
examples/memory_ops.pyused a plain string comparisonnp.__version__ < "2.1.0", which is unreliable for multi-digit versions (e.g."2.9" > "2.10"lexicographically). Replaced withnp.lib.NumpyVersion, consistent with the other examples.test_graph_builder.pyhad a hand-rolledtuple(int(i) ...)skipif (also brittle for pre-release versions). Standardized onto the sharedrequires_modulemark.numpy>=2.2.5.Intentionally left at
2.1:examples/strided_memory_view_constructors.py— only reads DLPack arrays.test_utils.py:129— guards an unrelated NumPy readonly-input fix (numpy#26501), not the DLPack write issue.Testing
All edited files compile. The changes are version-guard logic only (no behavior change for supported NumPy); the GPU test suite runs in CI.
Closes #1169