etha.comm.ir#
Intermediate Representation for tensor transfer operations.
Attributes#
Classes#
A transfer unit: one buffer + one wire op for its chunks. |
|
A shape-dependent transfer descriptor: a tensor region plus its role. |
|
A chunk location: a rank and its cell (multi-index) in the transfer grid. |
|
Mesh-to-mesh topology (shape-independent, reusable across batches). |
|
One source cell's delivery: |
Module Contents#
- class etha.comm.ir.Bucket#
A transfer unit: one buffer + one wire op for its chunks.
Identity (transport/role/ranks/key) is uniform across a bucket’s chunks (they share a
bucket_key), so it is read from the first chunk. Byte offsets (the prefix sum ofchunk.nbytes) are computed once at construction since a bucket is reused across transfers.- launch() bool#
Issue the wire op once the assembled buffer is ready.
Returns False if the buffer-assembly event hasn’t fired yet; otherwise issues the transport (no-op for LOCAL/NONE) and returns True.
- prepare() None#
Assemble the bucket buffer from its chunks.
Source-side Partial reduce and dtype cast both live inside
Chunk.prepare. A producing chunk’s data is copied into the bucket; the per-chunk buffer is kept only when the chunk alsois_target(self-copy), sofinalizecan write it to the target. A consume-only recv instead points its buffer at the bucket slice to land directly.
- buffer: torch.Tensor | None = None#
- buffer_ready_event: torch.cuda.Event | None = None#
- device: torch.device | None = None#
- property transport: etha.comm.transfer.Transport#
- work: torch.distributed.Work | None = None#
- class etha.comm.ir.Chunk#
A shape-dependent transfer descriptor: a tensor region plus its role.
Not a transfer unit — a
Bucketruns the wire op; a chunk only describes one tensor region and how to prepare/finalize it.- prepare(contiguous: bool = True) None#
Prepare the buffer.
is_sourcereadssrc_slicethen performs (in order): in-place all-reduce on Partial sub-groups (in source dtype) → cast totransfer_dtype. Reducing before the cast matches DTensorPartial → Replicatesemantics; running the all-reduce in the (possibly lower-precision) wire dtype would change numerical results. A consume-only chunk (recv) instead viewsdst_sliceso the wire op lands directly in the target.
- property bucket_key: tuple#
Return bucket grouping key.
transportis in the key so a local (self-copy) chunk never bundles with a co-located broadcast source chunk: they sharesrc_rankanddst_ranksbut must run different ops and produce buffers of different sizes across the broadcast group.cell_keyis added for reduce-only Partial chunks only — they all sharedst_ranks=()and would otherwise bundle across cells, making the bucket’s all_reduce sequence per-rank-specific and out of sync with peer ranks whose matching cells live in separate buckets. Shipping chunks already differ bydst_ranksacross cells.
- buffer: torch.Tensor | None = None#
- tensor: torch.Tensor | None = None#
- transfer_dtype: torch.dtype | None = None#
- transport: etha.comm.transfer.Transport#
- class etha.comm.ir.Endpoint#
Bases:
msgspec.StructA chunk location: a rank and its cell (multi-index) in the transfer grid.
- class etha.comm.ir.M2MMap#
Bases:
msgspec.StructMesh-to-mesh topology (shape-independent, reusable across batches).
routesis a flat list of per-cell delivery plans (seeRoute);source_num_slicers/target_num_slicersdescribe how each side partitions the tensor;source_partial_reductionslists(mesh_dim, reduce_op)per source Partial dim (empty when none).
- class etha.comm.ir.Route#
Bases:
msgspec.StructOne source cell’s delivery:
srcendpoint to a set of dst endpoints.kindis fixed at construction: emptydsts-> NONE (reduce-only), else BROADCAST (>1) or P2P (1). LOCAL is not a route kind; a dst that lands on the source rank is refined to a local copy when chunks are built.
- etha.comm.ir.logger#