Skip to content

Commit 9365d0e

Browse files
committed
simplify tests
1 parent 7c035f8 commit 9365d0e

5 files changed

Lines changed: 9 additions & 87 deletions

File tree

‎cuda_core/cuda/core/_memory/_copy_ops.pyi‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ from cuda.core._stream import Stream
1010

1111
_SINGLE_COPY_HINT = 'Buffer.copy_to / Buffer.copy_from'
1212

13-
def _batch_entry_point_in_use() -> bool:
14-
"""Internal: expose the dispatch predicate so tests can gate on it."""
15-
1613
def _normalize_copy_options(options: CopyOptions | Sequence[CopyOptions] | None, n: int) -> tuple[CopyOptions, ...]:
1714
"""Expand ``options`` to exactly one :class:`CopyOptions` per copy.
1815

‎cuda_core/cuda/core/_memory/_copy_ops.pyx‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ cdef inline bint _batch_entry_point_available():
5050
return False
5151

5252

53-
def _batch_entry_point_in_use() -> bool:
54-
"""Internal: expose the dispatch predicate so tests can gate on it."""
55-
return bool(_batch_entry_point_available())
56-
57-
5853
def _normalize_copy_options(
5954
options: CopyOptions | Sequence[CopyOptions] | None,
6055
Py_ssize_t n,

‎cuda_core/tests/example_tests/test_basic_examples.py‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,9 @@ def has_recent_memory_pool_support() -> bool:
7474
# Specific system requirements for each of the examples.
7575

7676

77-
def has_copy_batch_support() -> bool:
78-
"""Check if cuMemcpyBatchAsync is available (CUDA 13+)."""
79-
from cuda.core._memory._copy_ops import (
80-
_batch_entry_point_in_use as cu_memcpy_batch_available,
81-
)
82-
83-
return cu_memcpy_batch_available()
84-
85-
8677
SYSTEM_REQUIREMENTS = {
8778
"memory_pool_resources.py": has_recent_memory_pool_support,
88-
"batched_memcpy.py": lambda: has_copy_batch_support() and has_recent_memory_pool_support(),
79+
"batched_memcpy.py": has_recent_memory_pool_support,
8980
"gl_interop_plasma.py": has_display,
9081
"gl_interop_fluid.py": has_display,
9182
"gl_interop_mipmap_lod.py": has_display,

‎cuda_core/tests/memory/conftest.py‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from helpers.copy_batch import COPY_BATCH_COUNT, COPY_BATCH_SIZE
1313

1414
from cuda.core import Device, LegacyPinnedMemoryResource
15-
from cuda.core._memory._copy_ops import _batch_entry_point_in_use
1615

1716

1817
@pytest.fixture
@@ -23,21 +22,6 @@ def copy_batch_device(init_cuda):
2322
return device
2423

2524

26-
@pytest.fixture
27-
def requires_copy_options():
28-
"""Skip when ``CopyOptions`` cannot reach the driver.
29-
30-
Options travel only through ``cuMemcpyBatchAsync``. Where that is
31-
unavailable, ``copy_batch`` falls back to per-copy ``cuMemcpyAsync``
32-
which silently ignores them.
33-
"""
34-
if not _batch_entry_point_in_use():
35-
pytest.skip(
36-
"non-default CopyOptions requires cuda.core built against CUDA 13, "
37-
"cuda.bindings 13.0+, and a driver reporting CUDA 13.0 or newer"
38-
)
39-
40-
4125
@pytest.fixture
4226
def copy_stream(copy_batch_device):
4327
"""The single stream used for both allocation and copies in a test.

‎cuda_core/tests/memory/test_copy_batch_options.py‎

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
assert_managed_holds,
2020
)
2121

