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
split_k_reduce
def split_k_reduce(c: TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], work_space: TileTensor[Engine=work_space.Engine, address_space=work_space.address_space, linear_idx_type=work_space.linear_idx_type], ctx: DeviceContextBase)
Reduces a split-K workspace into the output tensor by summing across K partitions.
Loads each (m, n) element from every partition in work_space, accumulates
them, and stores the result into c.
Args:
- c (
TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type]): Output tile of shape(M, N)that receives the reduced sum. - work_space (
TileTensor[Engine=work_space.Engine, address_space=work_space.address_space, linear_idx_type=work_space.linear_idx_type]): Read-only tile of shape(num_partitions, M, N)holding the per-partition partial sums to be reduced. - ctx (
DeviceContextBase): Device context used to launch the reduction kernel.
def split_k_reduce[EpilogueFnType: ElementwiseEpilogueFn, //](c: TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], work_space: TileTensor[Engine=work_space.Engine, address_space=work_space.address_space, linear_idx_type=work_space.linear_idx_type], epilogue_fn: EpilogueFnType, ctx: DeviceContextBase)
Reduces a split-K workspace by summing across K partitions and hands each reduced output to epilogue_fn.
Parameters:
- EpilogueFnType (
ElementwiseEpilogueFn): Type ofepilogue_fn(inferred).
Args:
- c (
TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type]): Output tile of shape(M, N). Only its shape is read;epilogue_fnstores the result. - work_space (
TileTensor[Engine=work_space.Engine, address_space=work_space.address_space, linear_idx_type=work_space.linear_idx_type]): Read-only tile of shape(num_partitions, M, N)holding the per-partition partial sums to be reduced. - epilogue_fn (
EpilogueFnType): Stores each reduced output. - ctx (
DeviceContextBase): Device context used to launch the reduction kernel.
def split_k_reduce[ComputeFnType: ElementwiseComputeFn, //](c: TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], work_space: TileTensor[Engine=work_space.Engine, address_space=work_space.address_space, linear_idx_type=work_space.linear_idx_type], compute_fn: ComputeFnType, ctx: DeviceContextBase)
Reduces a split-K workspace by summing across K partitions and stores compute_fn of each reduced output into c.
Parameters:
- ComputeFnType (
ElementwiseComputeFn): Type ofcompute_fn(inferred).
Args:
- c (
TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type]): Output tile of shape(M, N)that receives the result. - work_space (
TileTensor[Engine=work_space.Engine, address_space=work_space.address_space, linear_idx_type=work_space.linear_idx_type]): Read-only tile of shape(num_partitions, M, N)holding the per-partition partial sums to be reduced. - compute_fn (
ComputeFnType): Maps each output index and reduced value to the value to store. - ctx (
DeviceContextBase): Device context used to launch the reduction kernel.