Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cuda_core/examples/graph_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# ################################################################################

# /// script
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "numpy>=2.1"]
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "numpy>=2.2.5"]
# ///

import sys
Expand Down Expand Up @@ -44,8 +44,11 @@ def build_increment_graph(device, kernel, target_ptr):


def main():
if np.lib.NumpyVersion(np.__version__) < "2.1.0":
print("This example requires NumPy 2.1.0 or later", file=sys.stderr)
# Writing into the pinned host array imported via DLPack requires NumPy
# 2.2.5+ (np.from_dlpack returns a read-only array on earlier versions;
# see numpy GH #28632).
if np.lib.NumpyVersion(np.__version__) < "2.2.5":
print("This example requires NumPy 2.2.5 or later", file=sys.stderr)
sys.exit(1)

device = Device()
Expand Down
11 changes: 6 additions & 5 deletions cuda_core/examples/memory_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
# ################################################################################
#
# This example demonstrates memory resources for allocation and management,
# copying data between device and pinned memory, and DLPack interop. Requires
# NumPy 2.1.0+.
# copying data between device and pinned memory, and DLPack interop. Writing
# into the pinned host array imported via DLPack requires NumPy 2.2.5+ (arrays
# from np.from_dlpack are read-only on earlier versions; see numpy GH #28632).
#
# ################################################################################

# /// script
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "cupy-cuda13x"]
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "cupy-cuda13x", "numpy>=2.2.5"]
# ///

import sys
Expand Down Expand Up @@ -47,8 +48,8 @@


def main():
if np.__version__ < "2.1.0":
print("This example requires NumPy 2.1.0 or later", file=sys.stderr)
if np.lib.NumpyVersion(np.__version__) < "2.2.5":
print("This example requires NumPy 2.2.5 or later", file=sys.stderr)
sys.exit(1)

dev = Device()
Expand Down
9 changes: 6 additions & 3 deletions cuda_core/examples/memory_pool_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# ################################################################################

# /// script
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "numpy>=2.1"]
# dependencies = ["cuda_bindings", "cuda_core", "nvidia-cuda-nvrtc", "numpy>=2.2.5"]
# ///

import sys
Expand Down Expand Up @@ -43,8 +43,11 @@


def main():
if np.lib.NumpyVersion(np.__version__) < "2.1.0":
print("This example requires NumPy 2.1.0 or later", file=sys.stderr)
# Writing into the managed/pinned host arrays imported via DLPack requires
# NumPy 2.2.5+ (np.from_dlpack returns a read-only array on earlier
# versions; see numpy GH #28632).
if np.lib.NumpyVersion(np.__version__) < "2.2.5":
print("This example requires NumPy 2.2.5 or later", file=sys.stderr)
sys.exit(1)

device = Device()
Expand Down
4 changes: 2 additions & 2 deletions cuda_core/tests/graph/test_device_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _compile_device_launcher_kernel():
Device().compute_capability.major < 9,
reason="Device-side graph launch requires Hopper (sm_90+) architecture",
)
@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_device_launch_basic(init_cuda):
"""Test basic device-side graph launch functionality.

Expand Down Expand Up @@ -128,7 +128,7 @@ def test_device_launch_basic(init_cuda):
Device().compute_capability.major < 9,
reason="Device-side graph launch requires Hopper (sm_90+) architecture",
)
@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_device_launch_multiple(init_cuda):
"""Test that device-side graph launch can be executed multiple times.

Expand Down
4 changes: 2 additions & 2 deletions cuda_core/tests/graph/test_graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_graph_is_join_required(init_cuda):
gb.end_building().complete()


@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_graph_repeat_capture(init_cuda):
mod = compile_common_kernels()
add_one = mod.get_kernel("add_one")
Expand Down Expand Up @@ -209,7 +209,7 @@ def read_byte(data):
assert result[0] == 0xAB


@pytest.mark.skipif(tuple(int(i) for i in np.__version__.split(".")[:2]) < (2, 1), reason="need numpy 2.1.0+")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_graph_child_graph(init_cuda):
mod = compile_common_kernels()
add_one = mod.get_kernel("add_one")
Expand Down
8 changes: 4 additions & 4 deletions cuda_core/tests/graph/test_graph_builder_conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@pytest.mark.parametrize(
"condition_value", [True, False, ctypes.c_bool(True), ctypes.c_bool(False), np.bool_(True), np.bool_(False), 1, 0]
)
@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_graph_conditional_if(init_cuda, condition_value):
mod = compile_conditional_kernels(type(condition_value))
add_one = mod.get_kernel("add_one")
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_graph_conditional_if(init_cuda, condition_value):
@pytest.mark.parametrize(
"condition_value", [True, False, ctypes.c_bool(True), ctypes.c_bool(False), np.bool_(True), np.bool_(False), 1, 0]
)
@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_graph_conditional_if_else(init_cuda, condition_value):
mod = compile_conditional_kernels(type(condition_value))
add_one = mod.get_kernel("add_one")
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_graph_conditional_if_else(init_cuda, condition_value):


@pytest.mark.parametrize("condition_value", [0, 1, 2, 3])
@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_graph_conditional_switch(init_cuda, condition_value):
mod = compile_conditional_kernels(type(condition_value))
add_one = mod.get_kernel("add_one")
Expand Down Expand Up @@ -244,7 +244,7 @@ def test_graph_conditional_switch(init_cuda, condition_value):


@pytest.mark.parametrize("condition_value", [True, False, 1, 0])
@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_graph_conditional_while(init_cuda, condition_value):
mod = compile_conditional_kernels(type(condition_value))
add_one = mod.get_kernel("add_one")
Expand Down
4 changes: 2 additions & 2 deletions cuda_core/tests/graph/test_graph_definition_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def close(self):
self._buf.close()


@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
class TestMutateYRig:
"""Tests that mutate the Y-shaped graph built by YRig."""

Expand Down Expand Up @@ -335,7 +335,7 @@ def test_self_edge(init_cuda):
node.succ.add(node)


@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_convert_linear_to_fan_in(init_cuda):
"""Chain four computations sequentially, then rewire so all pairs run in
parallel feeding into a reduce node.
Expand Down
4 changes: 2 additions & 2 deletions cuda_core/tests/graph/test_graph_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@pytest.mark.parametrize("builder", ["GraphBuilder", "GraphDefinition"])
@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_graph_update_kernel_args(init_cuda, builder):
"""Update redirects a kernel to write to a different pointer."""
mod = compile_common_kernels()
Expand Down Expand Up @@ -60,7 +60,7 @@ def build(ptr):
b.close()


@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_graph_update_conditional(init_cuda):
"""Update swaps conditional switch graphs with matching topology."""
mod = compile_conditional_kernels(int)
Expand Down
4 changes: 2 additions & 2 deletions cuda_core/tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_launch_invalid_values(init_cuda):


@pytest.mark.parametrize("python_type, cpp_type, init_value", PARAMS)
@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
def test_launch_scalar_argument(python_type, cpp_type, init_value):
dev = Device()
dev.set_current()
Expand Down Expand Up @@ -536,7 +536,7 @@ class MyBool(ctypes.c_bool):
assert holder.ptr != 0


@requires_module(np, "2.1")
@requires_module(np, "2.2.5", reason="need numpy 2.2.5+ (numpy GH #28632)")
@pytest.mark.parametrize(
("scalar_kind", "np_dtype", "cpp_type", "raw_value"),
[
Expand Down
Loading