The multistage GEMM
multistage_gemm, the tiled tensor-core GEMM with asynchronous copies (TorchLean.Tensor.matmul)
- Area
- Kernels
- Kind
- kernel
- Level
- L0 (card written). Next: L1 needs a recorded GPU run (a conformance test, not a proof).
- Evidence present above the level
- None above the level.
- Reference
modular/modular@bbc13a71:max/kernels/src/linalg/matmul/gpu/__init__.mojo:2492- Quote
def multistage_gemm[
- Lean declarations
TorchLean.Tensor.matmul
- Corpus files
24 kernel files (
.ll) in the corpus.- Tests
MojoProofTest.Corpus
- Upstream issue
- https://github.com/modular/modular/issues/7735
- Depends on
- gpu-model/mma, gpu-model/ldmatrix, gpu-model/cp-async, gpu-model/shared-memory, gpu-model/barriers, kernels/split-k-reduce
The rule. C = A B, computed by tiles: copies of tiles of A and B into shared memory (cp.async), loads of fragments (ldmatrix), and tensor-core multiply-accumulates (mma), over several stages in flight.
What is in the code. 24 corpus specializations of multistage_gemm_kernel and of its
split-k form (float32, bfloat16 and float8 inputs, with and without an epilogue function). 22
import: the importer accepts their inline asm cp.async.cg.shared.global copies
(MojoProof/LLVM/Asm.lean) and refuses the 2 float8 ones at a cvt.rn.satfinite.e4m3x2.f32
(tests/corpus/REFUSALS.tsv). exec faults at the copies, and the evaluator has no grid semantics
for ldmatrix and mma yet (their models, MojoProof.Sem.mmaStep, MojoProof.Sem.ldmatrix
and MojoProof.Sem.Async, are not dispatched).
Open. The grid's dispatch of the copies, ldmatrix and mma to their models, then every
level above L0.