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

multistage_gemm

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b]](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], ctx: DeviceContextBase)

TileTensor overload of multistage_gemm. Dispatches to a GEMM kernel over the native TileTensor operands; the device-side pipeline bridges to legacy LayoutTensorIter views internally (the multistage pipeline is iterator-driven and has no TileTensor equivalent yet).

Parameters:

  • ​c_type (DType): DType of the output tile c elements (inferred).
  • ​a_type (DType): DType of the input tile a elements (inferred).
  • ​b_type (DType): DType of the input tile b elements (inferred).
  • ​transpose_b (Bool): Whether b is accessed transposed, so its row y is read as b[y, i] instead of b[i, y].
  • ​config (MatmulConfig[a_type, b_type, c_type, transpose_b]): Compile-time MatmulConfig selecting the block tile, warp tile, MMA shape, and pipeline stages for the kernel.

Args:

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, EpilogueFnType: ElementwiseEpilogueFn, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b]](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], epilogue_fn: EpilogueFnType, ctx: DeviceContextBase)

Runs multistage_gemm, storing the output through an epilogue closure value.

Parameters:

  • ​c_type (DType): DType of the output tile c elements (inferred).
  • ​a_type (DType): DType of the input tile a elements (inferred).
  • ​b_type (DType): DType of the input tile b elements (inferred).
  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​transpose_b (Bool): Whether b is accessed transposed, so its row y is read as b[y, i] instead of b[i, y].
  • ​config (MatmulConfig[a_type, b_type, c_type, transpose_b]): Compile-time MatmulConfig selecting the block tile, warp tile, MMA shape, and pipeline stages for the kernel.

Args:

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, ComputeFnType: ElementwiseComputeFn, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b]](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], compute_fn: ComputeFnType, ctx: DeviceContextBase)

Runs multistage_gemm, storing compute_fn(idx, a @ b) into c.

Parameters:

  • ​c_type (DType): DType of the output tile c elements (inferred).
  • ​a_type (DType): DType of the input tile a elements (inferred).
  • ​b_type (DType): DType of the input tile b elements (inferred).
  • ​ComputeFnType (ElementwiseComputeFn): Type of compute_fn (inferred).
  • ​transpose_b (Bool): Whether b is accessed transposed, so its row y is read as b[y, i] instead of b[i, y].
  • ​config (MatmulConfig[a_type, b_type, c_type, transpose_b]): Compile-time MatmulConfig selecting the block tile, warp tile, MMA shape, and pipeline stages for the kernel.

Args:

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b]](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], runtime_config: MatmulConfig[a_type, b_type, c_type, transpose_b], ctx: DeviceContextBase)

TileTensor overload of multistage_gemm with runtime config. Constrains c to mut=True because split_k_reduce requires a mutable output tensor.

Parameters:

  • ​c_type (DType): DType of the output tile c elements (inferred).
  • ​a_type (DType): DType of the input tile a elements (inferred).
  • ​b_type (DType): DType of the input tile b elements (inferred).
  • ​transpose_b (Bool): Whether b is accessed transposed, so its row y is read as b[y, i] instead of b[i, y].
  • ​config (MatmulConfig[a_type, b_type, c_type, transpose_b]): Compile-time MatmulConfig selecting the block tile, warp tile, MMA shape, and pipeline stages for the kernel.

Args:

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, EpilogueFnType: ElementwiseEpilogueFn, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b]](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], runtime_config: MatmulConfig[a_type, b_type, c_type, transpose_b], epilogue_fn: EpilogueFnType, ctx: DeviceContextBase)

Runs multistage_gemm with runtime config, storing the output through an epilogue closure value.

Parameters:

  • ​c_type (DType): DType of the output tile c elements (inferred).
  • ​a_type (DType): DType of the input tile a elements (inferred).
  • ​b_type (DType): DType of the input tile b elements (inferred).
  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​transpose_b (Bool): Whether b is accessed transposed, so its row y is read as b[y, i] instead of b[i, y].
  • ​config (MatmulConfig[a_type, b_type, c_type, transpose_b]): Compile-time MatmulConfig selecting the block tile, warp tile, MMA shape, and pipeline stages for the kernel.

Args:

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, ComputeFnType: ElementwiseComputeFn, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b]](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], runtime_config: MatmulConfig[a_type, b_type, c_type, transpose_b], compute_fn: ComputeFnType, ctx: DeviceContextBase)

Runs multistage_gemm with runtime config, storing compute_fn(idx, a @ b) into c.

Parameters:

  • ​c_type (DType): DType of the output tile c elements (inferred).
  • ​a_type (DType): DType of the input tile a elements (inferred).
  • ​b_type (DType): DType of the input tile b elements (inferred).
  • ​ComputeFnType (ElementwiseComputeFn): Type of compute_fn (inferred).
  • ​transpose_b (Bool): Whether b is accessed transposed, so its row y is read as b[y, i] instead of b[i, y].
  • ​config (MatmulConfig[a_type, b_type, c_type, transpose_b]): Compile-time MatmulConfig selecting the block tile, warp tile, MMA shape, and pipeline stages for the kernel.

Args:

Was this page helpful?