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 function
launch
def launch[Body: RowBody, //, axis: Int, simd_width: Int, supports_tiled: Bool = False, reduce_shaped: Bool = False, supports_splitk: Bool = False, num_phases: Int = Int(0), max_simd_width: Int = Int(0)](body: Body, shape: Coord[*shape.element_types])
Top-level CPU scaffolder. Picks the tier from axis and supports_tiled, parallelizes over outputs (or output tiles), and invokes the body once per output (or tile).
Tier choice:
- Inner axis (
axis == rank - 1) — one worker per row, vectorize within the row atsimd_width.emit_tile_width = 1. - Non-inner axis with
supports_tiled— one worker per slice; each walks the innermost-non-axis dim insimd_widthtiles, with a scalar tail for the remainder.emit_tile_width = simd_width. - Non-inner axis without
supports_tiled— one worker per output, scalar reduce.emit_tile_width = 1.
Parameters:
- axis (
Int): Axis being reduced. - simd_width (
Int): SIMD width for tile dispatch. Bodies compute it viarowwise.pick_simd_width[...]and pass it directly; the scaffolder no longer derives it from a dtype. - supports_tiled (
Bool): Whether the body can run in the tiled tier (emit_tile_width > 1). Single-output reductions (reduce_sum, …) set thisTrue; multi-output kernels (softmax, layernorm) set itFalse. - reduce_shaped (
Bool): Whether the body is reduce-shaped (one output per row). Only then does the inner-axis cooperative tier widen the accumulator to_CPU_ILP_ACCUMULATORS * simd_widthlanes for rows>= _CPU_WIDE_ACC_MIN_ROW, breaking the serial accumulate dependency chain. - supports_splitk (
Bool): Whether the body can run in the inner-axis split-axis tier, where only the last worker to arrive sees the joined state. Reduce-shaped bodies set thisTrue; normalize-shaped bodies need the joined state in every worker. - num_phases (
Int): Normalize-shaped opt-in for the pointwise split-axis tier:num_phases - 1dependent reduces, then the per-element write, each run as its ownsync_parallelize.<= 1disables it. - max_simd_width (
Int): The widest load the body may take,0for any; the wide-accumulator path widens only up to it.
Args:
- body (
Body): The per-row computation. Receives aContextand the row'sCoord; usesreduce/pjoin/once/simdto compose the algorithm. - shape (
Coord[*shape.element_types]): Tensor shape.
Raises:
If a worker raises.