monarch.rdma#
The monarch.rdma module provides Remote Direct Memory Access (RDMA) support for high-performance networking and zero-copy data transfers between processes. See the Point-to-Point RDMA guide for an overview.
RDMA Buffer#
- class monarch.rdma.RDMABuffer(data)[source]#
Bases:
object- __init__(data)[source]#
RDMABuffer supports 1d contiguous tensors (including tensor views/slices) or 1d c-contiguous memoryviews.
- Parameters:
data (torch.Tensor | memoryview) – torch.Tensor or memoryview to create the buffer from. Must be 1d and contiguous. If provided, addr and size must not be specified.
- Raises:
ValueError – If data is not 1d contiguous, if size is 0, or if data is a GPU tensor.
RuntimeError – If no RDMA backend is available on this platform.
Note
Currently only CPU tensors are supported. GPU tensor support will be added in the future.
TODO: Create TensorBuffer, which will be main user API supporting non-contiguous tensors
- read_into(dst, *, timeout=60)[source]#
Read data from this RDMABuffer into
dst.dstmust be a 1D contiguous tensor or c-contiguous memoryview whose byte-size is at leastself.size().- Parameters:
dst (torch.Tensor | memoryview) – Destination tensor or memoryview to read into.
- Keyword Arguments:
timeout (int, optional) – Timeout in seconds. Defaults to 60s.
- Returns:
- A Monarch Future that resolves to
Nonewhen the read completes.
- A Monarch Future that resolves to
- Return type:
Future[None]
- Raises:
ValueError – If
dstis smaller than the RDMA buffer.
- write_from(src, *, timeout=60)[source]#
Write data from
srcinto this RDMABuffer.srcmust be a 1D contiguous tensor or c-contiguous memoryview whose byte-size is at mostself.size().- Parameters:
src (torch.Tensor | memoryview) – Source tensor or memoryview containing the bytes to write to the RDMA buffer.
- Keyword Arguments:
timeout (int, optional) – Timeout in seconds. Defaults to 60s.
- Returns:
- A Monarch Future that resolves to
Nonewhen the write completes.
- A Monarch Future that resolves to
- Return type:
Future[None]
- Raises:
ValueError – If
srcexceeds the RDMA buffer size.
RDMA Actions#
- class monarch.rdma.RDMAAction[source]#
Bases:
objectSchedule a batch of RDMA operations and submit them as one unit.
All bookkeeping (per-op validation, intra-batch local-memory race detection, backend grouping, parallel dispatch) lives in the Rust _RdmaAction; this class is a thin wrapper around it.
Utility Functions#
- monarch.rdma.is_ibverbs_available()[source]#
Whether ibverbs RDMA hardware is available on this system.
- monarch.rdma.is_rdma_available()[source]#
Whether RDMA over ibverbs is available on this system.
Deprecated since version Monarch: now supports multiple RDMA backends, so is_rdma_available is ambiguous and will be removed in a future release. Use
is_ibverbs_available()orget_rdma_backend()instead.