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
grouped_matmul_sm100_persistent
def grouped_matmul_sm100_persistent[EpilogueFnType: ElementwiseEpilogueFn = inflated$def[comptime[dtype: DType, width: SIMDLength, *, alignment: Int] #kgen.func.symbol<@linalg::@utils::@"_no_epilogue_body[::DType,::SIMDLength,::SIMD[DType.int, 1],KGENParamList[::Intable & ::Defaultable & ::RegisterPassable & ::TrivialRegisterPassable & ::Writable & ::AnyType & ::Copyable & ::ImplicitlyCopyable & ::Deinitable & ::Movable & ::CoordLike],::TypeList[::Intable & ::Defaultable & ::RegisterPassable & ::TrivialRegisterPassable & ::Writable & ::AnyType & ::Copyable & ::ImplicitlyCopyable & ::Deinitable & ::Movable & ::CoordLike, $3]](::Coord[$3, $4],::SIMD[$0, $1])"<:!lit.struct<@std::@builtin::@dtype::@DType> dtype, :!lit.struct<@std::@builtin::@simd_length::@SIMDLength> width, :!lit.struct<@std::@simd::@SIMD<:!lit.struct<@std::@builtin::@dtype::@DType> {:dtype index}, :!lit.struct<@std::@builtin::@simd_length::@SIMDLength> {1}>> alignment, :param_list<trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>> *?, :!lit.struct<@std::@builtin::@variadics::@TypeList<:meta<!lit.trait<@std::@traits::@anytype::@AnyType>> trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>, :param_list<trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>> *?>> *?>>], ComputeFnType: ElementwiseComputeFn = inflated$def[comptime[dtype: DType, width: SIMDLength, *, alignment: Int] #kgen.func.symbol<@linalg::@utils::@"identity_compute_fn[::DType,::SIMDLength,::SIMD[DType.int, 1],KGENParamList[::Intable & ::Defaultable & ::RegisterPassable & ::TrivialRegisterPassable & ::Writable & ::AnyType & ::Copyable & ::ImplicitlyCopyable & ::Deinitable & ::Movable & ::CoordLike],::TypeList[::Intable & ::Defaultable & ::RegisterPassable & ::TrivialRegisterPassable & ::Writable & ::AnyType & ::Copyable & ::ImplicitlyCopyable & ::Deinitable & ::Movable & ::CoordLike, $3]](::Coord[$3, $4],::SIMD[$0, $1])"<:!lit.struct<@std::@builtin::@dtype::@DType> dtype, :!lit.struct<@std::@builtin::@simd_length::@SIMDLength> width, :!lit.struct<@std::@simd::@SIMD<:!lit.struct<@std::@builtin::@dtype::@DType> {:dtype index}, :!lit.struct<@std::@builtin::@simd_length::@SIMDLength> {1}>> alignment, :param_list<trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>> *?, :!lit.struct<@std::@builtin::@variadics::@TypeList<:meta<!lit.trait<@std::@traits::@anytype::@AnyType>> trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>, :param_list<trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>> *?>> *?>>], //, c_type: DType, a_type: DType, b_type: DType, transpose_b: Bool, *, config: MatmulConfig[a_type, b_type, c_type, transpose_b], cta_group: Int = Int(1), num_pipeline_stages: Optional[Int] = None, a_swizzle: TensorMapSwizzle = TensorMapSwizzle.SWIZZLE_128B, b_swizzle: TensorMapSwizzle = TensorMapSwizzle.SWIZZLE_128B, has_epilogue_fn: Bool = False, has_compute_fn: Bool = False, a_plane_splits: Tuple[Int, Int] = Tuple(Int(0), Int(0)), pdl_level: PDLLevel = PDLLevel()](c: TileTensor[c_type, Engine=c.Engine, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, linear_idx_type=a.linear_idx_type], a_offsets: TileTensor[.uint32, Engine=a_offsets.Engine, linear_idx_type=a_offsets.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, linear_idx_type=b.linear_idx_type], expert_ids: TileTensor[.int32, Engine=expert_ids.Engine, linear_idx_type=expert_ids.linear_idx_type], expert_usage_stats: TileTensor[.uint32, Engine=expert_usage_stats.Engine, linear_idx_type=expert_usage_stats.linear_idx_type], ctx: DeviceContext, epilogue_fn: EpilogueFnType = no_epilogue_fn, compute_fn: ComputeFnType = no_compute_fn)
Launches the persistent grouped GEMM kernel for SM100 from host tensors.
Swaps A and B to match the kernel's transposed-B convention, delegates
to _grouped_matmul_sm100_persistent which builds TMA descriptors and
shared-memory layouts from the matmul config, selects the pipeline
depth from available shared memory, and enqueues the warp-specialized
kernel on the device context.
Parameters:
- EpilogueFnType (
ElementwiseEpilogueFn): Type ofepilogue_fn(inferred). - ComputeFnType (
ElementwiseComputeFn): Type ofcompute_fn(inferred). - c_type (
DType): Element type of the C output matrix (inferred). - a_type (
DType): Element type of the A operand matrix (inferred). - b_type (
DType): Element type of the B operand matrix (inferred). - transpose_b (
Bool): Whether B is stored transposed in global memory (inferred). - config (
MatmulConfig[a_type, b_type, c_type, transpose_b]): Matmul config carrying the block tile shape, MMA shape, and cluster shape. - cta_group (
Int): Number of CTAs cooperating per MMA along the M dimension (defaults to 1). - num_pipeline_stages (
Optional[Int]): Number of TMA producer and consumer pipeline stages; when None, auto-selected from available shared memory (defaults to None). - a_swizzle (
TensorMapSwizzle): TMA swizzle mode applied to A shared-memory tiles (defaults toSWIZZLE_128B). - b_swizzle (
TensorMapSwizzle): TMA swizzle mode applied to B shared-memory tiles (defaults toSWIZZLE_128B). - has_epilogue_fn (
Bool): Whetherepilogue_fnstores C in place of the TMA store (defaults to False). - has_compute_fn (
Bool): Whethercompute_fnmaps C in registers ahead of the TMA store (defaults to False). - a_plane_splits (
Tuple[Int, Int]): Per-plane split sizes for fused LoRA QKV A-plane row offsetting;(0, 0)disables it (defaults to(0, 0)). - pdl_level (
PDLLevel): Programmatic dependent launch level, forwarded to the warp-specialized kernel and to its launch attributes (defaults toPDLLevel(), which disables PDL).
Args:
- c (
TileTensor[c_type, Engine=c.Engine, linear_idx_type=c.linear_idx_type]): Output C tile tensor in generic address space. - a (
TileTensor[a_type, Engine=a.Engine, linear_idx_type=a.linear_idx_type]): A operand tile tensor (activations); swapped to B by the kernel's transposed-B convention. - a_offsets (
TileTensor[.uint32, Engine=a_offsets.Engine, linear_idx_type=a_offsets.linear_idx_type]): Per-expert A offset prefix sum tile tensor. - b (
TileTensor[b_type, Engine=b.Engine, linear_idx_type=b.linear_idx_type]): B operand tile tensor (weights); swapped to A by the kernel's transposed-B convention. - expert_ids (
TileTensor[.int32, Engine=expert_ids.Engine, linear_idx_type=expert_ids.linear_idx_type]): Per-group expert id tile tensor; negative entries skip the tile. - expert_usage_stats (
TileTensor[.uint32, Engine=expert_usage_stats.Engine, linear_idx_type=expert_usage_stats.linear_idx_type]): Per-expert usage stats tile tensor; index 1 holds the active expert count. - ctx (
DeviceContext): Device context used to enqueue the kernel. - epilogue_fn (
EpilogueFnType): Stores each output element at its(row, col)inc. - compute_fn (
ComputeFnType): Maps each output element at its(row, col)inc.