22
33from typing import TypedDict
44
5+ from cuda .core ._memory ._copy_enums import CopyOptions
56from cuda .core ._memory ._device_memory_resource import DeviceMemoryResource
67from cuda .core ._memory ._ipc import IPCBufferDescriptor
78from cuda .core ._memory ._pinned_memory_resource import PinnedMemoryResource
@@ -149,7 +150,7 @@ class Buffer:
149150 """
150151 def __enter__ (self ): ...
151152 def __exit__ (self , exc_type , exc_val , exc_tb ): ...
152- def copy_to (self , dst : Buffer | None = None , * , stream : Stream | GraphBuilder ) -> Buffer :
153+ def copy_to (self , dst : Buffer | None = None , * , stream : Stream | GraphBuilder , options : CopyOptions | None = None ) -> Buffer :
153154 """Copy from this buffer to the dst buffer asynchronously on the given stream.
154155
155156 Copies the data from this buffer to the provided dst buffer.
@@ -164,9 +165,31 @@ class Buffer:
164165 stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
165166 Keyword argument specifying the stream for the
166167 asynchronous copy
168+ options : :class:`~utils.CopyOptions`, optional
169+ Transfer hints (source access order, location hints, overlap mode).
170+ Honored when cuda.bindings and the driver are both CUDA 13.2 or
171+ newer. Not accepted with ``LEGACY_DEFAULT_STREAM``; use
172+ ``PER_THREAD_DEFAULT_STREAM`` instead. Not accepted with a
173+ capturing stream either, since a graph cannot represent these
174+ attributes; use :meth:`graph.GraphNode.memcpy` for a plain,
175+ non-attributed copy node, or pass ``options=None``. On an older
176+ cuda.bindings/driver, ``src_access_order`` values of ``STREAM``
177+ and ``ANY`` are silently ignored; ``DURING_API_CALL`` raises
178+ instead of silently downgrading its guarantee.
179+
180+ Raises
181+ ------
182+ TypeError
183+ If ``options`` is not a :class:`~utils.CopyOptions` instance, or
184+ if ``options`` is given together with ``LEGACY_DEFAULT_STREAM``
185+ or a stream currently in graph capture mode.
186+ RuntimeError
187+ If ``options.src_access_order`` is ``DURING_API_CALL`` and
188+ cuda.bindings or the driver is older than CUDA 13.2: falling
189+ back to a plain copy cannot honor that guarantee.
167190
168191 """
169- def copy_from (self , src : Buffer , * , stream : Stream | GraphBuilder ) -> None :
192+ def copy_from (self , src : Buffer , * , stream : Stream | GraphBuilder , options : CopyOptions | None = None ) -> None :
170193 """Copy from the src buffer to this buffer asynchronously on the given stream.
171194
172195 Parameters
@@ -176,7 +199,28 @@ class Buffer:
176199 stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
177200 Keyword argument specifying the stream for the
178201 asynchronous copy
202+ options : :class:`~utils.CopyOptions`, optional
203+ Transfer hints (source access order, location hints, overlap mode).
204+ Honored when cuda.bindings and the driver are both CUDA 13.2 or
205+ newer. Not accepted with ``LEGACY_DEFAULT_STREAM``; use
206+ ``PER_THREAD_DEFAULT_STREAM`` instead. Not accepted with a
207+ capturing stream either, since a graph cannot represent these
208+ attributes; use :meth:`graph.GraphNode.memcpy` for a plain,
209+ non-attributed copy node, or pass ``options=None``. On an older
210+ cuda.bindings/driver, ``src_access_order`` values of ``STREAM``
211+ and ``ANY`` are silently ignored; ``DURING_API_CALL`` raises
212+ instead of silently downgrading its guarantee.
179213
214+ Raises
215+ ------
216+ TypeError
217+ If ``options`` is not a :class:`~utils.CopyOptions` instance, or
218+ if ``options`` is given together with ``LEGACY_DEFAULT_STREAM``
219+ or a stream currently in graph capture mode.
220+ RuntimeError
221+ If ``options.src_access_order`` is ``DURING_API_CALL`` and
222+ cuda.bindings or the driver is older than CUDA 13.2: falling
223+ back to a plain copy cannot honor that guarantee.
180224 """
181225 def fill (self , value : int | BufferProtocol , * , stream : Stream | GraphBuilder ) -> None :
182226 """Fill this buffer with a repeating byte pattern.
0 commit comments