Skip to content

Commit 090444e

Browse files
committed
fix docstrings regarding GraphNode.memcpy
1 parent 5080b34 commit 090444e

2 files changed

Lines changed: 48 additions & 42 deletions

File tree

cuda_core/cuda/core/_memory/_buffer.pyi

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,15 @@ class Buffer:
188188
asynchronous copy
189189
options : :class:`~utils.CopyOptions`, optional
190190
Transfer hints (source access order, location hints, overlap mode).
191-
Not accepted with ``LEGACY_DEFAULT_STREAM`` or a capturing stream
192-
(matches :func:`utils.copy_batch`); use ``PER_THREAD_DEFAULT_STREAM``
193-
or :meth:`graph.GraphNode.memcpy` instead. On cuda.bindings/driver
194-
older than CUDA 13.2, ``src_access_order`` values of ``STREAM``
195-
and ``ANY`` fall back to ``cuMemcpyAsync`` silently; ``DURING_API_CALL``
196-
raises instead of silently downgrading its guarantee.
191+
Honored when cuda.bindings and the driver are both CUDA 13.2 or
192+
newer. Not accepted with ``LEGACY_DEFAULT_STREAM``; use
193+
``PER_THREAD_DEFAULT_STREAM`` instead. Not accepted with a
194+
capturing stream either, since a graph cannot represent these
195+
attributes; use :meth:`graph.GraphNode.memcpy` for a plain,
196+
non-attributed copy node, or pass ``options=None``. On an older
197+
cuda.bindings/driver, ``src_access_order`` values of ``STREAM``
198+
and ``ANY`` are silently ignored; ``DURING_API_CALL`` raises
199+
instead of silently downgrading its guarantee.
197200
198201
Raises
199202
------
@@ -203,10 +206,8 @@ class Buffer:
203206
or a stream currently in graph capture mode.
204207
RuntimeError
205208
If ``options.src_access_order`` is ``DURING_API_CALL`` and
206-
cuda.bindings/driver older than CUDA 13.2 makes the native
207-
``cuMemcpyWithAttributesAsync`` path unavailable: the
208-
``cuMemcpyAsync`` fallback reads the source in stream order
209-
only, which cannot honor that guarantee.
209+
cuda.bindings or the driver is older than CUDA 13.2: falling
210+
back to a plain copy cannot honor that guarantee.
210211
211212
"""
212213

@@ -222,12 +223,15 @@ class Buffer:
222223
asynchronous copy
223224
options : :class:`~utils.CopyOptions`, optional
224225
Transfer hints (source access order, location hints, overlap mode).
225-
Not accepted with ``LEGACY_DEFAULT_STREAM`` or a capturing stream
226-
(matches :func:`utils.copy_batch`); use ``PER_THREAD_DEFAULT_STREAM``
227-
or :meth:`graph.GraphNode.memcpy` instead. On cuda.bindings/driver
228-
older than CUDA 13.2, ``src_access_order`` values of ``STREAM``
229-
and ``ANY`` fall back to ``cuMemcpyAsync`` silently; ``DURING_API_CALL``
230-
raises instead of silently downgrading its guarantee.
226+
Honored when cuda.bindings and the driver are both CUDA 13.2 or
227+
newer. Not accepted with ``LEGACY_DEFAULT_STREAM``; use
228+
``PER_THREAD_DEFAULT_STREAM`` instead. Not accepted with a
229+
capturing stream either, since a graph cannot represent these
230+
attributes; use :meth:`graph.GraphNode.memcpy` for a plain,
231+
non-attributed copy node, or pass ``options=None``. On an older
232+
cuda.bindings/driver, ``src_access_order`` values of ``STREAM``
233+
and ``ANY`` are silently ignored; ``DURING_API_CALL`` raises
234+
instead of silently downgrading its guarantee.
231235
232236
Raises
233237
------
@@ -237,10 +241,8 @@ class Buffer:
237241
or a stream currently in graph capture mode.
238242
RuntimeError
239243
If ``options.src_access_order`` is ``DURING_API_CALL`` and
240-
cuda.bindings/driver older than CUDA 13.2 makes the native
241-
``cuMemcpyWithAttributesAsync`` path unavailable: the
242-
``cuMemcpyAsync`` fallback reads the source in stream order
243-
only, which cannot honor that guarantee.
244+
cuda.bindings or the driver is older than CUDA 13.2: falling
245+
back to a plain copy cannot honor that guarantee.
244246
"""
245247

246248
def fill(self, value: int | BufferProtocol, *, stream: Stream | GraphBuilder) -> None:

