jax.experimental.pallas.mosaic_gpu.copy_gmem_to_smem#
- jax.experimental.pallas.mosaic_gpu.copy_gmem_to_smem(src, dst, barrier, *, impl='tma', collective_axes=None, leader_tracked=None, oob_mode=None)[source]#
Asynchronously copies a GMEM reference to a SMEM reference.
When
impl="tma"andcollective_axesis specified, the copy involves multiple CUDA blocks in the cluster. The value ofleader_trackeddetermines the behavior:None(multicast): all CUDA blocks sharing the same index along the collective axes receive the same data fromsrc.CopyPartition.PARTITIONED(axis): each CUDA block in the cluster receives atransfer_size // cluster_sizetile ofsrc. E.g. forsrcof shape(256, 256)with cluster size 2 along axis 0: block 0 getssrc[0:128, :], block 1 getssrc[128:256, :].CopyPartition.REPLICATED: all CUDA blocks in the cluster load the same data, but only the first block tracks progress via barrier arrivals.
Note
For leader-tracked copies, only the first CUDA block in the cluster arrives on the barrier. If other blocks need to consume the copied data, an additional cluster barrier is necessary to ensure all blocks have finished the copy.
- Parameters:
src (_Ref) – The source Ref. Must be in GMEM.
dst (_Ref) – The destination Ref. Must be in SMEM.
barrier (_Ref) – The barrier to use for tracking completion of the copy.
impl (Literal['tma', 'cp_async']) – The underlying copy implementation to use:
"cp_async"or"tma". Defaults to"tma".collective_axes (str | tuple[str, ...] | None) – The collective axes to use for the copy. Only a single collective axis is supported when
leader_trackedis specified (but the axis can be composite). Only supported whenimpl="tma".leader_tracked (CopyPartition | None) – If specified, only the leader block in the cluster will observe the completion of the copy. If
CopyPartition.PARTITIONED(axis), performs a partitioned collective copy along the given axis. IfCopyPartition.REPLICATED, all blocks load the same data. Only supported whenimpl="tma".oob_mode (OOBFillMode | None) – The optional out-of-bounds fill mode. Can be
OOBFillMode.UNDEFINED,OOBFillMode.PROMISE_IN_BOUNDSorOOBFillMode.ZEROS. Only supported whenimpl="tma".
- Return type:
None