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 module
reduce_op
Reduction monoid traits β the device-agnostic author surface.
A reduction algorithm is authored as a struct conforming to ReduceOp:
inlined state fields, __init__ (identity), accumulate[w] (SIMD-tile
fold), join (sequential combine), and optionally
join_parallel[R: Reducer] (parallel combine). How participants
cooperate and how the parallel scope is defined live in the Reducer
impls.
Structsβ
- β
ArgMax: Argmax reduction monoid: tracks the (value, axis-index) pair with the largest value. Ties break to the lower index. - β
ArgMin: Argmin reduction monoid: mirrorsArgMaxwith</gecomparison (seeArgMaxfor the algorithm + design notes). - β
MinMax: Fused min+max reduction monoid: tracks bothmin(self, x)andmax(self, x)in one state. Cuts the axis walk in half vs running separateReduceMin+ReduceMax. - β
OnlineLogSumExp: Online (flash-style) log-sum-exp monoid (Milakov & Gimelshein, 2018) β the reduction half of softmax. - β
ReduceMax: Max reduction monoid:(self, x) -> max(self, x). - β
ReduceMin: Min reduction monoid:(self, x) -> min(self, x). - β
ReduceProduct: Product reduction monoid:(self, x) -> self * x. - β
ReduceSum: Sum reduction monoid:(self, x) -> self + x. - β
Welford: Welford's online mean/variance monoid (Welford 1962, Chan et al. 1979 for the combine) β the reduction half of layer_norm / group_norm.
Traitsβ
- β
ReduceOp: Trait for an associative reduction monoid (identity + associativejoin). - β
Reducer: Parallel scalar reducer over the closed set of associative ops.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!