A Triton BF16 GEMM within 3% of cuBLAS across an LLM shape sweep on H100
On this page15 sections
Difficulty 27: compiler heuristics and scheduling on a well-understood operation; slightly above the FP8 parity task (24) because the kernel author cannot hand-place warps and the tuning budget is capped. Application value 45: matters wherever fused epilogues are written in Python. Leverage 30: decides how close torch.compile output gets to vendor GEMMs.
The problem
Can a Python-level Triton matrix multiply match the closed vendor library within 3% on 40 real sizes?
- 1cuBLAS is closed and heavily tuned
- 2Real shapes are thin, wide and awkward
- 3Triton needs Hopper features and tuning
- 4At most 20 settings per shape
- 5Python-level code at vendor speed
What is asked. Triton lets a programmer write a GPU kernel in Python for whole tiles of a matrix, and a compiler handles the details of threads and memory (see the Triton entry). PyTorch's compiler generates Triton code automatically. The problem asks whether a Triton matrix multiply in BF16 (16-bit floats, with sums kept in 32-bit) can run at 97% or more of NVIDIA's cuBLAS library on one H100. It must do this on every one of 40 shapes taken from real language models. Autotuning may try at most 20 configurations per shape.
Why the hard shapes matter. Multiplying an matrix by a one costs operations. When , that is about operations, a few milliseconds of tensor-core work, and many tile layouts reach near-peak speed. The 40 shapes also include from 1 to 64, where a model is generating text and the kernel mostly waits on memory. They include sizes that are not multiples of the tile, which leave part of the chip idle in the last round of tiles. And they include cases where the best kernel stays resident on the chip and loops over tiles, rather than launching one thread block per tile. cuBLAS handles these with heuristics and many precompiled variants, picked per shape. A Triton kernel has one source and a handful of parameters (tile sizes, pipeline depth, number of warps). The compiler must turn them into the asynchronous, warp-specialised code that Hopper needs. The analogy is a tailor-made suit versus an adjustable off-the-rack one. It breaks because the "adjustments", autotuning, can be searched by machine, but the search budget here is capped at 20 tries.
State of the art. Triton's tutorial matrix multiply and tuned variants reach a large fraction of cuBLAS on large square shapes in public benchmarks. Recent releases add Hopper's asynchronous copies and warp specialisation. Kernel authors report gaps on skinny, odd-sized and persistent-scheduling shapes, but no source gives a number across a full sweep. The 3% bar with a 20-configuration budget is a deliberate stretch.
What a solution looks like. A public Triton kernel at a pinned release, timed against cuBLAS on one H100 on all 40 published shapes, at 97% or more each time, with error no worse than 1.1 times cuBLAS's. A second party must rerun it.
Go deeper
The full technical text.
Using only upstream Triton language features (a pinned public release), write a BF16 GEMM with FP32 accumulation whose median throughput on one H100 SXM is at least 97% of cuBLAS on every shape in a sweep of 40 LLM projection shapes (M from 1 to 16384, N and K from the Llama-3 8B/70B and Mixtral families), including skinny and non-tile-multiple shapes, using autotuning limited to 20 configurations per shape.
Words on this page (10)
- Triton
- A Python-embedded language in which a GPU kernel is written for whole tiles; its compiler handles the low-level details.
- GEMM
- General matrix multiply, C = A·B: the operation that takes most of the arithmetic in neural networks.
- cuBLAS
- NVIDIA's closed-source library of tuned linear-algebra routines, the usual speed baseline for matrix multiply.
- compiler
- A program that translates code from one language into machine instructions.
- autotuning
- Trying several settings of a kernel (tile sizes, pipeline depth) by timing them, and keeping the fastest.
- tensor core
- A unit inside each GPU core that multiplies small matrix tiles in one instruction, much faster than ordinary arithmetic.
- Hopper (H100)
- NVIDIA's 2022 data-centre GPU generation; the H100 is its main chip.
- warp specialisation
- Giving different groups of GPU threads different jobs, for example some load data while others compute, so the two overlap.
- PyTorch
- The open-source Python library in which most neural networks are written; its built-in operators are the baseline here.
- kernel (GPU)
- A function that runs on the GPU, executed by thousands of threads in parallel.
New to this? Read first (3)
- Triton documentation and tutorialsOfficial introduction with runnable examples.
- How to Optimize a CUDA Matmul Kernel for cuBLAS-like Performance (Simon Boehm)Step-by-step matrix multiplication kernel, from slow to fast, with measurements.
- Making Deep Learning Go Brrrr From First Principles (Horace He)A readable tour of compute-bound versus memory-bound work on GPUs.
Built from
earlier problems → this oneThe earlier problems this one is built from. “Builds on” means it needs their progress or tools. “Generalizes” means they are special cases that come first. “Implies” means they are weaker results on the way. On the right is what builds on this problem.
- Start with
- A Triton BF16 GEMM within 3% of cuBLAS across an LLM shape sweep on H100This problem
- Then
- An autotuner that finds configurations within 2% of the best in 20 trialsKernel Languages & Compilers · D41
Path to understanding
foundations → problemThe research entries this problem rests on, in the order to read them. Each links to its explainer.
- Start with
- Step 2
- Tiled GEMM on tensor cores (CUTLASS and CuTe)Algorithm
- PyTorchLibrary
- Step 3
- Then
- A Triton BF16 GEMM within 3% of cuBLAS across an LLM shape sweep on H100The problem
State of the art
Triton's tutorial GEMM and tuned variants reach a large fraction of cuBLAS on large square shapes in public benchmarks, and recent Triton releases support TMA and warp-specialised pipelines on Hopper. The gap on skinny, odd-sized and persistent-scheduling cases is reported by kernel authors but the curator found no primary source that fixes a single number across a full sweep. The 3% bar with a bounded tuning budget is a deliberate stretch; it should be confirmed as open against current Triton benchmarks.
Realistic applications
If a compiler-language GEMM reaches vendor parity, fused GEMM epilogues and custom quantisation schemes can be written without leaving Python.
What counts as solved
A public kernel and sweep at pinned versions that meets the bar on all 40 shapes, rerun by a second party.
How it gets verified
To verify: GPU benchmarkA kernel run and timed on stated hardware against a baseline.
Hardware: one H100 SXM 80 GB. Dtypes: BF16 inputs and output, FP32 accumulation. Shapes: 40 listed (M, N, K) triples published in the harness repo, covering decode (M 1 to 64), prefill (M 2048 to 16384) and non-multiples of 128. Baseline: cuBLAS (cublasLt) from CUDA 12.8 or later, exact version recorded, via torch.matmul with the version of PyTorch recorded. Metric: median TFLOP/s over at least 100 iterations after warmup, CUDA events, tuning time excluded but reported with a limit of 20 configurations per shape. Correctness: max relative error versus FP32 reference no more than 1.1x that of cuBLAS. Harness: public script at a pinned commit and Triton release.
Claims
No claimed results on this problem.
Where the work is
Compiler engineering and per-shape tuning, measured on H100.
Connected problems
- This problem is related to An open FP8 GEMM kernel matching cuBLAS across LLM shapes on H100Both ask whether non-vendor code can match cuBLAS; one in a compiler language, the other with hand-written tiling.
- This problem is needed by An autotuner that finds configurations within 2% of the best in 20 trialsA good tuner is the practical route to closing the Triton versus cuBLAS gap per shape.