IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo struct

DistributedAllReduceSum

struct DistributedAllReduceSum

Registers the mo.distributed.allreduce.sum graph op with the graph compiler.

Implemented traits​

AnyType, Deinitable, Movable

Methods​

execute​

static def execute[dtype: DType, rank: Int, target: StringSpan[ImmStaticOrigin], _trace_name: StringSpan[ImmStaticOrigin], group_size: Int = Int(0)](outputs: _FusedOutputVariadicTensors[static_specs=outputs.static_specs], inputs: VariadicTensors[IOSpec[_, _].Input, static_specs=inputs.static_specs], signal_buffers: VariadicTensors[IOSpec[_, _].MutableInput, static_specs=signal_buffers.static_specs], dev_ctxs_input: DeviceContextArray)

Distributed allreduce operation implementation for sum reduction.

Limitations: - Maximum of 8 GPUs supported (matches MAX_GPUS in comm/sync.mojo) - Tensor element count must be multiple of SIMD width (per allreduce.mojo) - Requires identical tensor shapes within each allreduce group

Parameters:

  • ​dtype (DType): Element type of the input and output tensors.
  • ​rank (Int): Tensor rank (number of dimensions) of the inputs and outputs.
  • ​target (StringSpan[ImmStaticOrigin]): Target device string for tracing.
  • ​_trace_name (StringSpan[ImmStaticOrigin]): Trace name for profiling.
  • ​group_size (Int): Number of devices per independent allreduce group; must evenly divide the total number of devices. Zero (the attribute default) means all devices form one group.

Args:

  • ​outputs (_FusedOutputVariadicTensors[static_specs=outputs.static_specs]): Output tensors (one per GPU) to store reduced results.
  • ​inputs (VariadicTensors[IOSpec[_, _].Input, static_specs=inputs.static_specs]): Input tensors (one per GPU) containing values to reduce.
  • ​signal_buffers (VariadicTensors[IOSpec[_, _].MutableInput, static_specs=signal_buffers.static_specs]): Preallocated synchronization buffers for cross-GPU coordination.
  • ​dev_ctxs_input (DeviceContextArray): Device contexts for participating GPUs.

Was this page helpful?