Skip to content

Commit 44715f1

Browse files
committed
address review feedback
1 parent da4a376 commit 44715f1

5 files changed

Lines changed: 13 additions & 34 deletions

File tree

cuda_core/examples/batched_memcpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# dependencies = ["cuda_bindings", "cuda_core"]
1919
# ///
2020

21+
import ctypes
2122
import sys
2223

2324
from cuda.core import Device, Host, LegacyPinnedMemoryResource, ManagedMemoryResource
@@ -29,7 +30,6 @@ def readback(any_buf, pinned_mr, *, stream):
2930
host_buf = pinned_mr.allocate(any_buf.size)
3031
any_buf.copy_to(host_buf, stream=stream)
3132
stream.sync()
32-
import ctypes
3333

3434
ptr = ctypes.cast(int(host_buf.handle), ctypes.POINTER(ctypes.c_byte))
3535
data = ctypes.string_at(ptr, host_buf.size)

cuda_core/tests/example_tests/test_basic_examples.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,11 @@ def has_recent_memory_pool_support() -> bool:
7676

7777
def has_copy_batch_support() -> bool:
7878
"""Check if cuMemcpyBatchAsync is available (CUDA 13+)."""
79-
from cuda.core._utils.version import binding_version
79+
from cuda.core._memory._copy_ops import (
80+
_batch_entry_point_in_use as cu_memcpy_batch_available,
81+
)
8082

81-
if binding_version() < (13, 0, 0):
82-
return False
83-
try:
84-
from cuda.bindings import driver
85-
86-
if not hasattr(driver, "cuMemcpyBatchAsync"):
87-
return False
88-
except AttributeError:
89-
return False
90-
return True
83+
return cu_memcpy_batch_available()
9184

9285

9386
SYSTEM_REQUIREMENTS = {

cuda_core/tests/memory/__init__.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: Apache-2.0
4-
5-
# Marks `tests/memory` as a package. Under pytest's default "prepend" import
6-
# mode, a test file's sys.path entry is the first parent directory *without* an
7-
# __init__.py. Adding this file moves that entry up from `tests/memory` to
8-
# `tests/`, which is what we want for two reasons:
9-
#
10-
# * `tests/memory` is no longer on sys.path, so the `from conftest import ...`
11-
# in test_managed_ops.py resolves to the root tests/conftest.py. Without it
12-
# the local memory/conftest.py wins and the import fails with ImportError.
13-
# * Modules are named `memory.test_x` rather than `test_x`, so a file basename
14-
# reused under another directory cannot collide.
15-
#
16-
# Both follow from module identity tracking the directory layout instead of
17-
# whichever directory happens to land on sys.path. `tests/memory_ipc/` carries
18-
# an __init__.py for the same reasons.

cuda_core/tests/memory/conftest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717

1818
@pytest.fixture
1919
def copy_batch_device(init_cuda):
20-
"""``copy_batch`` works on every supported toolkit, so this never skips.
21-
22-
Only non-default ``CopyOptions`` need CUDA 13; those tests take
23-
``requires_copy_options`` as well.
24-
"""
20+
"""``copy_batch`` works on every supported toolkit, so this never skips."""
2521
device = Device()
2622
device.set_current()
2723
return device

cuda_core/tests/memory/test_copy_batch_options.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424

2525
from cuda.core import Device, Host, LegacyPinnedMemoryResource
2626
from cuda.core._memory._copy_enums import _attr_run_starts
27-
from cuda.core._memory._copy_ops import _batch_entry_point_in_use, _normalize_copy_options
27+
from cuda.core._memory._copy_ops import (
28+
_batch_entry_point_in_use as cu_memcpy_batch_available,
29+
)
30+
from cuda.core._memory._copy_ops import (
31+
_normalize_copy_options,
32+
)
2833
from cuda.core.utils import (
2934
CopyOptions,
3035
MemcpyOverlapMode,
@@ -356,7 +361,7 @@ class TestPerCopyFallback:
356361

357362
@pytest.fixture(autouse=True)
358363
def _skip_if_batched(self):
359-
if _batch_entry_point_in_use():
364+
if cu_memcpy_batch_available():
360365
pytest.skip("cuMemcpyBatchAsync is in use; fallback path not exercised")
361366

362367
@pytest.mark.agent_authored(model="Claude Opus 5")

0 commit comments

Comments
 (0)