22-
from cuda.core import Device, Host, LegacyPinnedMemoryResource
22+
from cuda.core import Host, LegacyPinnedMemoryResource
2323
from cuda.core._memory._copy_enums import _attr_run_starts
24-
from cuda.core._memory._copy_ops import (
25-
_batch_entry_point_in_use as cu_memcpy_batch_available,
26-
)
2724
from cuda.core._memory._copy_ops import (
2825
_normalize_copy_options,
2926
)
@@ -110,7 +107,7 @@ class TestCopyBatchOptions:
110107
(MemcpySrcAccessOrder.ANY, 33),
111108
],
112109
)
113-
def test_src_access_order(self, requires_copy_options, h2d_bufs, copy_stream, order, marker):
110+
def test_src_access_order(self, h2d_bufs, copy_stream, order, marker):
114111
srcs, dsts = h2d_bufs
115112
for i, src in enumerate(srcs):
116113
set_buffer(src, i + marker)
@@ -122,7 +119,7 @@ def test_src_access_order(self, requires_copy_options, h2d_bufs, copy_stream, or
122119
assert compare_buffer_to_constant(dst, i + marker)
123120

124121
@pytest.mark.agent_authored(model="Claude Opus 5")
125-
def test_per_copy_options(self, requires_copy_options, h2d_bufs, copy_stream):
122+
def test_per_copy_options(self, h2d_bufs, copy_stream):
126123
srcs, dsts = h2d_bufs
127124
for i, src in enumerate(srcs):
128125
set_buffer(src, i + 40)
@@ -142,7 +139,7 @@ def test_per_copy_options(self, requires_copy_options, h2d_bufs, copy_stream):
142139
assert compare_buffer_to_constant(dst, i + 40)
143140

144141
@pytest.mark.agent_authored(model="Claude Opus 5")
145-
def test_location_hints_do_not_corrupt_copy(self, requires_copy_options, copy_batch_device, copy_stream):
142+
def test_location_hints_do_not_corrupt_copy(self, copy_batch_device, copy_stream):
146143
"""Device and host hints are accepted and leave the bytes intact.
147144
148145
Hints only steer how the driver stages a transfer, so no data
@@ -176,13 +173,8 @@ def test_location_hints_do_not_corrupt_copy(self, requires_copy_options, copy_ba
176173
mr.close()
177174

178175
@pytest.mark.agent_authored(model="Claude Sonnet 4.6")
179-
def test_host_numa_location_hint(self, requires_copy_options, copy_batch_device, copy_stream):
180-
"""A NUMA-specific host hint is accepted and does not corrupt the copy.
181-
182-
``requires_copy_options`` already implies CUDA 13, where
183-
``Host(numa_id=...)`` is representable; the CUDA 12 rejection is
184-
covered by ``_coerce_location``'s own tests.
185-
"""
176+
def test_host_numa_location_hint(self, copy_batch_device, copy_stream):
177+
"""A NUMA-specific host hint is accepted and does not corrupt the copy."""
186178
dev = copy_batch_device
187179
numa_id = dev.properties.host_numa_id
188180
if numa_id < 0:
@@ -204,7 +196,7 @@ def test_host_numa_location_hint(self, requires_copy_options, copy_batch_device,
204196
mr.close()
205197

206198
@pytest.mark.agent_authored(model="Claude Sonnet 4.6")
207-
def test_host_numa_current_location_hint(self, requires_copy_options, copy_batch_device, copy_stream):
199+
def test_host_numa_current_location_hint(self, copy_batch_device, copy_stream):
208200
"""Host.numa_current() as a location hint is accepted and does not corrupt the copy."""
209201
dev = copy_batch_device
210202
if dev.properties.host_numa_id < 0:
@@ -226,7 +218,7 @@ def test_host_numa_current_location_hint(self, requires_copy_options, copy_batch
226218
mr.close()
227219

228220
@pytest.mark.agent_authored(model="Claude Opus 5")
229-
def test_overlap_mode_copies_correctly(self, requires_copy_options, h2d_bufs, copy_stream):
221+
def test_overlap_mode_copies_correctly(self, h2d_bufs, copy_stream):
230222
"""The overlap hint is advisory and must not change the bytes copied."""
231223
srcs, dsts = h2d_bufs
232224
for i, src in enumerate(srcs):
@@ -357,40 +349,3 @@ def test_rejects_bad_options_element(self, h2d_bufs, copy_stream):
357349

358350
with pytest.raises(TypeError, match="each options element must be CopyOptions"):
359351
copy_batch(copy_stream, srcs, dsts, options=bad)
360-
361-
362-
class TestPerCopyFallback:
363-
"""Behaviour where ``cuMemcpyBatchAsync`` is unavailable.
364-
365-
Reached whenever any of the three requirements for
366-
``cuMemcpyBatchAsync`` is unmet: ``cuda.core`` built against CUDA 13,
367-
``cuda.bindings`` 13.0+, and a driver reporting CUDA 13.0 or newer.
368-
Skipped when the batched entry point is actually in use.
369-
"""
370-
371-
@pytest.fixture(autouse=True)
372-
def _skip_if_batched(self):
373-
if cu_memcpy_batch_available():
374-
pytest.skip("cuMemcpyBatchAsync is in use; fallback path not exercised")
375-
376-
@pytest.mark.agent_authored(model="Claude Opus 5")
377-
def test_default_options_still_copy(self, init_cuda):
378-
device = Device()
379-
device.set_current()
380-
stream = device.create_stream()
381-
pinned_mr = LegacyPinnedMemoryResource()
382-
srcs = [pinned_mr.allocate(COPY_BATCH_SIZE) for _ in range(3)]
383-
dsts = [device.memory_resource.allocate(COPY_BATCH_SIZE, stream=stream) for _ in srcs]
384-
for i, src in enumerate(srcs):
385-
set_buffer(src, i + 5)
386-
387-
copy_batch(stream, srcs, dsts)
388-
stream.sync()
389-
390-
for i, dst in enumerate(dsts):
391-
assert compare_buffer_to_constant(dst, i + 5)
392-
393-
for buf in srcs + dsts:
394-
buf.close(stream)
395-
stream.sync()
396-
stream.close()

0 commit comments

Comments
 (0)