cuda.core.utils.copy_batch#
- cuda.core.utils.copy_batch(Stream stream: Stream, srcs: Sequence[Buffer], dsts: Sequence[Buffer], *, options: CopyOptions | Sequence[CopyOptions] | None = None) None#
Copy a batch of buffers asynchronously.
Sizes are taken from the source buffers and each destination must match. For a single buffer, use
Buffer.copy_to()orBuffer.copy_from().The driver provides no graph-node form of
cuMemcpyBatchAsync, so this cannot be captured into a graph. Build graph copies withgraph.GraphNode.memcpy()or per-bufferBuffer.copy_to().- Parameters:
stream (
Stream) – Stream for the asynchronous copy. First positional and required (mirrorslaunch()). Unlike most stream-taking APIs this does not accept aGraphBuilder; one is rejected withTypeErrorbecause the copy cannot be captured.srcs (Sequence[
Buffer]) – Source buffers. Must be a sequence, not a single Buffer.dsts (Sequence[
Buffer]) – Destination buffers. Must matchlen(srcs).options (
CopyOptions| Sequence[CopyOptions] | None) – Per-copy options. A single value applies to every copy; a sequence pairs by index and must matchlen(srcs).Noneuses stream-ordered defaults.
- Raises:
ValueError – If lengths or sizes mismatch.
TypeError – If a single Buffer is passed instead of a sequence.
NotImplementedError – If non-default
optionsare given wherecuMemcpyBatchAsyncis unavailable (see Notes).
Notes
Batching through
cuMemcpyBatchAsyncrequires all three of:cuda.corebuilt against CUDA 13 headers,cuda.bindings13.0 or newer, and a driver reporting CUDA 13.0 or newer (cuDriverGetVersion() >= 13000).cuda.bindingsbinds only the CUDA 13.0 revision of the entry point, so a driver that predates it is refused even where it implements the earlier CUDA 12.8 signature.Short of that, the copies fall back to a Python-level loop over
cuMemcpyAsync, which is semantically equivalent but does not amortize launch overhead. The fallback has no way to conveyCopyOptionsto the driver, so non-default options raiseNotImplementedErrorthere rather than being silently ignored.- Warns:
UserWarning – If
overlap_mode='prefer_overlap_with_compute'is requested on a non-integrated (discrete) GPU.