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, target: StringSpan[ImmStaticOrigin], num_phases: Int, computationally_expensive: Bool = False, associative: Bool = False, dtype_size: Int = Int(0)](body: Body, shape: Coord, ctx: Optional[DeviceContext] = None)
Top-level scaffolder. num_phases picks reduce-shaped (num_phases == 1, output collapses the reduced axis, terminal emit) vs. normalize-shaped (num_phases > 1, output keeps the input shape, terminal elementwise) β see the module note above for the full picture, including the GPU tier-dispatch decision tree.
Parameters:
- βaxis (
Int): Axis being reduced. - βsimd_width (
Int): SIMD width for tile dispatch. Bodies compute this viarowwise.pick_simd_width[...]and pass it directly. - βtarget (
StringSpan[ImmStaticOrigin]):"cpu"or"gpu"(anything non-CPU routes through the GPU backend). - βnum_phases (
Int): Total phase count β1for reduce-shaped bodies (the reduce's own result is the final output);> 1for normalize-shaped bodies (num_phases - 1dependentrow.reducephases before a final per-element write). Asserted> 0. - βcomputationally_expensive (
Bool): GPU author hint β flips the block tier's SIMD-full threshold for compute-heavy bodies. CPU ignores. - βassociative (
Bool): Reduce-shaped (num_phases == 1) only, CPU-only. SetTrueto widen the accumulator on long rows so the running total doesn't serialize into one add-per-element chain (recovers memory bandwidth). Only correct when reordering the accumulation doesn't change the result β additive reductions likereduce_sum/reduce_mean. LeaveFalsefor anything where element order matters (product's narrower-dtype rounding, tie-breaking inarg_max/arg_min, ...). Ignored on GPU and meaningless for normalize-shaped bodies. - βdtype_size (
Int): Normalize-shaped (num_phases > 1) only, GPU only. Byte size of the body's primary dtype (size_of[dtype]()), used only by the phase-aware split-K byte gate;0(the default) leaves that tier's runtime condition permanently false, so the extra codegen it introduces is unreachable (softmax / log-softmax pass their dtype's size to actually engage it). Meaningless for reduce-shaped bodies.
Args:
- βbody (
Body): The per-row computation. Receives aContextand the row'sCoord; usesreduce/pjoin/once/simdto compose the algorithm. - βshape (
Coord): Tensor shape. - βctx (
Optional[DeviceContext]): OptionalDeviceContext; required fortarget="gpu", unused on CPU.
Raises:
On launch or worker failure.