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 function

launch

def launch[Body: RowBody, //, axis: Int, simd_width: Int, num_phases: Int, computationally_expensive: Bool = False, dtype_size: Int = Int(0), name: StaticString = "rowwise", pdl_level: PDLLevel = PDLLevel.OVERLAP_AT_BEGINNING, max_simd_width: Int = Int(0)](body: Body, shape: Coord[*shape.element_types], ctx: Optional[DeviceContext[target]] = DeviceContext[_].NoneValue)

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 via rowwise.pick_simd_width[...] and pass it directly.
  • ​num_phases (Int): Total phase count — 1 for reduce-shaped bodies (the reduce's own result is the final output); > 1 for normalize-shaped bodies (num_phases - 1 dependent row.reduce phases 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.
  • ​dtype_size (Int): Normalize-shaped (num_phases > 1) only. Byte size of the body's primary dtype (size_of[dtype]()), used by the GPU phase-aware split-K byte gate; any value > 0 also opts the body into the CPU pointwise split-axis tier. 0 (the default) leaves both tiers unreachable (softmax / log-softmax / rms_norm pass their dtype's size to engage them). Meaningless for reduce-shaped bodies.
  • ​name (StaticString): Operation name propagated to the GPU tier kernels' @__name so a profile row identifies the op (defaults to "rowwise"). CPU ignores.
  • ​pdl_level (PDLLevel): GPU programmatic dependent launch level of the tier kernels (NVIDIA SM90+ only). OVERLAP_AT_BEGINNING releases dependent kernels right after the predecessor wait instead of at exit. CPU ignores.
  • ​max_simd_width (Int): The widest load the body may take, 0 for any: the CPU wide-accumulator path widens only up to it. The GPU tiers already load at simd_width.

Args:

  • ​body (Body): The per-row computation. Receives a Context and the row's Coord; uses reduce / pjoin / once / simd to compose the algorithm.
  • ​shape (Coord[*shape.element_types]): Tensor shape.
  • ​ctx (Optional[DeviceContext[target]]): Optional DeviceContext; required for target="gpu", unused on CPU.

Raises:

On launch or worker failure.

Was this page helpful?