Kernels
Scope
The GPU kernels the project proves things about: the ones in the corpus (tests/corpus) and the ones it means to add. A card is one kernel family, one source definition with all the specializations the corpus has of it, and names the TorchLean operation the kernel computes. Each card says whether what is proved covers one kernel or the family. Kernel cards climb the kernel ladder of roadmap/README.md: L1 a GPU run (a conformance test, not a proof), L2 the kernel theorem, L3 TorchLean over the reals, L4 an IEEE bound or the exact bits.
Reference: the Modular repository at commit bbc13a71 for the kernels from Modular (each card's ref names the file and line, and its quote is that line), and this repository for vector_multiply.
Cards
- vadd: vector_addition,
TorchLean.Tensor.add; the kernel theorem, the TorchLean equality and the rounding are proved for its one kernel. - vmul: vector_multiply,
TorchLean.Tensor.mul; as vadd, for its one kernel. - vsub: the tutorial's vector subtraction,
TorchLean.Tensor.sub; as vadd, for its one kernel, from onemojo_kernelcommand. - naive-matmul: matmul_kernel_naive,
TorchLean.Tensor.matmul; 13 specializations and 10 built without contraction; its blocks are checked, every thread runs toretat one launch and, from premises, at every launch; no kernel theorem. - gemv: gemv_kernel,
TorchLean.Tensor.matVecLoop; no corpus file. - reduction: sum_kernel,
TorchLean.Tensor.sum; one corpus file. - layernorm: layer_norm_gpu,
TorchLean.Tensor.layerNorm; 34 specializations. - rms-norm: rms_norm_gpu,
TorchLean.Tensor.rmsNorm; no corpus file. - softmax: softmax_kernel,
TorchLean.Tensor.softmax; no corpus file. - multistage-gemm: multistage_gemm,
TorchLean.Tensor.matmul; 24 specializations, all refused by the importer. - split-k-reduce: the split-k GEMM's reduction,
TorchLean.Tensor.sum; 12 specializations. - tiled-matmul: tiled_matmul_kernel,
TorchLean.Tensor.matmul; one corpus file. - layout-mma: the layout tensor-core tests,
TorchLean.Tensor.matmul; 13 corpus files.
Open
A kernel passes L0 only with a tracked record of a GPU run of it (L1), a conformance test of the evaluator against the GPU and not a proof; STATUS.md lists the cards that have one. vadd, vmul and vsub have their L2, L3 and L4 evidence. The next kernel theorems need the block checker to take loops (the naive matmul), barriers (the reduction, the tiled matmul) and shuffles (layer norm).
Status of the cards
From roadmap/status.yaml, which the roadmap script writes from the code.
| Card | Kind | Level | Evidence above the level | Next | Corpus kernels |
|---|---|---|---|---|---|
| gemv: gemv_kernel, a matrix-vector product (TorchLean.Tensor.matVecLoop) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 2 |
| layernorm: layer_norm_gpu, the 34 row-wise layer norm specializations (TorchLean.Tensor.layerNorm) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 34 |
| layout-mma: the layout tensor-core tests, mma_layout_tc, matmul_naive and c_fragment_kernel (TorchLean.Tensor.matmul) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 13 |
| multistage-gemm: multistage_gemm, the tiled tensor-core GEMM with asynchronous copies (TorchLean.Tensor.matmul) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 24 |
| naive-matmul: matmul_kernel_naive, one thread per output cell of C = A B (TorchLean.Tensor.matmul) | kernel | L4 | - | top level | 24 |
| reduction: sum_kernel, a block sum in shared memory with one atomic add per block (TorchLean.Tensor.sum) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 1 |
| rms-norm: rms_norm_gpu, root mean square normalization (TorchLean.Tensor.rmsNorm) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 0 |
| softmax: softmax_kernel, the row-wise softmax (TorchLean.Tensor.softmax) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 0 |
| split-k-reduce: matmul split-k reduce, the sum of the partial products of a split GEMM (TorchLean.Tensor.sum) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 12 |
| tiled-matmul: tiled_matmul_kernel, a matmul by shared-memory tiles (TorchLean.Tensor.matmul) | kernel | L0 | - | L1 needs a recorded GPU run (a conformance test, not a proof) | 1 |
| vadd: vector_addition, the elementwise sum of two float32 vectors (TorchLean.Tensor.add) | kernel | L4 | - | top level | 1 |
| vmul: vector_multiply, the elementwise product of two float32 vectors (TorchLean.Tensor.mul) | kernel | L4 | - | top level | 1 |
| vsub: vector_subtraction, the tutorial's elementwise difference of two float32 vectors (TorchLean.Tensor.sub) | kernel | L4 | - | top level | 1 |