For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
allgather
def allgather[dtype: DType, in_layout: TensorLayout, in_origin: ImmOrigin, out_layout: TensorLayout, out_origin: MutOrigin, //, ngpus: Int](inputs: Array[TileTensor[dtype, in_layout, in_origin], ngpus], outputs: Array[TileTensor[dtype, out_layout, out_origin], (ngpus * ngpus)], list_of_ctx: List[DeviceContext])
Performs an allgather across all GPUs via the vendor CCL library.
Each GPU contributes its local inputs[i] chunk; after the call every
output slot outputs[dev * ngpus + src] on device dev holds a copy of
the input from device src. Uses ncclAllGather (NVIDIA) or
rcclAllGather (AMD) internally, wrapped inside an NCCL group for
correct pipelining.
Parameters:
- βdtype (
DType): Element data type of all input and output tensors. - βin_layout (
TensorLayout):TensorLayoutof each per-GPU input. - βin_origin (
ImmOrigin): Origin tag for the input tensors. - βout_layout (
TensorLayout):TensorLayoutof each per-GPU output slot. - βout_origin (
MutOrigin): Mutable origin tag for the output tensors. - βngpus (
Int): Number of participating GPUs.
Args:
- βinputs (
Array[TileTensor[dtype, in_layout, in_origin], ngpus]): Per-GPU inputTileTensors; must all have the same element count. - βoutputs (
Array[TileTensor[dtype, out_layout, out_origin], (ngpus * ngpus)]): Flat array ofngpus * ngpusoutputTileTensors. Sloti * ngpus + jon deviceireceives devicej's input. - βlist_of_ctx (
List[DeviceContext]): Device context for each GPU; length must equalngpus.
Raises:
If ngpus < 1 or ngpus > MAX_GPUS.
If len(list_of_ctx) != ngpus.
If any input element count differs from inputs[0]'s count.
If the CCL collective call fails.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!