cuda_core/cuda/core/_memory/_buffer.pyx

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ cdef void _dispatch_buffer_copy(
215215
if _stream_is_capturing(s):
216216
raise TypeError(
217217
f"{method_name} does not support graph capture with options "
218-
"(matches copy_batch); use GraphNode.memcpy to build attributed copies "
219-
"into a graph, or pass options=None."
218+
"(matches copy_batch); the driver has no graph-node form of "
219+
"cuMemcpyWithAttributesAsync, so options cannot be honored in a graph. "
220+
"Use GraphNode.memcpy for a plain (non-attributed) copy node, or pass "
221+
"options=None."
220222
)
221223
if _with_attributes_available():
222224
_do_copy_with_attributes(dst, src, nbytes, options, as_cu(s._h_stream))
@@ -485,12 +487,15 @@ cdef class Buffer:
485487
asynchronous copy
486488
options : :class:`~utils.CopyOptions`, optional
487489
Transfer hints (source access order, location hints, overlap mode).
488-
Not accepted with ``LEGACY_DEFAULT_STREAM`` or a capturing stream
489-
(matches :func:`utils.copy_batch`); use ``PER_THREAD_DEFAULT_STREAM``
490-
or :meth:`graph.GraphNode.memcpy` instead. On cuda.bindings/driver
491-
older than CUDA 13.2, ``src_access_order`` values of ``STREAM``
492-
and ``ANY`` fall back to ``cuMemcpyAsync`` silently; ``DURING_API_CALL``
493-
raises instead of silently downgrading its guarantee.
490+
Honored when cuda.bindings and the driver are both CUDA 13.2 or
491+
newer. Not accepted with ``LEGACY_DEFAULT_STREAM``; use
492+
``PER_THREAD_DEFAULT_STREAM`` instead. Not accepted with a
493+
capturing stream either, since a graph cannot represent these
494+
attributes; use :meth:`graph.GraphNode.memcpy` for a plain,
495+
non-attributed copy node, or pass ``options=None``. On an older
496+
cuda.bindings/driver, ``src_access_order`` values of ``STREAM``
497+
and ``ANY`` are silently ignored; ``DURING_API_CALL`` raises
498+
instead of silently downgrading its guarantee.
494499

495500
Raises
496501
------
@@ -500,10 +505,8 @@ cdef class Buffer:
500505
or a stream currently in graph capture mode.
501506
RuntimeError
502507
If ``options.src_access_order`` is ``DURING_API_CALL`` and
503-
cuda.bindings/driver older than CUDA 13.2 makes the native
504-
``cuMemcpyWithAttributesAsync`` path unavailable: the
505-
``cuMemcpyAsync`` fallback reads the source in stream order
506-
only, which cannot honor that guarantee.
508+
cuda.bindings or the driver is older than CUDA 13.2: falling
509+
back to a plain copy cannot honor that guarantee.
507510

508511
"""
509512
cdef Stream s = Stream_accept(stream)
@@ -537,12 +540,15 @@ cdef class Buffer:
537540
asynchronous copy
538541
options : :class:`~utils.CopyOptions`, optional
539542
Transfer hints (source access order, location hints, overlap mode).
540-
Not accepted with ``LEGACY_DEFAULT_STREAM`` or a capturing stream
541-
(matches :func:`utils.copy_batch`); use ``PER_THREAD_DEFAULT_STREAM``
542-
or :meth:`graph.GraphNode.memcpy` instead. On cuda.bindings/driver
543-
older than CUDA 13.2, ``src_access_order`` values of ``STREAM``
544-
and ``ANY`` fall back to ``cuMemcpyAsync`` silently; ``DURING_API_CALL``
545-
raises instead of silently downgrading its guarantee.
543+
Honored when cuda.bindings and the driver are both CUDA 13.2 or
544+
newer. Not accepted with ``LEGACY_DEFAULT_STREAM``; use
545+
``PER_THREAD_DEFAULT_STREAM`` instead. Not accepted with a
546+
capturing stream either, since a graph cannot represent these
547+
attributes; use :meth:`graph.GraphNode.memcpy` for a plain,
548+
non-attributed copy node, or pass ``options=None``. On an older
549+
cuda.bindings/driver, ``src_access_order`` values of ``STREAM``
550+
and ``ANY`` are silently ignored; ``DURING_API_CALL`` raises
551+
instead of silently downgrading its guarantee.
546552

547553
Raises
548554
------
@@ -552,10 +558,8 @@ cdef class Buffer:
552558
or a stream currently in graph capture mode.
553559
RuntimeError
554560
If ``options.src_access_order`` is ``DURING_API_CALL`` and
555-
cuda.bindings/driver older than CUDA 13.2 makes the native
556-
``cuMemcpyWithAttributesAsync`` path unavailable: the
557-
``cuMemcpyAsync`` fallback reads the source in stream order
558-
only, which cannot honor that guarantee.
561+
cuda.bindings or the driver is older than CUDA 13.2: falling
562+
back to a plain copy cannot honor that guarantee.
559563
"""
560564
cdef Stream s = Stream_accept(stream)
561565
cdef size_t dst_size = self._size

0 commit comments

Comments
 (0)