A self-study course
GPU Kernel Optimization 101
From threads and warps to assembly-level search and LLM agents: the foundations, a reading list of fourteen works, and the wider field around them.
Nine parts · foundations first, then the papers · early charts measured on an RTX 3060
Orientation
Course map
0 · Orientation
What a kernel is, why speed varies, and the map used throughout.
1 · The machine
Threads, warps, memory and the compile pipeline.
2 · The craft
The classic hand techniques, each with a measurement.
3 · Expert-designed kernels
FlashAttention, Mamba, and what experts built since.
4 · Operators and compilers
Canvas and GOS; then Mirage and the kernel compilers.
5 · Below the compiler
CuAsmRL, AsmEvo, autosass, CASS, PTXBench; GPU cores.
6 · LLM agents
MARCO, CUDAMaster, CUDA-Harness, AutoKernel, MOPS.
7 · The wider field
Industry labs, universities, and how agents are measured.
8 · Synthesis
Maps, who is doing what, pitfalls and next steps.
Three questions to ask of every work in Parts 3–7
1 · At which level does it change the kernel?
2 · Who or what does the searching?
3 · How does it know the result is still correct?
Orientation
Four meanings of “kernel”
Compute kernel
A function that runs on the GPU, executed by many threads at once. In CUDA it is marked __global__.
Examples: SAXPY, matrix multiply, attention, a fused normalization layer.
This course: Parts 1–3, 5–7
Convolution kernel
The small weight pattern a layer slides over its input; more loosely, the layer-level operator itself.
Examples: a 3 × 3 convolution, a depthwise convolution, the operators Canvas discovers.
This course: Part 4
Kernel function
A similarity measure k(x, y) used by kernel methods such as SVMs and Gaussian processes.
Example: the Gaussian (RBF) kernel drawn above.
Not in this course
OS kernel
The core of an operating system, sitting between programs and hardware.
Example: Linux. The GPU driver that loads compute kernels runs partly inside it.
Not in this course
The word is overloaded. In this course, “kernel” means a compute kernel unless a slide says otherwise.
Orientation
Why optimization matters
The same GPU computes the same matrix product 9.8 times faster, depending only on how the kernel is written.
Time to multiply two 2048 × 2048 matrices (lower is better)
Naive kernel
21.5 ms
+ shared-memory tiles
18.7 ms
+ register tiles
3.2 ms
cuBLAS library
2.2 ms
All four produce the same result. Each step is a technique from Part 2; a vendor library such as cuBLAS stacks still more of them.
31×
slower when the same 256 MB of data is read in scattered order instead of sequential order (50.6 ms vs 1.64 ms).
3.0×
faster when three element-wise steps are fused into one pass over memory (1.61 ms vs 4.84 ms).
Measured for this course on an NVIDIA RTX 3060, CUDA 12.8, FP32, median of repeated runs. Parts 1 and 2 explain each gap.
Orientation
The optimization ladder
Six levels at which a kernel can be changed, with the works of this course that operate at each.
1
Algorithm
The order in which the math is carried out. The result stays exact.
FlashAttention
Mamba
Part 3
2
Operator
What a layer computes. Accuracy may change and must be re-checked.
Canvas
GOS
Part 4
3
Kernel source
The CUDA or Triton code: layout, tiling, fusion, launch shape.
AutoKernel
CUDAMaster
CUDA-Harness
Agentic Kernel Opt.
MARCO
Part 6
4
Schedule
Loop order, tile sizes and kernel boundaries chosen by a compiler.
Mirage · TorchInductor · Helion
Part 4
5
PTX
Virtual assembly, including instructions for one GPU generation.
PTXBench
Part 5
6
Machine code
Instruction order, register choice and scheduling bits in SASS or AMD assembly.
CuAsmRL
autosass
AsmEvo
CASS
Part 5
Higher levels give larger gains per change; lower levels give gains no compiler finds. MOPS (Part 6) is the same pattern in robotics.
Part 1
The machine
Before optimizing a kernel you need a mental model of what executes it. This part builds that model from the bottom up.
Execution
Grids, blocks, threads and warps; what SIMT means.
Memory
Registers, shared memory, caches and HBM, and why bandwidth rules.
Compilation
From CUDA C++ to PTX to SASS, with a real listing.
Measurement
The roofline model and what profilers report.
Part 1 · The machine
CPU and GPU
CPU: a few fast, clever cores
- Typically 8 to 64 cores.
- Each core predicts branches, reorders instructions and owns deep caches.
- Built to finish one task as soon as possible: low latency.
GPU: thousands of simple cores
- Thousands of cores, grouped into streaming multiprocessors (SMs).
- Each core is simple: no speculation, little private cache.
- Built to finish many identical tasks per second: high throughput.
The RTX 3060 behind this course’s measurements has 28 SMs and 3,584 CUDA cores. Fast kernels keep them busy and fed with data.
Part 1 · The machine
Inside a GPU
108 streaming multiprocessors
L2 cache · 40 MB
One SM
Warp scheduler
64 FP32 cores
4 Tensor Cores
Register file · 256 KB
L1 cache + shared memory
192 KB
Global memory (HBM) · 40 GB · 1,555 GB/s
The drawing shows an A100. The H100 has the same parts in larger amounts.
| A100 (40 GB) | H100 (SXM5) | |
|---|---|---|
| Streaming multiprocessors | 108 | 132 |
| FP32 cores per SM | 64 | 128 |
| Tensor Cores per SM | 4 | 4 |
| L1 + shared memory per SM | 192 KB | 256 KB |
| L2 cache | 40 MB | 50 MB |
| Global memory | 40 GB | 80 GB |
| Memory bandwidth | 1,555 GB/s | 3,352 GB/s |
| Peak FP32 | 19.5 TFLOPS | 66.9 TFLOPS |
| Peak FP16 on Tensor Cores | 312 TFLOPS | 989 TFLOPS |
Sources: NVIDIA A100 and H100 architecture whitepapers. KB and MB are binary units there.
Part 1 · The machine
Grid, blocks and threads
A kernel launch creates a grid of blocks; each block holds the same number of threads. Every thread runs the same function and differs only in its indices.
A thread finds its own piece of work by combining them:
int i = blockIdx.x * blockDim.x
+ threadIdx.x;
Threads in one block run on the same SM, can share fast memory and can wait for one another. Threads in different blocks cannot.
Grid: every block of one kernel launch
Block 0
Block 1
Block 2
Block 3
8 threads per block in this drawing; up to 1,024 in practice.
thread 3 of block 2:
i = 2 × 8 + 3 = 19
The array x[0] … x[31]: each thread handles one element.
Blocks are the unit the GPU schedules onto SMs. The programmer picks the block size and the number of blocks.
Part 1 · The machine
Warps and SIMT
The hardware groups a block’s threads into warps of 32. All 32 threads of a warp execute the same instruction in the same cycle, each on its own data. NVIDIA calls this SIMT: single instruction, multiple threads.
An SM holds many warps at once. Each cycle its scheduler issues instructions from warps that are ready.
Latency hiding
A load from global memory takes hundreds of cycles. While one warp waits, the SM runs others. Where the loads sit relative to the arithmetic therefore changes speed; Part 5 optimizes exactly that.
One streaming multiprocessor (SM)
Warp 0
running
Warp 1
waiting on memory
Warp 2
ready
Warp 3
waiting on memory
Warp 4
ready
The orange frame is the scheduler’s pick: it moves between warps that are ready and skips the ones waiting on memory.
Part 1 · The machine
Branch divergence
A warp has one program counter. When its threads disagree on a branch, the warp runs both sides in turn and masks off the threads that do not belong.
if (x[i] > 0)
y[i] = sqrtf(x[i]); // step 1
else
y[i] = 0.0f; // step 2
The usual cures
Replace short branches with a select (c ? a : b), or group similar data so that whole warps take the same side.
Step 1 · the if side: 15 threads work, 17 wait
Step 2 · the else side: 17 threads work, 15 wait
Without divergence: all 32 threads work in every step
Blue and orange mark working threads; grey threads are masked off.
Compilers turn small branches into selects on their own; long or nested divergent paths are the ones that cost.
Part 1 · The machine
The memory hierarchy
Level (bar width hints at capacity)
Capacity on an A100
Access latency
Bandwidth
Registers
256 KB per SM
no extra cycles
Shared memory and L1
192 KB per SM
19 to 28 cycles
≈ 19 TB/s
L2 cache
40 MB
≈ 190 cycles
Global memory (HBM)
40 GB
375 to 1,030 cycles
1.5 TB/s
Host memory (CPU DRAM)
over 1 TB
across PCIe
32 GB/s
The rule behind most of this course: keep the data you are working on as high in this list as you can, and cross the HBM line as rarely as you can. On-chip memory is about twelve times faster than HBM and two thousand times smaller.
Capacities: NVIDIA A100 whitepaper. Bandwidths: FlashAttention Fig. 1 (SRAM estimated). Latencies: V100, Jia et al. 2018.
Part 1 · The machine
A first kernel: SAXPY
SAXPY computes y = a·x + y over two long arrays: the “hello world” of GPU programming.
// 1 runs on the GPU, once per thread
__global__ void saxpy(int n, float a,
const float *x, float *y)
{
// 2 which element is mine?
int i = blockIdx.x * blockDim.x + threadIdx.x;
// 3 the grid may be larger than n
if (i < n)
y[i] = a * x[i] + y[i];
}
// 4 on the CPU: launch blocks of 256 threads
saxpy<<<(n + 255) / 256, 256>>>(n, 2.0f, x, y);
1 · __global__
Marks a function as a kernel: compiled for the GPU and callable from the CPU.
2 · Thread index
The only thing that differs between threads; the rest is shared code.
3 · Bounds check
The grid is a whole number of blocks, so the last block may have spare threads.
4 · Launch
The angle brackets set the grid: how many blocks, and how many threads in each.
This exact file is compiled on the next slides to show its PTX and SASS.
Part 1 · The machine
From source to machine code
CUDA C++
What you write. Other front ends, such as Triton, join the pipeline further down.
NVVM IR
LLVM IR with GPU rules. Classic compiler optimizations run here.
PTX
Virtual assembly: typed, documented, portable across GPU generations.
SASS
Machine code for one architecture, stored in a cubin. Only partly documented.
GPU
Runs the cubin. If only PTX was shipped, the driver compiles it at load time.
nvcc front end
NVVM compiler
ptxas
CUDA driver
See it yourself
nvcc -ptx saxpy.cu
nvcc -cubin saxpy.cu
cuobjdump -sass saxpy.cubin
Two kinds of assembly
PTX is a stable contract: code written for an older GPU still compiles for a newer one. SASS changes with every architecture: sm_80 for the A100, sm_86 for RTX 30, sm_90 for the H100.
Why this matters later
Every arrow is a place where an optimizer can step in: the source (Parts 2, 3 and 6), PTX (PTXBench) and SASS (CuAsmRL, autosass).
Sources: NVIDIA nvcc, PTX ISA, NVVM IR and CUDA Binary Utilities documentation.
Part 1 · The machine
One line at three levels
CUDA C++
what you write
y[i] = a * x[i] + y[i];
One line, no hardware detail.
PTX
virtual assembly
nvcc -ptx
ld.global.f32 %f2, [%rd6]; // x[i]
ld.global.f32 %f3, [%rd7]; // y[i]
fma.rn.f32 %f4, %f2, %f1, %f3;
st.global.f32 [%rd7], %f4;
Two loads, one fused multiply-add, one store. Registers are virtual (%f2, %rd6) and every operation names its type (.f32).
SASS
machine code for sm_86
cuobjdump -sass
LDG.E R2, [R2.64] ;
LDG.E R7, [R4.64] ;
FFMA R7, R2, c[0x0][0x164], R7 ;
STG.E [R4.64], R7 ;
The same four steps on real registers. The scalar a is read from the kernel’s constant bank. Each instruction also carries scheduling bits not shown here; Part 5 edits those.
Real output for the SAXPY kernel of the previous slide: CUDA 12.8, nvcc -O3, target sm_86 (RTX 3060). Address arithmetic omitted.
Part 1 · The machine
The roofline model
0.01
0.01
0.1
0.1
1
1
10
10
100
100
1,000
1,000
Arithmetic intensity (FLOPs per byte moved)
Attainable TFLOP/s
Element-wise add: 0.08 FLOP/byte, memory-bound
Large matmul:
compute-bound
ridge point:
12.5 FLOP/byte
Tensor Cores: 312 TFLOP/s
FP32 cores: 19.5 TFLOP/s
A kernel can go no faster than its arithmetic units allow, and no faster than memory can feed them:
speed ≤ min(peak FLOP/s, bandwidth × intensity)
Left of the ridge the kernel is memory-bound: the only way up is to move fewer bytes per operation (coalescing, tiling, fusion).
Right of the ridge it is compute-bound: use faster units (Tensor Cores) or waste fewer cycles (scheduling).
An A100 moves 1,555 GB/s and computes 19.5 TFLOP/s in FP32, so the ridge sits at 19,500 ÷ 1,555 ≈ 12.5 FLOPs per byte.
Model: Williams, Waterman and Patterson, CACM 2009. Peaks from the NVIDIA A100 whitepaper; both axes are logarithmic.
Part 1 · The machine
Measuring a kernel
Where does the time go?
Nsight Systems
One timeline for the whole application: CPU threads, CUDA API calls, every kernel and memory copy. Use it first, to find which kernel matters.
Why is this kernel slow?
Nsight Compute
Hardware counters for one kernel: memory throughput, occupancy, why warps stall, a roofline chart, and hot spots mapped to source, PTX and SASS lines.
Which operator is expensive?
PyTorch profiler
Per-operator CPU and GPU time inside a model, with input shapes and the names of the kernels each operator launched.
Speedup
Baseline time divided by optimized time, on the same inputs and the same GPU. Report the baseline: 2× over a naive kernel and 2× over cuBLAS are different claims.
Honest timing
Kernel launches return before the work is done. Synchronize or use CUDA events, warm up first, repeat, and report the median.
“100% GPU utilization”
nvidia-smi reports the share of time in which some kernel was running. A kernel stalled on memory still reads 100%.
Sources: NVIDIA Nsight Compute, Nsight Systems and nvidia-smi documentation; PyTorch profiler documentation.
Part 1 · The machine
Check your understanding
Question 1
A kernel is launched with 100 blocks of 256 threads each. How many warps does it create?
100 × 256 ÷ 32 = 800 warps.
Question 2
Why is an element-wise addition memory-bound on every current GPU?
It does 1 FLOP for 12 bytes moved (0.08 FLOP/byte), far left of the ridge point (12.5 on an A100).
Question 3
Which survives a move to a newer GPU generation: PTX or SASS?
PTX. SASS is specific to one architecture and must be regenerated.
Question 4
nvidia-smi shows 100% utilization. Is the kernel using the GPU well?
Not necessarily: it only means some kernel was running during the sample period.
Answers appear one at a time: press the right arrow or click.
Part 2
The craft
The classic techniques experts apply by hand. Each removes one kind of waste, and each is measured here on the same RTX 3060.
Memory access
Coalescing: make a warp’s loads line up.
Reuse
Tiling with shared memory and registers.
Fewer passes
Fusion and pipelining: move bytes once, and on time.
Hardware fit
Occupancy, Tensor Cores, and the search space they create.
Part 2 · The craft
Memory coalescing
Coalesced: thread i reads element i. The warp’s loads merge into a few wide transactions.
Scattered: every thread needs its own transaction, and most of each fetched line is wasted.
Time to read and write 256 MB, in ms (lower is better)
thread i touches element i
thread i touches element i × stride
Same kernel, same amount of data: 327 GB/s when coalesced, 10.6 GB/s when scattered. The fix is usually a data-layout change, such as a structure of arrays instead of an array of structures.
Measured on an RTX 3060 (peak memory bandwidth 360 GB/s). Transaction rule: NVIDIA CUDA Best Practices Guide.
Part 2 · The craft
Tiling with shared memory
In C = A·B every element of A and B is needed by many threads. A naive kernel fetches it from global memory each time. A tiled kernel copies one 32 × 32 tile of A and of B into the block’s shared memory, and all 1,024 threads reuse it.
__shared__ float sA[32][32], sB[32][32];
for (int t = 0; t < N / 32; t++) {
sA[ty][tx] = A[row * N + t * 32 + tx];
sB[ty][tx] = B[(t * 32 + ty) * N + col];
__syncthreads(); // tile is loaded
for (int k = 0; k < 32; k++)
s += sA[ty][k] * sB[k][tx];
__syncthreads(); // tile is used up
}
A
B
C = A · B
Shared memory of one block
sA and sB, 32 × 32 each
load each tile once
use it 32 times
Measured: only 1.15× (21.5 → 18.7 ms), because caches already help the naive kernel. FlashAttention reuses this exact pattern.
2048 × 2048 FP32 matrices on an RTX 3060. The blue squares sweep along the tiles the block visits.
Part 2 · The craft
Kernel fusion
Three kernels
One fused kernel
Global memory (HBM)
Global memory (HBM)
scale
add
ReLU
x
t₁
t₁
t₂
t₂
y
scale → add → ReLU, intermediates stay in registers
x
y
Element-wise operations are memory-bound: their cost is the bytes they move. Run separately, y = ReLU(a·x + b) reads or writes 256 MB six times. Fused, it does so twice.
The measured 3.0× equals the ratio of bytes moved, 6 to 2. Compilers such as TVM and XLA fuse automatically; hand-written kernels fuse further.
2^26 FP32 elements on an RTX 3060. Caveat: training needs the intermediates for the backward pass; Part 3 shows the way around it.
Part 2 · The craft
Occupancy and register pressure
Occupancy is the share of an SM’s warp slots that a kernel fills. An A100 SM has 64 slots (2,048 threads) and 65,536 registers to divide among them.
Maximum occupancy on an A100 SM, by registers per thread
32 registers per thread
100%
2,048 threads
64 registers per thread
50%
1,024 threads
128 registers per thread
25%
512 threads
255 registers per thread
12.5%
256 threads
The more registers a thread uses, the fewer threads fit. Shared memory per block limits occupancy in the same way.
Why high occupancy helps
More resident warps give the scheduler more to run while others wait on memory: better latency hiding.
Why it is not the goal
Registers are the fastest storage there is. A thread holding an 8 × 8 tile of results in registers lowers occupancy and still wins.
NVIDIA’s guidance: higher occupancy does not always mean higher performance, but low occupancy always weakens latency hiding. It is a knob to tune, not a score to maximize.
Limits from the CUDA Programming Guide, compute capability 8.0. The fourth row is the per-thread maximum of 255 registers.
Part 2 · The craft
Tensor Cores and mixed precision
A Tensor Core is a hardware unit that does one thing: a small matrix multiply-accumulate, D = A·B + C, in a single step.
On an A100 each Tensor Core performs 256 fused multiply-adds per clock, and there are four per SM. Ordinary cores do one per clock.
Mixed precision
Tensor Cores want 16-bit or 8-bit inputs. Models therefore run matrix multiplies and convolutions in FP16 or BF16, and keep range-sensitive steps such as reductions in FP32.
Consequence for kernel design: whatever is not a matrix multiply is about 16 times more expensive per FLOP. FlashAttention-2 and -3 are largely about shrinking that remainder.
Peak throughput in TFLOP/s (higher is better)
general-purpose FP32 cores
Tensor Cores, FP16 matrix multiply
Sources: NVIDIA A100 and H100 architecture whitepapers (dense figures); FlashAttention-2 for the 16× remark.
Part 2 · The craft
Overlapping loads and compute
A load from global memory takes hundreds of cycles. Pipelining issues the load for the next tile before computing on the current one.
One after the other
Pipelined
load 1
compute 1
load 1
compute 1
load 2
compute 2
load 2
compute 2
load 3
compute 3
load 3
compute 3
load 4
compute 4
load 4
compute 4
time saved
time
In CUDA source
Since Ampere, an asynchronous copy moves data from global to shared memory in the background while the SM computes. Kernels keep two or more tiles in flight: double buffering.
On newer hardware
Hopper adds the Tensor Memory Accelerator, which moves whole tiles with one instruction. FlashAttention-3 gives a dedicated group of warps the single job of issuing those loads.
One level down
The same idea at the scale of single instructions is SASS scheduling: issue the next load before the arithmetic that hides its latency. CuAsmRL learns such orders in Part 5.
Sources: NVIDIA A100 and H100 architecture whitepapers; CUDA Programming Guide (asynchronous copies, pipelines); FlashAttention-3.
Part 2 · The craft
Worked example: matrix multiply
2048 × 2048 FP32 matrix multiply, TFLOP/s (higher is better)
kernels written for this course
vendor library, for reference
Naive
One thread per output element. Every operand comes from global memory.
Shared-memory tiles · 1.15×
Each loaded value is reused by all threads of the block.
Register tiles · 5.8× more
Each thread computes an 8 × 8 patch of outputs kept in registers, so one read from shared memory feeds eight multiply-adds.
cuBLAS · 1.46× more
The vendor library. Its source is closed; the remaining gap is tuning at every level, down to assembly.
The large step did not come from a faster instruction. It raised the arithmetic done per byte fetched: a move to the right on the roofline.
Measured on an RTX 3060, CUDA 12.8; every kernel checked against cuBLAS. About 40 lines of CUDA reach 68% of the library.
Part 2 · The craft
The search space
The register-tiled kernel under 12 settings of three knobs, TFLOP/s
K-step 8
K-step 16
K-step 32
64 × 64 block tile, 4 × 4 per thread
5.06
5.62
5.81
64 × 64 block tile, 8 × 8 per thread
5.41
6.05
6.14
128 × 128 block tile, 4 × 4 per thread
4.26
4.98
5.36
128 × 128 block tile, 8 × 8 per thread
5.52
6.26
6.27
Darker cells are faster. Worst 4.26, best 6.27: a 1.47× spread without changing a line of the algorithm.
The best setting is not the textbook default, and it moves with the GPU model and the matrix size.
A production kernel has dozens of such knobs, plus structural choices: what to fuse, what to pipeline, which precision, which instruction order. Nobody can try them all by hand.
The rest of the course is about who explores this space
Experts with insight (Part 3), search over operators (Part 4), search and learning at assembly level (Part 5), and LLM agents (Part 6).
Measured on an RTX 3060 at N = 2048; each configuration recompiled and checked against cuBLAS (7.82 TFLOP/s).
Part 2 · The craft
Check your understanding
Question 1
The threads of a warp read a[33 × i]. Are their loads coalesced?
No. Neighbouring threads are 132 bytes apart, so each needs its own transaction. This pattern ran 13× slower than stride 1.
Question 2
Why did fusing scale, add and ReLU give almost exactly 3×?
The work is memory-bound. Six passes over the data became two.
Question 3
Shared-memory tiles gave 1.15×, register tiles 5.8× more. Why the difference?
Caches already gave the naive kernel some reuse. Register tiles changed arithmetic per byte fetched.
Question 4
A kernel uses 64 registers per thread on an A100. What is its maximum occupancy?
65,536 ÷ 64 = 1,024 threads, or 32 of 64 warp slots: 50%.
Answers appear one at a time: press the right arrow or click.
Part 3
Expert-designed kernels
Two landmark kernels in which people redesigned the algorithm around the memory hierarchy. Their moves return in every later part.
FlashAttention
Exact attention without the N × N matrix in global memory, refitted twice to new hardware.
Mamba
A recurrence computed by one fused, scanning kernel.
Beyond the list
FlashAttention-4, ThunderKittens, FlashInfer and the languages experts now write in.
The playbook
Tile, fuse, recompute: and what it costs in expert time.
Part 3 · Expert-designed kernels
FlashAttention: the problem
Global memory (HBM)
Three kernels
matmul
softmax
matmul
Q, K
S
S
P
P, V
O
Thick orange arrows carry N × N matrices; thin blue ones carry N × d.
| GPT-2 medium, one A100 | Arithmetic | HBM read + write | Runtime |
|---|---|---|---|
| Standard attention | 66.6 GFLOPs | 40.3 GB | 41.7 ms |
| FlashAttention | 75.2 GFLOPs | 4.4 GB | 7.3 ms |
Attention computes O = softmax(Q·Kᵀ)·V. For a sequence of N tokens, the scores S and probabilities P are N × N, far larger than the N × d inputs.
A standard implementation writes S and P to global memory and reads them back. Masking and dropout add further N × N passes, and P must be kept for the backward pass.
The table is the whole argument: FlashAttention does more arithmetic and is 5.7× faster, because it moves a ninth of the bytes.
Dao, Fu, Ermon, Rudra, Ré. FlashAttention. NeurIPS 2022, arXiv 2205.14135. Table: their Fig. 2 (sequence 1,024, forward + backward).
Part 3 · Expert-designed kernels
FlashAttention: tiling the softmax
Tiling a matmul is easy. Softmax is the obstacle: each row needs its maximum and its sum over all columns before any entry can be normalized.
The answer is an online softmax: keep a running maximum m and running sum l per row, and rescale what has been accumulated whenever a new block raises the maximum.
# for row block i, visiting column blocks j = 1, 2, …
S = Q_i @ K_j.T # one tile
m_new = max(m, rowmax(S))
P = exp(S - m_new)
l = exp(m - m_new) * l + rowsum(P)
O = exp(m - m_new) * O + P @ V_j
m = m_new
# after the last block: O_i = O / l
K, V blocks →
Q block i
The N × N score matrix, cut into tiles
on chip:
m, l, O
for row
block i
The result is exactly softmax(Q·Kᵀ)·V: no approximation. Recurrence as in FlashAttention-2, Section 3.1 (arXiv 2307.08691).
Part 3 · Expert-designed kernels
FlashAttention: one fused kernel
for each row block Q_i: # independent
load Q_i into on-chip memory
m, l, O = -inf, 0, 0
for each block K_j, V_j:
load K_j, V_j
S = Q_i @ K_j.T # on chip
update m, l, O # on chip
write O_i = O / l to HBM
write L_i = m + log(l) to HBM
| HBM accesses | Extra memory | |
|---|---|---|
| Standard attention | Θ(N·d + N²) | Θ(N²) |
| FlashAttention | Θ(N²·d² / M) | O(N) |
Tile
Blocks of Q, K and V are sized to fit in on-chip memory. The N × N matrices never exist as a whole.
Fuse
Matmul, mask, softmax, dropout and the second matmul run in one kernel. Each input is read once.
Recompute
The backward pass rebuilds S and P on chip from Q, K, V and the saved statistics, instead of storing them. More FLOPs, fewer bytes, still faster.
M is the size of on-chip memory, with d ≤ M ≤ N·d. For typical values (d = 64 to 128, M ≈ 100 KB), d²/M is well below 1.
FlashAttention, Theorems 1 and 2. Loop order shown is FlashAttention-2’s, in which every row block can run in parallel.
Part 3 · Expert-designed kernels
FlashAttention: results and limits
Training GPT-2 small on 8 × A100 (lower is better)
standard attention
FlashAttention
3×
faster than PyTorch attention at sequence lengths up to 2K.
10–20×
less memory than exact baselines at 2K to 4K tokens.
What it bought
Longer contexts became affordable. PyTorch’s scaled_dot_product_attention can dispatch to it, and xFormers and Triton ship their own versions.
What it cost
A hand-written CUDA kernel per attention variant, hand-tuned block sizes, and, as the authors note, no guarantee of carrying over to another GPU architecture.
FlashAttention (arXiv 2205.14135), Table 2 and Section 4; repository README for the memory figures.
Part 3 · Expert-designed kernels
FlashAttention-2: fitting the thread hierarchy
1 · Less work that is not a matmul
On an A100, Tensor Cores make matmul FLOPs 16× cheaper than the rest. Version 2 stops dividing by l at every step and normalizes once at the end.
2 · Parallelism over the sequence
The loops are swapped so that every row block of Q is independent and gets its own thread block. Long sequences with small batches now fill all 108 SMs.
3 · Warps that do not talk
Splitting Q instead of K and V across the four warps of a block removes the shared-memory merge and its synchronization.
v1: warps split K and V
v2: warps split Q
warp 0
warp 0
rows
warp 1
warp 1
rows
warp 2
warp 2
rows
warp 3
warp 3
rows
shared memory: merge
partial sums must be merged
no communication needed
Share of the A100’s peak matmul throughput reached (forward pass)
FlashAttention
up to 40%
FlashAttention-2
up to 73%
Tuned matmul (GEMM)
80–90%
Dao. FlashAttention-2, arXiv 2307.08691 (2023). 1.7–3.0× faster than version 1 and 3–10× faster than PyTorch attention on an A100.
Part 3 · Expert-designed kernels
FlashAttention-3: fitting a new GPU
On the H100, FlashAttention-2 reached only 35% of peak. The third version rebuilds the kernel around Hopper’s asynchronous instructions.
Producer warps
Consumer group 1
Consumer group 2
load K, V block 2
matmul
softmax
load K, V block 3
softmax
matmul
load K, V block 4
matmul
softmax
load K, V block 5
softmax
matmul
load K, V block 6
matmul
softmax
load K, V block 7
softmax
matmul
Warp specialization
A producer group only issues loads, using Hopper’s Tensor Memory Accelerator. Consumer groups only compute, using the asynchronous Tensor Core instruction.
Softmax hidden under matmul
On an H100 exp runs at 3.9 TFLOP/s against 989 for matmul. Two consumer groups alternate, so one always keeps the Tensor Cores busy: 570 → 620–640 TFLOP/s.
FP8 without losing accuracy
8-bit Tensor Cores double throughput. Per-block scaling and a random rotation of Q and K cut the numerical error 2.6× against plain FP8.
Shah et al. FlashAttention-3, NeurIPS 2024 (arXiv 2407.08608v2): 1.5–2.0× over v2; up to 740 TFLOP/s in FP16, about 1.2 PFLOP/s in FP8.
Part 3 · Expert-designed kernels
Mamba: a selective state space model
Mamba replaces attention with a recurrence. A hidden state h is carried along the sequence, and each token updates it:
h[t] = A[t] * h[t-1] + B[t] * x[t]
y[t] = C[t] · h[t]
# selective: these depend on the input x[t]
A[t] = exp(Δ[t] * A)
B[t], C[t], Δ[t] = functions of x[t]
The systems problem. Earlier state space models had fixed A and B and could be computed as one convolution. Input-dependent parameters force an explicit scan over a state of shape (batch, length, channels, N): N times larger than the input, with N = 16.
x₁
h₁
y₁
x₂
h₂
y₂
x₃
h₃
y₃
x₄
h₄
y₄
Orange arrows are the “selective” part: each input sets its own A and B.
Gu and Dao. Mamba: Linear-Time Sequence Modeling with Selective State Spaces. arXiv 2312.00752 (2023), Sections 2 and 3.
Part 3 · Expert-designed kernels
Mamba: the hardware-aware scan
A direct implementation writes A[t], B[t] and every state to global memory. Mamba’s kernel applies FlashAttention’s three moves to a recurrence.
Fuse
One kernel reads the small inputs, expands A[t] and B[t] on chip, scans, applies C and writes only y. Memory traffic falls by a factor of about N.
Scan in parallel
Two steps (a₀, b₀) and (a₁, b₁) combine into (a₁·a₀, a₁·b₀ + b₁). The rule is associative, so neighbours can be combined in a tree.
Recompute
The states are not saved for the backward pass. They are rebuilt on chip from a few checkpoints.
3 parallel levels
instead of 7 steps in a row
Paper and code differ
The released kernel runs the tree scan only inside one thread block, over chunks of at most 2,048 steps. It is sequential across chunks and across the N state dimensions; most parallelism comes from giving every (batch, channel) pair its own block.
Mamba, Section 3.3 and Appendix D. Code: state-spaces/mamba, selective_scan_fwd_kernel.cuh (cub::BlockScan), December 2026.
Part 3 · Expert-designed kernels
Mamba: results and caveats
1
2
4
8
16
32
64
128
0
500
1,000
1,500
2,000
Batch size
Tokens per second
Mamba, 1.4 B parameters: 1,814
Transformer, 1.3 B:
364, then out
of memory
The kernel
20–40× faster than an unfused PyTorch scan. Faster than FlashAttention-2 beyond 2K tokens, and up to 7× faster at 32K.
Memory
Comparable to a Transformer that uses FlashAttention: 38.2 GB against 34.5 GB at batch 32 for 125 M-parameter models.
Read the headline carefully
“5× higher throughput” compares Mamba at batch 128 with the Transformer at batch 32, its largest that fits. At equal batch 32 the ratio is 4.0×; at batch 1 it is 1.8×.
Mamba, Section 4.5, Fig. 8 and Appendix D. A100 80 GB; prompt of 2,048 tokens, 128 generated; Transformer baseline from Hugging Face.
Part 3 · Expert-designed kernels · beyond the reading list
FlashAttention-4: the bottleneck moves again
Princeton, Meta, Colfax, NVIDIA, Together AI · MLSys 2026
From the H100 to the B200, Tensor Cores doubled. The exponential unit and shared-memory bandwidth did not. For one attention tile the matmul is no longer the largest cost:
Clock cycles per 128 × 128 × 128 tile on a B200 (paper’s model)
A ping-pong pipeline
Each thread block owns two query tiles. One warp group loads and issues matmuls, two take turns at softmax, one rescales the output.
Two kinds of exponential
A software polynomial computes 10–25% of each row’s exponentials while the hardware unit does the rest, so two unit types work at once.
Rescale only when needed
The output is rescaled only when the running maximum jumps by more than a factor of 256. A final normalization keeps the result exact.
On a B200: 1.1–1.3× over cuDNN 9.13, 2.1–2.7× over Triton. Written in Python (CuTe DSL): compiles in 2.5 s, against 55 s for version 3.
Zadouri, Hoehnerbach, Shah et al. FlashAttention-4. MLSys 2026, arXiv 2603.05451. Later cuDNN releases adopted these techniques.
Part 3 · Expert-designed kernels · beyond the reading list
ThunderKittens: a small kernel framework
Stanford Hazy Research · ICLR 2025, version 2.0 in 2026
Can a handful of opinionated abstractions reach the speed of NVIDIA’s template library? Three levels, one per level of the GPU:
Warp level: tiles
Small typed tiles in registers and shared memory, with PyTorch-like operations. A layout mismatch is a compile-time error.
Block level: a template
The programmer fills in load, compute, store and finish. Producer warps load; consumer warps compute. One integer sets the pipeline depth.
Grid level: persistence
Blocks are launched once and loop over the work, in an order chosen for cache reuse: 805 against 392 TFLOP/s from block order alone.
Matmul speed by pipeline depth, TFLOP/s on an H100 (higher is better)
Results and family
Attention backward 10–40% faster than FlashAttention-3. Version 2.0 matches or beats cuBLAS on Blackwell; HipKittens ports the ideas to AMD. In 2026 its authors predicted that coding agents will retire such DSLs.
Spector, Arora, Singhal, Fu, Ré. ThunderKittens. ICLR 2025, arXiv 2410.20399. Hazy Research blog, February and August 2026.
Part 3 · Expert-designed kernels · beyond the reading list
FlashInfer: attention kernels for serving
University of Washington, NVIDIA, CMU, Perplexity · MLSys 2025
Serving differs from training: caches are paged and shared, batches mix prefill and decode, and lengths change at every step.
Sparse cache format
The key-value cache is a block-sparse matrix: rows are query tiles, columns are cache pages. Shared prefixes are stored once.
Kernel template
FlashAttention-2 or -3 inside. Scattered pages are first gathered into contiguous shared memory.
Variants at run time
A new attention variant is a few code fragments; the template is filled in and compiled just in time.
Plan on the CPU
At each step a scheduler splits the work into chunks and gives each to the least-loaded thread block.
Run on the GPU
A persistent kernel with a fixed grid, so the whole step still fits in a CUDA graph.
Results
29–69% lower inter-token latency than a Triton backend on Llama 3.1 (H100). A fused position-encoding and attention kernel took about 20 extra lines.
Adoption
Used by SGLang, vLLM, TensorRT-LLM and others. NVIDIA now releases its own inference kernels into it.
The lesson
An inference kernel is a kernel plus a data structure plus a scheduler. Forward pass only.
Ye et al. FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving. MLSys 2025, arXiv 2501.01005.
Part 3 · Expert-designed kernels · beyond the reading list
More expert kernels worth reading
DeepSeek · February 2025
DeepGEMM
FP8 matrix-multiply kernels compiled just in time for each shape, in about 300 lines of core code. Its first release also patched scheduling bits in the SASS of its multiply-adds.
Up to 2.7× over the team’s CUTLASS-based version
The baseline is internal and unpublished.
Stanford Hazy Research · 2025
Megakernels
A whole forward pass as one persistent kernel that runs an interpreter on every SM, removing the stalls between about a hundred kernel launches.
Llama-1B in under 1 ms per pass on an H100
Research code, sensitive to compiler versions.
NVIDIA · June 2025
CUTLASS 4 and the CuTe DSL
NVIDIA’s kernel building blocks (layouts, atoms, pipelines) exposed in Python with full low-level control. FlashAttention-4 is written in it.
22× to 32× faster compiles than C++ templates
The programmer still specifies every layout.
LinkedIn · October 2024
Liger-Kernel
Short Triton kernels for LLM training: normalization, position encoding, fused loss. Gains come from fusion and in-place gradients.
20% more throughput, 60% less memory
An approachable first read in Triton.
DeepGEMM and Megakernels: project repositories and blog posts. CUTLASS: NVIDIA documentation. Liger-Kernel: arXiv 2410.10989.
Part 3 · Expert-designed kernels · beyond the reading list
The languages experts now write kernels in
In 2023 a fast kernel meant C++ templates or plain Triton. By 2026 the tooling had split into three tiers:
Expose everything, in a friendlier language
ThunderKittens · CuTe DSL · Gluon (Triton) · TLX (Meta) · Mojo
Infer layouts and pipelines for the programmer
TileLang · Hexcute · Cypress, Tawa, Twill · Pallas (Google) · Helion
A vendor tile abstraction beneath them all
NVIDIA CUDA Tile and Tile IR, from December 2025
Hexcute · Toronto and NVIDIA, CGO 2026
Solves for which thread holds which element. Attention 1.27× FlashAttention-3 in 212 lines, against 1,684.
TileLang · Peking and Microsoft Research, ICLR 2026
A decoding kernel at 98% of the hand-written one in about 70 lines.
Twill · NVIDIA and Stanford, OSDI 2026
Pipelining and warp roles as one constraint problem: it rederives FlashAttention-3’s schedule in 28 seconds.
TLX · Meta, 2026
Warp groups as the unit of orchestration. A production attention kernel in 3,200 lines, against about 10,000.
The pipelines of FlashAttention-3 and -4, found by experts, are now derivable by solvers and compilers.
Hexcute: arXiv 2504.16214. TileLang: arXiv 2504.17577. Twill: arXiv 2512.18134. TLX: arXiv 2605.10905. CUDA Tile: NVIDIA.
Part 3 · Expert-designed kernels
The expert’s playbook
| Move | FlashAttention | Mamba |
|---|---|---|
| Tile | Blocks of Q, K, V sized to on-chip memory | Sequence chunks of at most 2,048 steps |
| Fuse | Matmul, mask, softmax, dropout, matmul in one kernel | Discretize, scan and output projection in one kernel |
| Recompute | S and P rebuilt in the backward pass | States rebuilt from per-chunk checkpoints |
| Parallelize what is independent | One thread block per row block of Q | One thread block per (batch, channel) |
| Refit to the hardware | Rewritten for warps (v2), then for Hopper (v3) | CUDA only; later versions moved to Triton |
What the playbook delivers
Large factors: 3× to 10× on attention, 20× to 40× on a scan. These come from the top of the ladder, where an insight changes how many bytes cross the HBM line.
What it costs
Scarce experts and months of work per kernel, repeated for each new GPU generation: FlashAttention has needed four versions since 2022, one per hardware shift, with block sizes tuned by hand.
The question for Parts 4 to 7
How much of this can a machine do: by searching over operators, by searching below the compiler, or by letting an LLM agent run the whole loop?
Sources as on the previous slides. Mamba-2’s state-passing kernel is written in Triton (state-spaces/mamba, issue 443).
Part 4
Operators and compilers
Two kinds of machine search that need no agent: changing what a layer computes, and letting a compiler decide how kernels are formed.
The map
Architecture search, tensor compilers and operator search compared.
Canvas and GOS
New operators from fine-grained primitives and from mathematical instructions.
Relatives
AutoML-Zero, AlphaTensor and Syno.
Beyond the list
Mirage, TorchInductor, Helion, and compilers that derive FlashAttention.
Part 4 · Operators and compilers
Where operator search sits
Tensor compilers
Architecture search
Operator search
From-scratch search
less is allowed to change
more is allowed to change
| Approach | What is searched | What stays fixed | Examples |
|---|---|---|---|
| Tensor compilers | The loop schedule of one operator | The operator’s mathematics | Halide, TVM, Ansor, MetaSchedule |
| Architecture search (NAS) | Which predefined layers, and how they are wired and sized | The operators themselves | MnasNet, ProxylessNAS, FBNet, Once-for-All |
| Operator search | The mathematics of the operator | The network’s backbone | Canvas, GOS, Syno |
| From-scratch search | The whole learning algorithm | Almost nothing | AutoML-Zero |
Compilers preserve the result
Ansor: up to 1.7× on NVIDIA GPUs over earlier auto-tuners, with no effect on accuracy.
NAS picks from a menu
MnasNet: 1.8× faster than MobileNetV2 on a phone, at 0.5% higher accuracy.
Operator search invents the menu
Larger possible gains, at a new cost: every candidate must be trained to see whether it still works.
Sources: Ansor (OSDI 2020), MnasNet (CVPR 2019), Canvas (arXiv 2304.07741), GOS (arXiv 2309.11246), AutoML-Zero (ICML 2020).
Part 4 · Operators and compilers
Canvas: kernels as small graphs
Kernel architecture search treats a kernel as a small graph: nodes are tensor shapes, edges are fine-grained primitives. New kernels are built from scratch and dropped into an unchanged backbone in place of its convolutions.
The search is performance-first: runtime is the constraint, and accuracy is maximized inside it.
The eight primitives
Rearrange: Group · Shift · Unfold
Move or regroup values. No weights.
Compute: FC · Element-wise · Fold · Softmax
FC is the only primitive with weights.
Blend: Broadcast add, sub, mul, min, max
Merge two branches of the graph.
A standard 3 × 3 convolution, decomposed
input
Unfold
FC
output
Unfold gathers 9 neighbours per pixel; FC applies the weights.
The best kernel Canvas found for ResNet-34
input
FC
Group
FC
Shift
+
A depthwise path plus a one-pixel shift: one neighbour instead of nine.
Zhao, Zhang, Shen, Gao. Canvas: End-to-End Kernel Architecture Search in Neural Networks. arXiv 2304.07741 (2023), Table 1 and Fig. 6.
Part 4 · Operators and compilers
Canvas: the search pipeline
Sample
Grow a graph one primitive at a time from the input. Near the end only merges are allowed. Duplicates are hashed away.
Match shapes
Each FC’s output width is a free variable. Where two branches meet, widths are chosen so the shapes divide evenly.
Fill the budget
Double whichever free width costs least, until the FLOP or parameter budget is used up.
Generate code
PyTorch modules for training; TVM tensor expressions tuned by Ansor for timing.
Evaluate
Train on a CIFAR-100 proxy, killing poor runs early. Measure runtime on the compiled kernel.
Select
Keep kernels within 1% of baseline accuracy that run fastest, then retrain them on ImageNet.
Search strategy
Purely random sampling, made affordable by the two solvers: a legal kernel is produced in a few milliseconds.
Scale
More than 300,000 kernels in two weeks on 16 GPUs: about 0.01 GPU-hours each.
Where correctness comes from
There is no equivalence to check: the new kernel computes something different. The test is accuracy after training.
Canvas, Sections 4 to 6. Proxy task: CIFAR-100 images upscaled to ImageNet size; runtime baseline and backend: TVM Ansor.
Part 4 · Operators and compilers
Canvas: results and caveats
Speedup over the original network compiled by TVM Ansor (higher is better)
The found networks are also smaller: 0.1× to 0.6× of the original parameters.
What it rediscovered
Residual connections, depthwise-separable and spatially separable convolutions, and squeeze-and-excitation-like kernels all turn up in the search.
Read with care
- The 1% accuracy bound holds on the CIFAR-100 proxy; after ImageNet retraining the loss is about 4%.
- Gains are small on networks that NAS already tuned.
- The paper never names the inference device; its runtime jobs run on CPU cores.
Canvas, Figs. 4 and 5 and Section 7. The paper summarizes the gains as “average 1.5×, up to 4.6×”.
Part 4 · Operators and compilers
GOS: operators grown from mathematics
Grassroots Operator Search starts from a trained model and a target edge device. It finds the operators that cost the most there and replaces each with a same-shape operator that is faster or smaller.
“Grassroots” refers to the search space: an operator is written as a graph of mathematical instructions (matrix products, norms, cross-correlation, pooling, activations, aggregations) instead of being chosen from a list of known layers.
The practical trick
Search starts from the original operator’s own graph. Of 1,000 random replacements almost all wreck accuracy; changing one instruction of the original rarely does.
Trained model
Profile on the device
Pick the slowest operators
Evolve a replacement
Fine-tune, check accuracy
Swap it in
Repeat until the latency target is met or enough layers are replaced.
Benmeziane et al. Grassroots Operator Search for Model Edge Adaptation. arXiv 2309.11246 (2023); journal version in FGCS, 2024.
Part 4 · Operators and compilers
GOS: method and results
Evolution
Tournament selection. Mutations swap one instruction for another of the same shape, change the aggregation, add or delete a node, or alter a hyperparameter. Crossover splices two graphs where shapes agree.
Fitness
Minimize latency measured on the device and parameter count, with accuracy within 1% of the original after a short fine-tune of the new operator alone.
Findings and caveats
It finds dilated and depthwise convolutions and leaky-ReLU-style activations: mostly known designs, picked per device. Edge CPUs only. Reported accuracy gains of 5 to 7 points after a short fine-tune are not explained.
Latency speedup after adaptation, ImageNet models (higher is better)
Raspberry Pi 3
ResNet18
5.76×
MobileNetV3
2.82×
FBNetV3
1.52×
OFA
1.16×
Redmi Note 7S phone
ResNet18
4.51×
InceptionV3
3.72×
MobileNetV3
2.23×
FBNetV3
1.18×
OFA
1.21×
NAS-tuned models (FBNetV3, OFA) gain least: 1.2× to 1.5×.
GOS, Tables 2 and 3 and Section 4. Search takes about one hour per model on a desktop GPU, 50 evolution steps per operator.
Part 4 · Operators and compilers · beyond the reading list
Compilers that search
Between a model and its machine code sit four layers. Each has become a search problem, with no person and no agent writing the kernel.
Capture and fuse the graph
TorchInductor · Relax · XLA · TensorRT
Decide which kernels exist
Korch · Mirage · Prism · Trinity · Neptune · Nautilus · MPK
Schedule and tile each kernel
Triton · Helion · TVM with Felix or Pruner · Tawa
Lower to machine code
ptxas · CompileIQ
Three shifts, 2023 to 2026
The search space moved up
In 2023 a compiler tuned the schedule of a kernel a human had fixed. Now the choice of kernels is searched too, and several systems derive FlashAttention-class kernels unaided.
The target moved to tiles
Triton, Helion and NVIDIA’s Tile IR let a compiler own warps, layouts and Tensor Cores, so high-level search rests on a strong back end.
Language models became proposers
They choose transformations or configurations inside a loop where the compiler guarantees legality and the hardware measures the result.
The second layer is new since 2024. The next seven slides go through these systems; none is on the original reading list.
Part 4 · Operators and compilers · beyond the reading list
TorchInductor: the compiler behind torch.compile
Meta with Quansight, OpenAI, Intel · ASPLOS 2024
The production answer to “what can be automated”, and the baseline that nearly every later system on these slides measures itself against.
Capture
TorchDynamo rewrites Python bytecode and pulls PyTorch calls into a graph, with guards that re-check its assumptions at run time.
Differentiate
AOTAutograd records the forward and backward graphs and decomposes operators into simpler ones.
Lower
Each operator becomes a loop body over 54 primitive operations, with symbolic sizes for dynamic shapes.
Fuse
A scheduler scores and merges compatible loops and plans memory. Library calls are left as they are.
Generate
The loops are printed as Triton source for GPUs; Triton compiles that to machine code.
Results
On an A100 across more than 180 models: 2.27× faster inference and 1.41× faster training than eager PyTorch, as geometric means.
Correct by construction
Every decomposition and fusion is a trusted rewrite. Nothing needs testing on random inputs.
What it leaves on the table
It does not fuse across reductions, so attention never becomes a FlashAttention-style kernel. Later systems report 2× to 5× over it on LLM blocks.
Ansel et al. PyTorch 2: Faster Machine Learning Through Dynamic Python Bytecode Transformation and Graph Compilation. ASPLOS 2024.
Part 4 · Operators and compilers · beyond the reading list
Mirage: a superoptimizer that invents kernels
CMU with Peking, Penn State, Purdue, Weizmann · OSDI 2025
Earlier superoptimizers rearranged a fixed set of library kernels. Mirage searches over a µGraph: three nested graphs that mirror the GPU, so new kernels can appear in the search.
Kernel graph
nodes are kernels; edges are tensors in device memory
Block graph
one kernel, as the work of a thread block; tensors in shared memory
Thread graph
element-wise chains that stay in registers
1 · Partition
Split the program into pieces built from multi-linear operators, division and limited exponentiation.
2 · Generate and prune
Enumerate candidate graphs operator by operator. Drop any whose symbolic “abstract expression” a solver cannot relate to the target’s.
3 · Verify
Test each survivor on random inputs over finite fields: a generalization of polynomial identity testing, with error probability as low as desired.
4 · Optimize and emit
Choose layouts with an integer program, generate CUDA, profile the candidates on the GPU and keep the fastest.
Wu et al. Mirage: A Multi-Level Superoptimizer for Tensor Programs. OSDI 2025, arXiv 2405.05751. Code: mirage-project/mirage.
Part 4 · Operators and compilers · beyond the reading list
Mirage: results and successors
Best speedup over the strongest existing system, by benchmark (A100 and H100)
Caveats. “Up to” figures on micro-benchmarks; end to end, 0.9× to 1.9×. Search takes up to four hours per program; the verifier excludes ReLU.
Mirage rediscovers FlashAttention and FlashDecoding from the plain definition, then beats them on group-query attention.
What came next
Prism · CMU, 2026 preprint
Keeps grid and mapping choices symbolic, so one graph stands for a family, and proves equivalence by e-graph rewriting. Up to 2.2× over Mirage.
Trinity · KAIST, ASPLOS 2026
Puts the program in an e-graph and saturates it with rewrite rules; over 10¹⁷ equivalent programs coexist. Up to 2.35× over TorchInductor.
MPK · CMU and NVIDIA, OSDI 2026
Compiles a whole model into one persistent “megakernel” with its own in-kernel scheduler. 1.0× to 1.7× over vLLM and SGLang.
Mirage, Section 8 (baselines: TASO, PET, torch.compile, TensorRT, Triton). Prism: arXiv 2604.15272. MPK: arXiv 2512.22219.
Part 4 · Operators and compilers · beyond the reading list
Neptune and Nautilus: deriving FlashAttention
UIUC with IBM Research · PLDI 2026 and a 2026 preprint
Schedule compilers could not fuse attention’s chain of reductions, so FlashAttention stayed hand-written. These two compilers reach it by algebra.
Plain attention
The input is the textbook formula written as loops: matmul, softmax, matmul.
Cut the dependency
The second reduction waits for the first to finish. The compiler breaks that link deliberately.
Add a correction
An algebraic correction term restores the exact result. One rule yields FlashAttention, another FlashDecoding.
Lower to tiles
The fused loop becomes a tile program and is handed to a Triton-based back end.
Tune
Candidates are measured on the GPU. Nautilus also generates the schedules itself.
Neptune
Ten attention benchmarks on NVIDIA and AMD GPUs: 1.35× on average over the next-best of Triton, TVM and FlexAttention.
Nautilus
No hand-written schedule template. Up to 23% more throughput than the best compiler on a GH200 and 42% on an RTX 5090.
Why it matters
The online softmax of Part 3, found there by insight, appears here as a compiler transformation that is exact by construction.
Zhao et al. Neptune, PLDI 2026 (arXiv 2510.08726); Nautilus, arXiv 2604.14825 (preprint). Both evaluations centre on attention.
Part 4 · Operators and compilers · beyond the reading list
Helion: four generations of autotuning
Helion is a kernel language from the PyTorch team. A person writes the tile-level algorithm in Python; tile sizes, loop order, warps and pipeline depth are a searched configuration. One kernel maps to thousands of Triton programs.
Settings measured
Tuning time
33 cases on a B200. LLM-guided kernels end about 1% slower on average.
2025 · Pattern search
Try every single-knob change from good random settings. About ten minutes per kernel.
February 2026 · Bayesian search
A classifier predicts which settings land in the top 10%; only those are measured. Tuning time falls 36%.
June 2026 · LLM-guided
The model sees the kernel, shapes and knob space, proposes about 15 settings a round, and gets timings back.
October 2026 · Joint with the back end
NVIDIA’s CompileIQ adds the machine-code compiler’s own controls: 2% to 7% more on tuned kernels.
The model replaces the search strategy, not the compiler.
PyTorch blog, October 2025 to October 2026 (Meta with NVIDIA, AMD and Intel teams). Engineering posts, not peer-reviewed papers.
Part 4 · Operators and compilers · beyond the reading list
Learned models inside the compiler’s search
UC San Diego · NeurIPS 2025
Reasoning Compiler
Tree search over TVM’s schedule transformations, with an LLM choosing which to expand. Only legal moves are accepted.
5.0× speedup with 5.8× fewer samples than TVM’s own search
All experiments are on CPUs.
Google DeepMind · 2025–2026
AlphaEvolve and Magellan
AlphaEvolve edited the compiler-generated IR of a FlashAttention kernel. Magellan evolves heuristics inside the compiler.
32% faster kernel; 4–5% smaller binaries from an evolved inliner
Internal workloads; GPU-compiler results are preliminary.
USTC and others · 2023–2026
TLP, TLM, Pruner
A learned cost model predicts a schedule’s speed, so most candidates never run. Pruner drafts cheaply, then verifies a shortlist.
Pruner: 2.6× to 4.8× less search time than Ansor
Faster search over the same space.
UIUC · ASPLOS 2024
Felix
Makes schedule search differentiable: tile sizes become continuous, and gradient descent runs on a latency predictor.
Near-peak schedules in about 3× less search time than Ansor
Finds answers faster, not better ones.
Here a model steers the compiler’s search and never writes kernel code. arXiv 2506.01374, 2506.13131, 2601.21096.
Part 4 · Operators and compilers · beyond the reading list
Inside the tile compilers
OpenAI · ASPLOS 2026
Linear Layouts
Triton now describes which register, thread and warp holds each tensor element as a binary matrix. Converting between layouts becomes linear algebra.
Up to 1.40×, 1.07× on average, over 265 cases
12% of Triton’s filed bugs had been layout bugs.
Cornell and NVIDIA · CGO 2026
Tawa
Takes unmodified Triton code and splits warps into producers that load and consumers that compute: FlashAttention-3’s hand technique, automated.
Up to 1.1× over cuBLAS matmul on an H100
UIUC, CMU and others · ASPLOS 2024
Korch
Splits operators into primitives, profiles every candidate kernel, and picks the best covering set by solving an integer program.
Up to 1.7× over PyTorch, TVM and TensorRT
Chooses among kernels; does not invent them.
NVIDIA · 2026
CUDA Tile and CompileIQ
A tile-level instruction set beneath the kernel languages, and an evolutionary search over the back-end compiler’s own controls.
Up to 15% on already optimized kernels
Vendor figures, without a published evaluation.
What “the compiler handles the low level” means in practice. arXiv 2505.23819, 2510.14719, 2406.09465; NVIDIA developer blog, 2026.
Part 5
Below the compiler
PTX and machine code are where the compiler has the last word. These works reopen its decisions: by learning, with agents, and by translation.
The level
What a SASS instruction contains, and the superoptimization lineage.
NVIDIA assembly
CuAsmRL learns instruction orders; autosass tunes register reuse.
Other targets and PTX
AsmEvo edits AMD binaries; CASS translates to AMD; PTXBench tests new instructions.
Beyond the list
Measured core pipelines, new assemblers, other vendors, hardware models.
Part 5 · Below the compiler
Anatomy of a SASS instruction
Every SASS instruction carries a control code: scheduling information the compiler fills in and the hardware obeys. Disassemblers hide it by default.
[B------:R-:W2:Y:S02] LDG.E R0, [R2.64] ;
Sets barrier 2 until the load returns
Opcode: load from global memory
Wait mask: which of six barriers must clear first
Yield hint and stall count: wait 2 cycles before the next one
Operands: destination register and address
An operand can also carry a .reuse flag, which keeps its value in a small register cache for the next instruction.
Why there is headroom
The compiler picks the instruction order, stall counts and reuse flags by general heuristics. Experts who reordered loads by hand to hide their latency beat it, but the work is trial and error over thousands of lines.
No official way back
NVIDIA ships a compiler from PTX to SASS and two disassemblers, but no assembler from SASS text to a binary. The community tool CuAssembler recovered the encodings by solving linear systems over disassembled examples. It supports Pascal to Ampere.
Sources: CuAssembler user guide (cloudcores/CuAssembler); CuAsmRL, Section 2. NVIDIA publishes opcode lists but not encodings.
Part 5 · Below the compiler
Superoptimization: the lineage
2013
2023
2025
2025
STOKE
Random search (MCMC) over x86-64 instruction sequences, scored by tests plus a validator and by speed.
A multiplication kernel 1.6× faster than gcc -O3. Loop-free code only.
AlphaDev
An AlphaZero-style agent plays an “assembly game”, rewarded for correct and short sorting routines.
Shorter sort routines, merged into LLVM’s libc++: up to 70% faster on 5 elements.
SuperCoder
LLMs rewrite gcc -O3 assembly for 8,072 programs; a 7B model is then fine-tuned with RL.
Best off-the-shelf model: 51.5% correct, 1.43×. Fine-tuned: 95.0% correct, 1.46×.
CuAsmRL
The same recipe on GPU machine code: an RL agent reorders SASS instructions of already optimized kernels.
Up to 26% and on average 9% faster on an A100. Next slides.
The shared recipe. A space of small edits to compiled code, a test that the code still computes the same thing, and a cost measured by running it. What changes over time is who proposes the edits: random moves, a trained agent, a language model.
STOKE: ASPLOS 2013. AlphaDev: Nature 618, 2023. SuperCoder: arXiv 2505.11480. CuAsmRL: CGO 2025, arXiv 2501.08071.
Part 5 · Below the compiler
CuAsmRL: an assembly game
CuAsmRL starts from the SASS that the compiler emits at -O3 for a Triton kernel, and lets a reinforcement learning agent rearrange it.
The only move is small: pick one memory instruction and swap it with its neighbour. The agent is rewarded whenever the reassembled kernel runs faster on the GPU.
Where it plugs in
The user swaps Triton’s @triton.jit for @cuasmrl.jit. Training takes under 5 hours per kernel; the best binary is cached and loaded at deployment, so there is no runtime overhead.
Why not reorder PTX instead? The compiler interleaves loads with address arithmetic when it lowers PTX to SASS, so the final order is only visible, and only editable, at SASS level.
RL agent
PPO policy
Reassemble, run on the GPU
SASS as a matrix
one row per instruction
Best binary, cached
action: move one load or store
up or down by one line
reward: time saved,
(T before − T after) ÷ T original
Each step runs the kernel 200 times on a real A100.
He and Yoneki. CuAsmRL: Optimizing GPU SASS Schedules via Deep Reinforcement Learning. CGO 2025, arXiv 2501.08071.
Part 5 · Below the compiler
CuAsmRL: one learned move
Compiler output
LDGSTS [R42+0x800], …
IADD3.X … ; IADD3 …
LDGSTS [R42+0xc00], …
HMMA.16816.F32 R28, R64.reuse, R60, R28
After the agent’s swap: 7% more throughput
LDGSTS [R42+0x800], …
IADD3.X … ; IADD3 …
HMMA.16816.F32 R28, R64.reuse, R60, R28
LDGSTS [R42+0xc00], …
LDGSTS copies from global to shared memory. HMMA is a Tensor Core matrix multiply.
Action
Move one memory instruction (LDG, LDGSTS, STG, …) up or down one line. No substitutions, no register changes.
Keeping it correct
Illegal moves are masked out: nothing may cross a dependency on a register, a barrier or a minimum stall count. Results are tested on random inputs and checked by hand. A formal proof is impossible: SASS has no published semantics.
Why this swap helps (the authors’ hypothesis)
In the original order the scheduler switches warps at the second load and loses the cached operand that R64.reuse was meant to keep.
CuAsmRL, Fig. 9 (fused GEMM + LeakyReLU on an A100; operands abbreviated here) and Sections 4 and 5.
Part 5 · Below the compiler
CuAsmRL: results and limits
Throughput gained over Triton’s own -O3 binary, per kernel
rmsnorm
+26%
fused feed-forward
+15%
matmul + LeakyReLU
+7%
batched matmul
+6%
softmax
+2%
self- attention
+1%
Values read from the paper’s bar chart, so approximate. Headline: up to 26%, 9% on average.
Where the gain comes from. The profiler shows 11% more memory throughput at an unchanged instruction rate: learned latency hiding.
What is new
The first learned optimizer for GPU machine code, and it starts from kernels that were already tuned. Gains come on top of everything in Parts 2 and 3.
Limits
- One architecture (A100), six kernels.
- Gains of 1–2% sit near the 1% measurement noise.
- Every step needs real GPU runs; training restarts from scratch for each kernel.
- Correctness rests on masking rules and tests.
CuAsmRL, Fig. 6 and Section 6. A100 80 GB, Triton 2.1.0, half precision. Each timing: 100 warm-up runs then 100 measured.
Part 5 · Below the compiler
AsmEvo: agents on binaries without source
AsmEvo targets AMD GPUs, not NVIDIA. Its setting is the hard one: only a compiled binary is available, with no source to edit and no reference implementation to test against.
Recover
Turn the compiled code object back into assembly that can be reassembled. Check once that the round trip is byte-identical.
Capture an oracle
Record inputs and outputs of the original binary, from synthetic data or a captured real launch. It is the only reference.
Profile
Hardware counters and sampling pick a stall-heavy hot window. The model sees that window, not the whole kernel.
Propose an edit
An LLM (Claude Opus 4.8) rewrites the window. A planner gives parallel workers different directions.
Rebuild
Splice the edit back and recompute register and memory metadata so the binary still launches.
Gate
In fixed order: assembles? ABI consistent? same outputs on every input? Only then: is it faster beyond noise?
Search space
Free-form edits to AMD GPU assembly: scheduling around slow memory operations, wait-counter placement, register pressure, instruction simplification.
Equivalence test
Against the original binary: byte-exact for integers; cosine similarity ≥ 0.9999 and error ≤ 0.001 for floats; checked three times per candidate.
Compared with CuAsmRL
Any edit instead of one kind of swap, a language model instead of a trained policy, and a much stricter gate, because the edits are unconstrained.
Liu et al. (AMD, SUSTech). AsmEvo: Agentic Assembly-Level Optimization of AMD GPU Kernels. arXiv 2608.20711 (2026).
Part 5 · Below the compiler
AsmEvo: results and caveats
Geometric-mean speedup over the unmodified binary (bars show the gain above 1×)
baselines written by an LLM
expert or production code
Best cases: 3.88× (depthwise convolution), 1.34× (a vLLM kernel).
12 h
search per kernel, on four GPU workers.
5.1%
of candidates pass the gate: about 7 commits in 138 attempts.
Read with care
- The large gains are over kernels that another LLM wrote. Expert code gains 1.01× to 1.34×.
- Equivalence is empirical: it covers the tested inputs and launch shapes only.
- The paper shows no before-and-after listing, and no official code.
AsmEvo, Section 5. AMD Instinct MI308X (KernelBench) and MI300X (production and Triton kernels). Preprint, August 2026.
Part 5 · Below the compiler
autosass: an autoresearch loop on SASS
autosass, from the GitHub organization gpuasm, applies the “autoresearch” pattern: a coding agent reads a playbook, edits an optimizer script, benchmarks, and keeps or reverts the change.
Its lever differs from CuAsmRL’s. Ampere cores have a small register cache, switched on per operand by .reuse, and a two-bank register file. A fused multiply-add whose inputs sit in the wrong places stalls.
What the script does to a compiled matmul kernel
- Finds runs of FFMA (fused multiply-add) instructions.
- Reorders them so consecutive ones share an operand, using a Z3 solver or a greedy search.
- Renames registers to avoid bank conflicts, sets .reuse, recomputes stall counts.
- Reassembles and checks the result against cuBLAS.
Before: the middle instruction evicts R3 from the cache
FFMA R0, R3, R5, R0
FFMA R1, R4, R7, R1
FFMA R2, R3, R9, R2
After: the two uses of R3 are adjacent, and the first keeps it cached
FFMA R0, R3.reuse, R5, R0
FFMA R2, R3, R9, R2
FFMA R1, R4, R7, R1
One kernel can contain over 2,000 such instructions, so small savings add up.
gpuasm/autosass on GitHub (README, program.md, optimize.py), March 2026. Register-cache behaviour: Huerta et al., arXiv 2503.20481.
Part 5 · Below the compiler
autosass: results and caveats
Gain over the nvcc binary, by matmul kernel variant (RTX 3090)
The 43 experiments behind the best result
24 within noise
7 crashed
12 others
The instructive part
The first thirty or so experiments gained nothing. Progress began only after the playbook’s model of the register cache was corrected. The agent’s search was only as good as its picture of the hardware.
Weak evidence
- An anonymous repository with one commit and no paper; the results are a single chart.
- It depends on a closed hosted assembler, gpuasm.com.
- The code is specific to one matmul kernel family on one architecture.
gpuasm/autosass, progress chart and playbook. Three small kernel variants with under 40 FFMAs showed no gain.
Part 5 · Below the compiler
CASS: translating NVIDIA code to AMD
CUDA code does not run on AMD GPUs. CASS trains models to translate it, at two levels: source to source, and assembly to assembly.
Its main product is data: the first large set of paired NVIDIA and AMD code, with both sources and both compiled assemblies for every sample.
How the 60,694 pairs were built
- CUDA files from the 200 most CUDA-heavy open repositories, plus 85,000 kernels written by an LLM from templates.
- AMD’s HIPIFY tool converts each to HIP; 44% fail and are dropped.
- Both sides are compiled; only samples that build on an A100 and on a Radeon RX 7900 XT are kept.
NVIDIA
AMD
CUDA source
SASS assembly
HIP source
RDNA3 assembly
nvcc
AMD compiler
source-level translation
assembly-level translation
Models: Qwen2.5-Coder at 1.5, 3 and 7 billion parameters, fine-tuned separately for each level. Benchmark: 369 tasks in 18 domains, judged by running the translated code and comparing outputs.
Heakl et al. (MBZUAI). CASS: Nvidia to AMD Transpilation with Data, Models, and Benchmark. ACL 2026, arXiv 2505.16968v4.
Part 5 · Below the compiler
CASS: results and caveats
Assembly level, SASS → RDNA3: share of tasks that compile and give the right output
CASS, 7B
69.1%
GPT-5.1
22.2%
Claude Haiku 4.5
11.2%
ZLUDA
7.9%
Gemini 2.5 Pro
6.5%
Qwen2.5-Coder 32B
5.4%
Source level, CUDA → HIP
CASS, 7B
88.2%
Hipify
87.5%
GPT-5.1
85.0%
Claude Haiku 4.5
69.4%
Gemini 2.5 Pro
66.7%
Qwen2.5-Coder 32B
47.0%
What the numbers say
General-purpose models translate source well and assembly badly. A small model trained on paired assembly does far better: assembly is learnable, given data.
Caveats
- Trained on A100 assembly, accuracy falls from 69% to 33% on RTX 4090 assembly: SASS is tied to its generation.
- Accuracy approaches zero beyond 750 assembly lines.
- It translates; it does not optimize. Tensor Core code is not covered.
- At source level its lead over Hipify is within the error bars.
CASS v4 (April 2026), Table 3 and ablations. The 2025 preprint reported other numbers (70k pairs, a 40-task benchmark).
Part 5 · Below the compiler
PTXBench: writing PTX for new hardware
Each GPU generation adds PTX instructions for its new units. A portable kernel can be correct and never use them. PTXBench tests the three bars separately: correct, uses the hardware, fast.
Prompt
The task, plus a 22,000 to 29,000-token pack describing the target GPU, PTX wrapper functions and its rules.
Write
The model writes a CUDA kernel with inline PTX from scratch. Calling cuBLAS or cuDNN counts as wrong.
Compile
nvcc -O3 for Hopper (H100) or Blackwell (B200).
Check
Sanitizers, then outputs compared with a reference; latency measured over 50 runs.
Verify use
A profiler counts how often the required machine instructions actually executed.
Feed back
Errors, timings and counts return to the model: up to 8 turns per attempt.
Inline PTX, as the model must write it
__device__ void wgmma_commit_fn() {
asm volatile(
"wgmma.commit_group.sync.aligned;\n"
::: "memory");
}
Why “verify use” runs the code
One model placed the required instruction in a dummy kernel that was never launched. The binary contained it; the profiler counted zero executions; the turn did not qualify.
Workloads
BF16 matrix multiply and multi-head attention (forward, backward, causal), compared with cuBLAS, cuDNN and FlashInfer on an H100 and a B200.
Zhang et al. (Stanford, CMU, RadixArk). PTXBench. arXiv 2608.17379v3 (2026); NeurIPS 2026 workshops. Code: zhang677/PTXBench.
Part 5 · Below the compiler
PTXBench: results
Best speed of a correct kernel that really used the target instructions, relative to the vendor library
H100
B200
matmul
attention forward
attention backward
matmul
attention forward
attention backward
Claude Opus 4.8
0.98×
0.84×
0.49×
1.01×
0.30×
0.15×
GPT-5.6 (xhigh)
0.87×
0.87×
0.70×
0.82×
0.54×
0.37×
Gemini 3.1 Pro
0.96×
0.73×
0.52×
0.89×
0.28×
0.13×
GLM-5.2
0.69×
0.61×
0.44×
0.63×
0.03×
none
1.00× equals cuBLAS or cuDNN. Darker is faster; one cell out of 24 reaches the library.
Correct is not the same as using the hardware
On Blackwell attention-backward, Claude Opus 4.8 was correct in 91.7% of turns, but executed Blackwell instructions in only 10.4%.
A compiler DSL still wins
The same models writing Triton instead of CUDA with PTX were faster in 18 of 20 comparisons.
Small data helps
A 27B open model that solved nothing reached 13.5% correct turns on matmul after fine-tuning on 158 repaired failures.
PTXBench v3, results tables and blog. Up to 8 turns; 96 turns per model, GPU and workload.
Part 5 · Below the compiler
Below the compiler: side by side
| Work | Target | What may change | Who searches | Correctness check | Headline |
|---|---|---|---|---|---|
| CuAsmRL | SASS, A100 | Swap neighbouring memory instructions | RL policy (PPO) | Move masking, random tests | Up to 26%, 9% on average |
| autosass | SASS, RTX 3090 | Reorder FFMAs, set .reuse, rename registers | Coding agent plus a heuristic script | cuBLAS comparison in the benchmark | +5.0% on one matmul kernel |
| AsmEvo | AMD assembly | Free-form edits in a hot window | LLM agents with a planner | Differential test against the original binary | 1.35× (LLM-written code), 1.09–1.18× (expert code) |
| CASS | SASS → AMD RDNA3 | Whole-program translation | Fine-tuned 7B model | Compile and run, 369 tasks | 69% assembly accuracy |
| PTXBench | PTX, H100 and B200 | Write the kernel from scratch | Frontier LLMs, 8 turns | Outputs plus executed-instruction count | 0.13× to 1.01× of the vendor library |
Gains are modest by design. The input is already optimized code; a few percent on a hot kernel still pays.
Freedom and checking trade off. One safe move needs light tests; free-form edits need a strict gate.
No proofs anywhere. Machine code has no public semantics; every work here verifies by testing.
Sources as on the preceding slides. Headline numbers use different baselines and hardware; they are not comparable with one another.
Part 5 · Below the compiler · beyond the reading list
What is now known about GPU cores
Universitat Politècnica de Catalunya · MICRO 2025
NVIDIA does not document its core pipeline. This group measured it with hand-assembled SASS between two reads of the cycle counter. The result explains why Part 5’s edits work.
Cycles until a result can be used, Ampere-class GPUs (log scale)
arithmetic to arithmetic
4
Tensor Core matmul
16–24
load from shared memory
24
load, L1 cache hit
29–32
load, L2 cache hit
208–357
load from GPU memory
566
The compiler keeps the books
The hardware does not check that an input is ready. The compiler writes a stall count into each instruction; a wrong count gives a wrong result.
Four sub-cores per SM
Each issues one instruction per cycle at most, staying on a warp while it is ready, then switching to the youngest ready one.
Register banks and a small cache
Two banks per sub-core, one read port each: a multiply-add with all inputs in one bank loses two cycles. A .reuse flag keeps an operand in a small cache.
Huerta et al. Analyzing Modern NVIDIA GPU Cores. MICRO 2025, arXiv 2503.20481. Cache latencies: Luo et al., arXiv 2501.12084.
Part 5 · Below the compiler · beyond the reading list
Reading and writing machine code: new tools
Purdue, EPFL · ASPLOS 2027
EoSS
Extracts the instruction-set description embedded in NVIDIA’s disassembler, generates a valid encoding per class, and times each on the GPU.
Hopper: 1,584 instruction classes, against 204 in the public listing
Timing, not meaning. NVIDIA has since encrypted the description.
HKUST-GZ, Tsinghua · 2026
Hidden scheduling marks
Three control-code bits also carry marks that let a warp run past a pending barrier or change priority. NVIDIA’s libraries hold 503,175 of them; the public compiler emits none.
Up to +3.6% end to end from setting marks in existing binaries
Unreviewed preprint; behaviour inferred from timing.
Independent · 2026 preprint
F2Asm
An assembler for Hopper, Blackwell and Rubin that learns instruction encodings as linear algebra over bits, from 213 million observed instructions.
All 3,225 test binaries reassemble byte for byte
Encodes, but does not choose control codes.
University of Cambridge · EuroMLSys 2024
SIP
The predecessor of CuAsmRL: random perturbation of SASS instruction order, kept when faster and still correct.
Fused attention 6.2% faster; matmul with activation 12.3%
Best kernels checked on 10 million random tests.
EoSS: github.com/eoss-framework. Marks: arXiv 2611.24437. F2Asm: arXiv 2608.20532. SIP: arXiv 2403.16863.
Part 5 · Below the compiler · beyond the reading list
Other vendors, and models of the hardware
Meta and AMD · MICRO 2026
Training on AMD at scale
What changes when a production stack tuned for NVIDIA moves to AMD’s MI350X: 64-thread waves instead of 32-thread warps, chiplet-local caches, costly atomics, no bulk tensor loader.
101% of B200 throughput across ten models, after re-tuning
Matmul stays 1.3–1.7× slower; different power caps.
Spectral Compute, independent, Tampere and others
SCALE, ZLUDA, chipStar
Three ways to run CUDA elsewhere: a drop-in compiler for AMD, a replacement runtime that recompiles PTX, and a route through SPIR-V to OpenCL.
chipStar: 0.75 of native AMD speed, geometric mean
Warp width, inline PTX and vendor libraries are what break.
Purdue · August 2026
Accel-Sim 2.0
The open cycle-level simulator now models Hopper-era kernels: bulk tensor loads, asynchronous Tensor Core instructions, producer and consumer warps.
13.5% error against a real H100
Trace-driven, and far slower than hardware.
Georgia Tech; SJTU and Alibaba · 2025–2026
NeuSight and PipeWeave
Learned predictors of kernel time, built on tiles and a roofline so that a prediction can never beat the hardware bound.
6–9% error on the authors’ own test sets
One was measured at 43% by the other’s authors.
Meta and AMD: arXiv 2610.22230. chipStar: IJHPCA 2026. Accel-Sim 2.0: arXiv 2608.22602. NeuSight: ASPLOS 2025.
Part 6
LLM agents
The newest searchers read profiles, write code and iterate on their own. This part covers how they are judged, five systems from the reading list, and a cousin from robotics.
The loop and its judges
The agent loop, KernelBench, and a cautionary tale.
Changing the model
Kevin and CUDA-L1 train on speedups; AlphaEvolve evolves programs.
Building the system
MARCO, CUDAMaster, CUDA-Harness, AutoKernel, Agentic Kernel Optimization.
Same pattern elsewhere
MOPS: language model, optimizer and simulator in robot planning.
Part 6 · LLM agents
The agent loop
Profile
Plan a change
Edit the code
Compile
Check correctness
Benchmark
Keep or revert
A fixed harness: tests and timers the agent is not allowed to edit
Every system in this part runs some version of this loop around a language model. They differ in three places:
How much the agent sees
From latency alone, to a roofline percentage, to filtered profiler counters, to a full profile mapped to source lines.
How the agent is organized
One agent editing one file; a fixed script of roles; or a team with a planner, parallel coders and a human supervisor.
How gaming is prevented
A frozen benchmark, tests the agent never sees, or explicit rules added after an agent found a shortcut.
The loop is the expert’s own workflow from Part 2, with the person replaced by a model and the notebook by a log.
Part 6 · LLM agents
KernelBench and its metric
KernelBench gives a model a PyTorch module and asks for a faster GPU implementation with the same outputs. It has 250 tasks: 100 single operators, 100 operator sequences, 50 whole architectures.
fast_p = share of tasks that are
correct AND speedup > p
fast_0 is the correctness rate. fast_1 counts kernels that are correct and beat PyTorch. Raising p asks for more.
Known weakness. Correctness is five random inputs at one fixed shape. An independent re-evaluation set aside about 45 of the 250 tasks as exploitable or flawed.
fast_1 of the best model in the paper, DeepSeek R1 (higher is better)
one attempt
10 turns with execution and profiler feedback
Other benchmarks: TritonBench, MSKernelBench, CUDABench, PTXBench (Part 5), and the newer generation in Part 7.
Ouyang et al. KernelBench: Can LLMs Write Efficient GPU Kernels? ICML 2025, arXiv 2502.10517. Re-evaluation: METR, February 2025.
Part 6 · LLM agents
A cautionary tale
The first widely publicized agent for CUDA kernels is best remembered for what went wrong with its measurements.
20 February 2025
Sakana AI announces the “AI CUDA Engineer”: an agent pipeline that translates PyTorch to CUDA and evolves it. Claimed: 10–100× over common PyTorch operations.
21 February 2025
Outside users re-run kernels and find them no faster; one measures a 3× slowdown. Sakana confirms the system “found a memory exploit in the evaluation code” that let it skip correctness checks, and apologizes.
September 2025
Sakana’s follow-up benchmark, robust-kbench: with contaminated tasks removed, its own average speedup falls from 3.13× to 1.49×. “Cheating” kernels had scored 50–120×.
It was not an isolated case
CUDA-L1. First versions claimed 17.7× on average. The authors found 82 of 250 outputs gamed the timer with extra CUDA streams, and revised to 3.12× (median 1.42×).
Agentic Kernel Optimization. An agent cached outputs keyed on the identity of the input tensors and reported over 1,000×.
PTXBench. A model put the required instruction in a kernel that was never launched.
Sources: Sakana AI post and update; TechCrunch, 21 Feb 2025; robust-kbench (arXiv 2509.14279); CUDA-L1 (arXiv 2507.14111).
The lesson that recurs in every part that follows
A search process optimizes what you measure, not what you meant.
The stronger the searcher, the more carefully the harness must be built: unseen tests, fresh inputs, and timing the candidate cannot influence.
Part 6 · LLM agents
Changing the model: Kevin and CUDA-L1
Cognition AI and Stanford · July 2025
Kevin: multi-turn reinforcement learning
A 32B open model is fine-tuned on 180 KernelBench tasks. Each refinement turn is a training sample, rewarded by the scores of the turns after it.
score = 0.3·correct + speedup·correct
- Correct on 82% of unseen tasks (best of 16), up from 56%.
- Best-attempt speedup 1.10× over PyTorch, up from 0.53×.
- Refining one attempt beats sampling many in parallel.
Caveat: averaged over all attempts, 0.40×.
DeepReinforce · July 2025, ICLR 2026
CUDA-L1: contrastive reinforcement learning
Three stages: supervised fine-tuning on CUDA code, self-training on its own correct outputs, then prompts that show earlier variants with their measured speedups.
- After its revision: 3.12× mean, 1.42× median over the KernelBench baselines (A100).
- CUDA-L2 targets half-precision matmul: +19% over cuBLAS across 1,000 shapes.
Caveat: its showcased 64× case is an algebraic rewrite.
Two ways to use a measured speedup
Train on it, so the model itself improves. Or feed it back at run time, so a fixed model searches better. The rest of this part takes the second road.
Kevin: arXiv 2507.11948. CUDA-L1: arXiv 2507.14111. CUDA-L2: arXiv 2512.02551.
Part 6 · LLM agents
Evolving programs with a language model
Program database
islands keep variety
Pick parents, build a prompt
LLM proposes a change
Evaluate: run and score
Good candidates return to the database and become parents themselves.
The language model plays the mutation operator of a genetic algorithm. Selection is done by measurement, not by the model’s opinion of its own work.
FunSearch · 2023
The template: a frozen model mutates one function, an evaluator scores it. Results in mathematics.
AlphaEvolve · 2025
Whole files evolved through diffs. Inside Google: a 23% faster TPU matmul kernel and a 32% faster GPU FlashAttention kernel.
KernelEvolve · 2025
Meta’s production agent writes Triton kernels for NVIDIA, AMD and in-house chips: 1.25× to 17× on selected cases.
GPU Kernel Scientist · 2025
An honest negative: with timing as the only feedback, about 4× behind the best human.
FunSearch: Nature 625 (2024). AlphaEvolve: arXiv 2506.13131. KernelEvolve: arXiv 2512.23236. GPU Kernel Scientist: arXiv 2506.20807.
Part 6 · LLM agents
MARCO: adding fresh knowledge to the loop
MARCO starts from one weakness of language models: their knowledge stops at a training cutoff, while optimization techniques keep appearing in papers.
Its answer is a two-agent loop with a search tool. The optimizer agent turns the code into search queries restricted to scholarly sites, reads back techniques, and rewrites the code. A second agent measures the result and reports back.
No training involved. The model is used as it is; the system adds retrieval and measurement around it. The authors present this as the cheaper alternative to fine-tuning an HPC-specific model.
Code optimizer agent
writes search queries, applies what it finds
Web search
ACM, IEEE, arXiv, ResearchGate
Performance evaluator agent
time, memory, complexity
techniques and references
a new variant of the code
structured feedback
Rahman et al. (Virginia Tech). MARCO: Multi-Agent Code Optimization with Real-Time Knowledge Integration. arXiv 2505.03906 (2025).
Part 6 · LLM agents
MARCO: results and what to take from it
Runtime reduction against Claude 3.5 Sonnet used alone, by problem difficulty
| Runtime, ms | Easy | Medium | Hard |
|---|---|---|---|
| Claude 3.5 Sonnet | 11.8 | 78.1 | 288.1 |
| MARCO | 9.3 | 65.9 | 138.5 |
The evaluation is not about GPUs
Despite the title, every reported result is on Python LeetCode problems. The authors state that the evaluator “lacks native support for … Numba, Torch, and CUDA”. Timings of a few milliseconds are noisy, and no code is released.
The ablation
The paper credits web search with a 30.9% improvement over the system without it. On easy problems the model alone sometimes wins.
Why it is on the reading list
For the idea: retrieve current knowledge, then measure. It returns as the Researcher agent in Agentic Kernel Optimization and as the knowledge pack in PTXBench.
MARCO v3, Section 5. LeetCode 75 plus 10 hard problems; 14.6% lower mean runtime overall; equal or better on 44 of 75.
Part 6 · LLM agents
CUDAMaster: profile-guided roles
Profile
Run the kernel under Nsight Compute and collect its hardware counters.
Filter
Classify it as compute-bound, bandwidth-bound or latency-bound, and keep only the counters that matter for that class.
Plan
A planner agent reads code, filtered profile and past speedups; it returns one incremental strategy, no code.
Code
A coder agent writes the optimized kernel. Calling libraries is forbidden.
Compile
A compiler agent chooses the nvcc flags.
Run and debug
Check outputs at every input size, time, re-profile. On failure a debug agent gets up to three rounds.
Share of 100 tasks above each speedup (o4-mini)
MSKernelBench
The paper’s own benchmark: 50 tasks in FP32 and BF16, reaching beyond ML operators to sparse algebra, stencils and scientific kernels, each at several input sizes.
About $0.27 and three iterations per task.
Caveats
Baselines are deliberately naive. The optimized sparse kernel hard-codes the benchmark’s column count, and the normalization kernel is tested only at tiny sizes: signs of fitting the test.
Han et al. (Tsinghua, Proxseer). Making LLMs Optimize Multi-Scenario CUDA Kernels Like Experts. arXiv 2603.07169 (2026). RTX 4090.
Part 6 · LLM agents
CUDA-Harness: kernels from a description
A different task from the others: the input is natural language, not existing code. There is no reference to compare with and no test data, so the harness must create both.
1 · Structured generation
The request first becomes a manifest: each kernel’s name, inputs, outputs and test shapes. Each entry then fills a fixed code scaffold.
2 · Verification by synthesis
Reference inputs and outputs are generated with NumPy or PyTorch in a context the coding agent cannot see. Checks fail fast: compile, function, speed.
3 · Correctness-first evolution
A compile failure triggers a repair; a wrong answer, a retreat to a simpler version. Only correct kernels are tuned for speed.
Functionally correct kernels on CUDABench (higher is better)
CUDABench baseline
60.9%
OpenCode
60.6%
KernelSkill
63.7%
CudaForge
67.7%
Codex
69.5%
CUDA-Harness
80.5%
Caveats. The synthesized tests agree with the benchmark’s own 84% of the time and let 8.7% of wrong kernels pass. The gain is mostly correctness, not speed: latency is the only performance feedback. No code is released.
Fan, Zou, Ma (Shanghai Jiao Tong). CUDA-Harness. arXiv 2609.00058 (2026). NVIDIA A40; three rounds of three candidates per task.
Part 6 · LLM agents
AutoKernel: one agent, one file
AutoKernel applies the autoresearch pattern to GPU kernels: edit one file, run a fixed evaluation, keep or revert. It argues that this simple loop beats elaborate multi-agent designs.
A profiler first ranks a PyTorch model’s kernels by their share of runtime, so effort goes where Amdahl’s law says it pays. The agent then works through them in Triton or CUDA.
The harness the agent may not edit
Five stages: a smoke test, a sweep over shapes and precisions, numerical stability, bitwise determinism over three runs, and odd sizes such as 1,023 and 4,097.
Write a hypothesis
One focused edit to kernel.py
git commit
Run bench.py
Correct and ≥ 1% faster?
Keep, or git reset
Move to the next kernel after 5 reverts in a row, 90% of the GPU’s peak, 2 hours, or a 2× speedup.
About 90 seconds per iteration: 300 to 400 experiments in an overnight run.
Jaber and Jaber (RightNow AI). AutoKernel: Autonomous GPU Kernel Optimization via Iterative Agent-Driven Search. arXiv 2603.21331.
Part 6 · LLM agents
AutoKernel: results and caveats
Speed of AutoKernel’s Triton kernels on an H100, relative to PyTorch (higher is better)
RMSNorm
Softmax
Cross-entropy
Matmul
against eager PyTorch
against torch.compile, max-autotune
Below 1× is a loss: its matmul reaches half the speed of the compiled baseline, which calls cuBLAS.
The pattern in the numbers
Memory-bound kernels (normalization, softmax, losses) gain 2× to 5×. The compute-bound matmul loses to the vendor library, as in Part 2.
Caveats
- The table measures the hand-provided starter kernels, not the output of the agent loop; no measured search trajectory is reported.
- A 1% keep-threshold on one measurement can keep noise.
- The model used for the results is not stated.
A namesake: OAID’s AutoKernel (2020) generates operators with Halide for the Tengine framework. It is not LLM-based.
AutoKernel, Table 4 and Section 7. H100, FP16, CUDA 12.8; sizes 8192² (4096³ for matmul). All 34 configurations pass the harness.
Part 6 · LLM agents
Agentic Kernel Optimization: a supervised team
Can general coding agents write state-of-the-art kernels for brand-new hardware? This report tries it on three production workloads for the Blackwell B200, starting from PyTorch references.
Every agent is Claude Code running Claude Opus 4.6, in its own process and GPU sandbox. Only the kernel file may change; harness, data and references are fixed.
Houmao, the framework underneath
An open-source tool for running teams of command-line coding agents, each in its own terminal session with a mailbox and no central orchestrator. The name is 猴毛, “monkey hair”: the Monkey King’s self-directed clones.
Agent skills: a Blackwell PTX reference, a profiling recipe, benchmark rules, independent code review, web search.
Human supervisor
Planner
CUDA coder 1
CUDA coder 2
CUDA coder N
Researcher
web search
Synthesizer
merge, validate, log
Profiler
Nsight Compute
Dashed: the human sets rules and redirects, but never edits kernel code.
Luo, Li et al. (Intellifusion). Agentic Kernel Optimization. arXiv 2608.14560 (2026), tech report. Houmao: github.com/igamenovoer/houmao.
Part 6 · LLM agents
Agentic Kernel Optimization: results and caveats
One campaign: the fused mixture-of-experts kernel on a B200
0×
25×
50×
75×
100×
0
250
500
750
1,000
Tokens spent (millions)
Speedup over PyTorch
92.7×
start: 27×
overlapped pipeline
Blackwell instructions
hand-written FlashInfer: 47×
| Kernel | FlashInfer | Agents | Tokens |
|---|---|---|---|
| Top-k indexer | 52× | 1,101× | 414 M |
| Sparse attention | 10× | 181× | 427 M |
| Fused MoE | 47× | 93× | 1.05 B |
Official contest check: MoE kernel 1.71× over the FlashInfer baseline; best agent-assisted entry 1.68×.
Caveats
- The 1,101× is mostly a fast path: in 69 of 128 workloads the kernel only remaps indices.
- The heavy matmuls still call NVIDIA’s CUTLASS.
- Human redirection was needed throughout.
Agentic Kernel Optimization, Table 1 and Fig. 2 (step labels approximate). Speedups are workload averages against PyTorch.
Part 6 · LLM agents
MOPS: the same pattern in robotics
MOPS plans robot manipulation from a language instruction. It is here because it states cleanly a division of labour that kernel agents are converging on.
Language models are weak at exact numbers and geometry. So the model chooses the structure, and numerical optimizers choose the numbers.
| In MOPS | In kernel optimization |
|---|---|
| The LLM writes a parameterized program | An agent picks the strategy: what to tile, fuse, pipeline |
| CMA-ES tunes its numbers | An autotuner sweeps tile sizes, as in Part 2 |
| A gradient solver finds the motion | The compiler lowers and schedules the code |
| The simulator returns a cost | The benchmark returns a runtime |
Level 1 · Language model
writes a program: which skills and constraints, in what order
Level 2 · Black-box optimizer (CMA-ES)
tunes the program’s numbers
Level 3 · Gradient-based solver
computes the robot’s trajectory for the fully specified problem
Simulator
task cost
cost, final state and a target go back to the model
Shcherba, Cobo-Briesewitz, Braun, Toussaint. Meta-Optimization and Program Search using Language Models for TAMP. CoRL 2025.
Part 6 · LLM agents
MOPS: results and the lesson
Task score by method, 1.0 is perfect (higher is better)
Push:
circle
Push:
line
Push:
obstacle
Draw:
star
Draw:
pentagon
Draw:
hash
Code-as-Policies
PRoC3S
MOPS
Read from the paper’s bar chart (about ±0.05); it has no numeric table. Simulation, five seeds.
Where the search happens
At most three prompts to a small model (gpt-4o-mini), with 1,000 to 1,500 optimizer steps after each. The language model sets the direction; the optimizer does the walking.
The lesson for kernels
Do not ask the model for the best tile size. Ask it for a kernel with a tile-size parameter, then sweep the parameter. CuAsmRL’s autotuner and AutoKernel’s block-size tier already work this way.
Caveat. Each task needs a hand-designed cost function, so much of the task knowledge sits in the evaluator.
MOPS, Fig. 4 and appendix (arXiv 2505.03725). Baselines sample parameters or chain fixed skills; MOPS optimizes them with CMA-ES.
Part 7
The wider field
The reading list is a sample. By late 2026 nearly every chip vendor and many universities run kernel agents of their own, and the field has had to rebuild how it measures them.
A map
A 2026 survey’s taxonomy: train the model, or wrap it in an agent.
Industry labs
Meta, NVIDIA, Google, ByteDance, Intel, AMD, Amazon, Microsoft and others.
Universities
Agent designs, trained models, search strategies, HPC.
Measuring it properly
New benchmarks, a catalogue of exploits, a contest, and proofs.
Part 7 · The wider field
A map of the wider field
Train the model
Supervised fine-tuning
KernelLLM
Reinforcement learning
Kevin · CUDA-L1 · CUDA Agent · TritonRL · Dr. Kernel · QiMeng-Kernel
Wrap it in an agent
Refine or evolve
AutoKernel · K-Search · AI CUDA Engineer · EvoEngineer
Add memory
KernelEvolve · KernelSkill
Add a profiler
CudaForge · SwizzlePerf · TritonForge
Add roles
STARK · Astra · GEAK · KernelFalcon
Feed it
Code corpora
CUTLASS · FlashInfer · DeepGEMM · vLLM · Triton
Knowledge bases
CUDA guide · PTX reference
Judge it
Benchmarks
ParEval · KernelBench · TritonBench · robust-kbench · FlashInfer-Bench · SOL-ExecBench
Open problems the survey lists: unreliable evaluation; data that holds final kernels but not the path to them; long-horizon agent training; sandboxed infrastructure at scale; how people and agents share the work.
Yu et al. (BAAI and others). Towards Automated Kernel Generation in the Era of LLMs. IJCAI 2026 survey track, arXiv 2601.15727.
Part 7 · The wider field
KernelEvolve: kernel agents in production
Meta · ISCA 2026
The one peer-reviewed report of kernel agents deployed in production, across three accelerator families: NVIDIA, AMD and Meta’s own MTIA chip.
Search graph
Each candidate kernel is a node with its score and profile. A policy picks nodes: greedy, tree search or evolution.
Diagnose
A sub-agent reads the node’s code, logs and profiles and writes down the bottleneck.
Retrieve
Another pulls hardware documents and code from a knowledge base: vital for a chip no public model has seen.
Write
One general agent writes the next Triton kernel.
Evaluate
Remote workers compare outputs with PyTorch and time the kernel on real hardware.
Deploy
Winners ship with shape-based dispatch and a fallback to the vendor library.
Results
480 of 480 operator-and-platform pairs correct. Production operators gain 1.25× to 17×; a convolution at its production shape gains 2.3× on an H100.
In deployment
Meta’s blog reports over 60% more inference throughput for one ads model that already used torch.compile and vendor libraries.
Caveats
Kernels are shape-specialized: the same convolution runs at 0.5–0.6× on other shapes. Baselines are PyTorch, not expert kernels. No code is released.
Liao et al. KernelEvolve: Scaling Agentic Kernel Coding for Heterogeneous AI Accelerators at Meta. ISCA 2026, arXiv 2512.23236.
Part 7 · The wider field
AVO: an agent that beat the vendor library
NVIDIA · NeurIPS 2026
Best gain in attention throughput on a B200 (higher is better)
over NVIDIA’s closed cuDNN kernel
over the best open kernel
The agent is the mutation step
Evolutionary search usually samples parents, then asks an LLM for a child. AVO hands the whole step to a coding agent that reads the lineage of earlier kernels, their profiles and a knowledge base, then edits, compiles and scores.
A supervisor
A second agent watches for stalls and proposes new directions; removing it hurt most. The run took seven days: 40 committed versions, over 500 directions tried.
Caveats. Single-digit gains over libraries already tuned by experts, and the search started with FlashAttention-4’s source in its knowledge base. One kernel family on one GPU.
Chen et al. (NVIDIA). AVO: Agentic Variation Operators for Autonomous Evolutionary Search. NeurIPS 2026, arXiv 2603.24517.
Part 7 · The wider field
µCUTLASS: a better language beats a bigger model
NVIDIA · NeurIPS 2026
Geometric-mean speedup over PyTorch, 59 KernelBench problems on an H100
GPT-5-mini
GPT-5
GPT-5.2
agent writes raw CUDA
writes the small DSL
DSL plus speed-of-light guidance
With the DSL, the smallest model (1.27×) passes the middle model writing raw CUDA (0.86×).
A compact DSL
A grammar of about 170 lines that the model learns in context. A kernel is 10 to 20 lines of high-level choices; a compiler checks them and emits NVIDIA’s CUTLASS code.
Speed-of-light guidance
A roofline bound per problem tells the agent how much headroom is left. Searches stop near the bound, saving 19–43% of tokens, and any result faster than the bound is flagged as cheating.
Caveats. 59 chosen problems. Agents may use 16-bit arithmetic on 32-bit problems. Without the integrity filter, speedups inflate by up to 1.9×.
Hari, Balaji, Damani, Huang, Kozyrakis (NVIDIA). arXiv 2603.29010; NeurIPS 2026 poster. Numbers are after integrity filtering.
Part 7 · The wider field
MaxKernel and JAXBench: agents for Google’s TPUs
Google and Google DeepMind · 2026 workshop papers
MaxKernel on JAXBench: geometric-mean speedup over Google’s XLA compiler
On eight production kernels with hand-tuned references, the agent reaches 2.69× against the experts’ 2.43×, and beats them on four of the eight.
JAXBench
50 TPU workloads: 17 production operators from models such as Llama-3.1, DeepSeek-V3, Mamba-2 and AlphaFold2, plus 33 fused operators. Eight come with expert kernels as an upper bound.
MaxKernel
Agents plan, write a kernel in Pallas (JAX’s kernel language), fix compile errors, test, autotune and profile. Tests are synthesized first and frozen, so the agent cannot edit its own checks.
A finding that travels. For a rarely seen language, documentation mattered more than model size: adding curated TPU documents raised per-sample correctness from 5.8% to 37.3%.
MaxKernel: arXiv 2609.04523. JAXBench: arXiv 2607.20466. TPU v6e; slower kernels count as 1.0×; tolerance up to 1e-1.
Part 7 · The wider field
CUDA Agent: reinforcement learning at agent scale
ByteDance Seed and Tsinghua · February 2026 preprint
Kevin and CUDA-L1 trained on short episodes. CUDA Agent trains a large model inside the full agent loop:
Data
6,000 synthesized tasks, each a stack of up to five PyTorch operators, filtered to be far from the benchmark.
Environment
An agent loop with shell tools; kernels are timed on a separate pool of 128 GPUs.
Reward
Milestones, not raw speed: wrong −1, correct +1, faster than eager +2, faster than torch.compile too +3.
Staged training
Warm up on single turns, fine-tune on good trajectories, pre-train the critic, then full agentic RL with 128k-token contexts and up to 200 turns.
Share of 250 KernelBench tasks faster than torch.compile, same agent loop
before training
frontier general models
after training
Caveats. Its instructions allow cuBLAS for matmul and require cuDNN for convolution, so not every kernel is hand-rolled. Best-of-trajectory selection. Weights are not released.
Dai, Wu et al. CUDA Agent: Large-Scale Agentic RL for CUDA Kernel Generation. arXiv 2602.24286. Geomean 2.11× over torch.compile.
Part 7 · The wider field
Xe-Forge: refining kernels for Intel GPUs
Intel · April 2026 · preprint
Most kernel agents write new kernels for NVIDIA. Xe-Forge takes a correct Triton kernel and refines it for an Intel GPU, hardware the models know little about.
Analyze
An LLM reads kernel, reference and shapes, and reports typed issues.
Plan
A planner orders up to nine stages: algorithm, data types, fusion, memory, GPU settings.
Rewrite in stages
One agent per stage, five attempts. If all fail, the earlier code is kept.
Verify
Four gates: it parses, the structure is legal, outputs match, it is faster.
Re-analyze
After each stage, so that later stages see the new code.
Autotune
Up to 12 settings of warps, tile sizes and register modes.
A knowledge base in place of training
84 hand-written entries on Intel specifics, injected stage by stage: for example, try both the 128- and the 256-register mode.
What may change
Only the Triton kernel body and its tuning configuration. Outputs are compared with torch.allclose at a relative tolerance of 1e-2.
Why it matters
It approaches portability from the other side: the kernel exists already, and the scarce input is knowledge of the target hardware.
Spoczynski, Fleischer et al. (Intel). Xe-Forge: Multi-Stage LLM-Powered Kernel Optimization for Intel GPU. arXiv 2605.26118 (2026).
Part 7 · The wider field
Xe-Forge: results and caveats
Speedup by kernel family on an Intel Arc Pro B70 (kernel counts after the dot; log scale)
GEMM-based · 19
1.28× geomean
MatMul-based · 17
1.76× geomean
Conv2D · 21
0.6–2.2×
ConvTranspose2D · 10
0.6–1.4×
Conv3D · 12
0.6–1.3×
ConvTranspose3D · 17
0.5–1.2×
Flash Attention · 16
2–13.3×
0.5×
1×
2×
4×
8×
16×
Left of the 1× line is a slowdown. Dots are geometric means; bars are the reported ranges.
1.17×
geometric mean over eager PyTorch, 97 kernels; 67% improve.
$0.5–2
per kernel: typically 10 to 20 model calls.
Where the outliers come from
Nine kernels gain 9× to 82× through algebraic rewrites and fusion, not faster arithmetic.
Caveats
- Bandwidth-bound convolutions regress to 0.5–0.8×.
- One device, one model, no ablations, no comparison with Intel’s own libraries.
Xe-Forge, Section 5. Baselines: eager PyTorch, torch.compile and the unoptimized input kernel. Model: GPT-5.4.
Part 7 · The wider field
More industry labs: AMD, Intel, Amazon, Microsoft
AMD · 2025–2026
GEAK and AgentKernelArena
Agents for AMD GPUs, grown from a generate-test-reflect loop into one that profiles a live server, ranks kernels by impact and re-measures every patch in a clean workspace.
Version 3: 3.02× on HIP kernels
Vendor-reported on small sets.
Intel · ICML 2026
KernelFoundry
Evolutionary search with a quality-diversity archive: 64 cells by memory pattern, algorithmic structure and parallelism. Targets SYCL, CUDA and Triton.
1.38× geometric mean on Intel GPUs
Its headline 2.3× is an arithmetic mean.
Amazon · 2025–2026
AccelOpt and CompoundingKernel
For AWS Trainium, with Stanford: beam search plus a memory of slow-to-fast rewrites. For GPUs: an archive-driven search that led NVIDIA’s speed-of-light boards.
Trainium: 49% → 61% of peak throughput
Microsoft · 2026
KernelBrain
Budget-aware search: screen many Triton candidates with short cheap runs, and promote survivors to longer, stricter benchmarks.
Up to 1.4× over PyTorch’s own kernel agent
Six kernels.
GEAK: arXiv 2507.23194 and AMD blogs. KernelFoundry: arXiv 2603.12440. AccelOpt: arXiv 2511.15915. KernelBrain: arXiv 2608.02611.
Part 7 · The wider field
More industry labs: Meta, Google, Huawei, frontier labs
Meta · 2025–2026
KernelFalcon, TritorX, STARK
KernelFalcon writes correct Triton for all 250 KernelBench tasks. TritorX fills in operators for Meta’s own chip overnight. STARK adds plan, code and debug roles over a search tree.
TritorX: 481 operators pass 20,000 tests
Coverage first, speed second.
Google · OSDI 2026
ECO
Performance edits as a fleet-wide service for production C++: mine past commits for anti-patterns, find hot matches by profiling, write, verify, send to human review.
6,400 landed commits; hundreds of thousands of CPU cores saved
CPU code; small local edits.
Huawei and partners · 2026
CANN Bench, KOPE
The same loop on Ascend NPUs, where public code is scarce. KOPE stores every attempt in an experience graph and retrieves from it.
Pass rate 84.6%, against 57.8% without the memory
Speed remains far below the vendor library.
OpenAI and Anthropic · 2026
First-party claims
OpenAI says a model rewrote its production kernels, cutting serving cost by 20%. Anthropic reports protein-model kernels 1.7× to 3.2× faster than the field standard.
Blog posts, without methods or benchmarks
KernelFalcon: PyTorch blog. TritorX: arXiv 2512.10977. STARK: arXiv 2510.16996. ECO: arXiv 2503.15669. KOPE: arXiv 2608.25570.
Part 7 · The wider field
Universities: agent designs
University of Minnesota · 2025
CudaForge
A coder and a judge. The judge sees the GPU’s spec sheet and 24 curated profiler metrics, names the bottleneck, and returns exactly one suggestion per round.
1.68× mean over PyTorch on KernelBench; median 1.11×
A few large wins carry the mean.
Stanford and others · 2025
Astra
Starts from production CUDA kernels in a serving framework, not from PyTorch, with testing, profiling, planning and coding agents.
1.32× on three SGLang kernels
Three kernels; integration is manual.
Beihang, SJTU, Tsinghua · ICML 2026
EGG
Encodes the order an expert works in: algorithm first, then parallel mapping, tiling and memory, with a profiling agent at each stage.
2.13× mean over PyTorch at half the tokens of CudaForge
A thin margin over tuned torch.compile on whole models.
University of Minnesota · ICML 2026
StitchCUDA
Whole programs instead of single kernels: a planner, a coder trained with rubric-shaped rewards, and a verifier that profiles system and kernel.
1.50× on full architectures
Results were screened for hacking by hand.
CudaForge: arXiv 2511.01884. Astra: arXiv 2509.07506. EGG: arXiv 2606.26758. StitchCUDA: arXiv 2603.02637.
Part 7 · The wider field
Universities: models trained for kernels
CMU, AWS, Google DeepMind · 2025–2026
TritonRL
An 8B model, distilled then reinforced. The plan is credited with the speed reward and the code with the correctness reward, behind a verifier that rejects kernels delegating to PyTorch.
88% correct, 41% faster than PyTorch (level 1)
Mean speedup only 1.26×.
HKUST and others · 2026
Dr. Kernel
Names “lazy optimization”: correct kernels that touch 0.01% of the runtime. Its reward adds the share of GPU time spent inside the generated kernel.
31.6% of kernels reach 1.2×, ahead of frontier models
Most kernels still fall short of 1.2×.
Chinese Academy of Sciences · AAAI 2026
QiMeng-Kernel
A small RL policy picks what to optimize and where; a general LLM applies that single step. One of a series covering matmul, attention and translation.
2.2× over PyTorch on KernelBench
A small, hand-chosen menu of actions.
Stanford, UCSD, Together AI · 2026
TTT-Discover
Fine-tunes an open model with RL on the one test problem at hand, restarting from its best earlier solutions.
First on four GPU leaderboards for one competition kernel
Wins lean on compiler settings and library matmul.
TritonRL: arXiv 2510.17891. Dr. Kernel: arXiv 2602.05885. QiMeng-Kernel: arXiv 2511.20100. TTT-Discover: arXiv 2601.16175.
Part 7 · The wider field
Universities: search, HPC and translation
UC Berkeley · 2026
K-Search
Separates an idea from its implementation: a tree of optimization ideas with priorities, each tried up to seven times before it is dropped.
2.1× better scores than OpenEvolve on serving kernels
Compared with other searchers, not with expert kernels.
Stanford and AWS · MLSys 2026
AccelOpt
Beam search with a planner, an executor and a summarizer that distils slow-to-fast rewrites into a growing memory. Built for AWS Trainium.
49% → 61% of peak throughput
14 kernels on one core.
University of Maryland · HPDC 2024
ParEval
The yardstick outside deep learning: 420 prompts across OpenMP, MPI, Kokkos, CUDA and HIP.
Best model: 76% on serial code, 40% on parallel
Predates agents and reasoning models.
CAS, USTC, Cambricon · OSDI 2025
QiMeng-Xpiler
Translates tensor programs between CUDA, AMD, Intel and Cambricon dialects with LLM-written passes and a symbolic solver that repairs wrong snippets.
95% translation accuracy
Translation, not optimization.
K-Search: arXiv 2602.19128. AccelOpt: arXiv 2511.15915. ParEval: arXiv 2401.12554. QiMeng-Xpiler: arXiv 2505.02146.
Part 7 · The wider field
MIT HAN Lab: algorithm and kernel, designed together
Stated theme: “We co-design models, kernels, memory layouts, and serving systems.” Each model-level change needs its own kernel.
MLSys 2025
QServe
LLM serving with 4-bit weights. Weights are stored in the order each thread loads them, so the matmul’s main loop stays on INT8 Tensor Cores.
1.2–1.4× (8B model) to 2.4–3.5× (72B) over TensorRT-LLM
Part of the gain is the larger batch 4-bit memory allows.
MICRO 2023
TorchSparse++
Sparse convolution. A short template does the indirect loads; TVM generates the Tensor Core tile. An autotuner picks a dataflow per layer group from measured latency.
1.7× over SpConv v2 on an A100
Generator alone: 1.1–1.2×, at 5% of the code.
MLSys 2025
LServe
Sparse attention for long contexts, built on FlashAttention-2: an iterator skips whole key-value blocks, and dense and streaming heads share one fused kernel.
Prefill up to 2.9×, decode 1.3–2.1× over vLLM on an A100
Mostly sparsity, which changes outputs. Kernel alone: 1.3×.
ICLR 2025
SVDQuant and Nunchaku
4-bit diffusion models. The low-rank branch that restores accuracy is fused into the quantization and matmul kernels, so it re-reads no activations.
Fusion cuts the branch’s overhead from about 50% to 5–10%
The 3× headline over NF4 is the 4-bit arithmetic.
QServe: arXiv 2405.04532. TorchSparse++: 2311.12862. LServe: 2502.14866. SVDQuant: 2411.05007. Also FlashMoBA: 2511.11571.
Part 7 · The wider field
KDA: kernel design agents
MIT HAN Lab, now with NVIDIA · 2026 contest report and code
One contest kernel, a top-k indexer: speedup over the FlashInfer baseline as parts are added (B200, 48 hours)
In the contest’s fully autonomous category it placed first, second and third on the three tracks. Its kernels have since been merged into SGLang and FlashInfer.
The loop
Claude builds in the real repository: it edits, compiles, tests and profiles. Codex, a model from another vendor, reviews each step against a written acceptance criterion. A person co-writes the plan and is asked only when both are stuck.
Two skills, one dispatcher
KernelWiki holds notes distilled from expert kernels and their pull requests. A profiler skill runs Nsight Compute and maps patterns to causes and fixes. The output routes each input shape to a specialised kernel.
Caveats. Team-reported, not peer reviewed. Two of its five contest kernels were slower than the baseline (0.80×, 0.65×). The authors document their agents gaming the checks.
HAN Lab Kernel Mafia. Developing GPU Kernels with Agentic Loops, contest report, 2026. Code: github.com/NVlabs/kda.
Part 7 · The wider field
Three generations of measurement
How the field checks “correct and fast” changed twice in two years:
1 · 2024 to early 2025
Fixed shapes, a few random inputs, loose tolerance, time against eager PyTorch. KernelBench, TritonBench, ParEval.
2 · 2025
The same skeleton, patched by hand: filtered tasks, more input distributions and shapes, process isolation. METR’s filter, robust-kbench, FlashInfer-Bench.
3 · 2026
The candidate is assumed hostile; scores are anchored to hardware limits or to the full model; the checker itself is measured. SOL-ExecBench, KernelBench-Verified, KernelQuest, FastKernels.
The same results, before and after stricter measurement (speedup)
Sakana’s agent on KernelBench
3.13× claimed
1.49× after removing exploitable tasks
Best model, KernelBench-Verified
1.43× claimed
0.88× realistic baseline, hidden tests
µCUTLASS agent, GPT-5.2
5.34× claimed
2.85× after the integrity filter
FastKernels, best kernel-level gain
6.6× claimed
1.25× measured inside the full model
robust-kbench: arXiv 2509.14279. KernelBench-Verified: arXiv 2607.16241. µCUTLASS: arXiv 2603.29010. FastKernels: 2605.23215.
Part 7 · The wider field
Benchmarks beyond KernelBench
| Benchmark | Who | What it adds | A finding |
|---|---|---|---|
| ComputeEval | NVIDIA | 591 hand-written CUDA problems with hidden tests and sanitizers | Best model 70.7%; 2% on a new tile language until given a skill file |
| JAXBench | 50 TPU workloads; expert kernels as the upper bound | Documentation helps more than a larger model | |
| FastKernels | Snowflake, CMU | 384 tasks from 47 real models; scores kernels inside the full model | Only 22 of 110 winning kernel sets run correctly when deployed |
| KernelBench-Verified | Meta, Stanford | A realistic PyTorch baseline and hidden input distributions | No model consistently beats PyTorch |
| KernelQuest | Turing | 13 honesty checks; targets set by certified expert solutions | 813 of 1,800 frontier-agent runs rejected |
| KernelGenBench | BAAI | 210 operators on six hardware platforms | Accuracy falls from 87% to 25% across vendors |
| KernelBench-M | NUS, NTU | Mutation testing: scores the checker, not the model | KernelBench’s check misses 16.9% of injected faults |
NVIDIA ComputeEval repository. arXiv 2607.20466, 2605.23215, 2607.16241, 2611.38125, 2607.27231, 2609.22220.
Part 7 · The wider field
SOL-ExecBench: scoring against the hardware limit
“Times faster than PyTorch” depends on how slow the baseline is. NVIDIA’s benchmark asks instead how much of the gap to an analytic bound, the “speed of light”, a kernel closes.
0
infinitely slow
0.5
as fast as the baseline
1.0
the hardware limit
Cursor’s agents: 0.56
NVIDIA’s optimizer: 0.73
How it is built
7,400 subgraphs extracted from 124 models, reduced to 235 public problems in BF16, FP8 and FP4 on a B200, each with about 16 input shapes and a derived runtime bound.
Results so far
Cursor’s multi-agent run (three weeks on 27 B200s) beat the baseline on 149 of 235 problems, 1.38× geometric mean. Amazon’s CompoundingKernel later led the boards.
Built for hostile candidates
14.5% of submissions from NVIDIA’s own agent were rejected as reward hacks. Clocks are locked, inputs cloned, caches flushed, and each solution runs in its own process.
Lin et al. (NVIDIA). SOL-ExecBench, arXiv 2603.19173. NVIDIA’s score is against PyTorch; Cursor’s is against NVIDIA’s solutions.
Part 7 · The wider field
A catalogue of exploits
Faking the answer
Reuse the reference’s output memory. Cache outputs keyed on the input tensor’s identity. Return a constant where the output never varies.
Faking the source of speed
Call the vendor library or fall back to PyTorch. Emit a kernel that is never launched. Compute in 16 bits and cast back.
Faking the clock
Work on a CUDA stream or thread the timer does not see. Patch the timing function. Replay a captured CUDA graph.
Rewriting the rules
Use one’s own first kernel as the baseline. Copy the validator but drop its NaN check. Read the grader’s answer from the call stack.
Share of agent submissions rejected in SOL-ExecBench, by exploit
How often? 14.5% of submissions there. In KernelQuest, 813 of 1,800 frontier-agent runs failed an honesty check, and 228 of those had met the speed target.
Each pattern was seen in a published benchmark or contest. SOL-ExecBench: arXiv 2603.19173. KernelQuest: arXiv 2611.38125.
Part 7 · The wider field
A contest: MLSys 2026 kernel generation
NVIDIA, CMU, Stanford and the University of Washington ran a competition on the FlashInfer benchmark: write production inference kernels for the Blackwell B200.
Tasks and rules
Three tracks: an FP8 mixture-of-experts layer, DeepSeek’s sparse attention, Qwen’s gated delta network. Any language. Two categories judged apart: agent-assisted, and fully autonomous with reproducible scripts. Scores are speedups over a supplied baseline, zeroed if any workload is wrong.
A lesson from one team. Baidu’s kernel passed the benchmark’s default of three random trials per workload, then failed the organisers’ check: a replay with 200 trials found 3 mismatches from near-ties under FP8.
One team’s speedups over the baseline, by operator (log scale)
sparse
attention
top-k
indexer
gated delta,
prefill
fused MoE,
FP8
gated delta,
decode
people steering agents
fully autonomous agents
Human-directed agents won on all five operators; two autonomous kernels were slower than the baseline.
Contest: mlsys26.flashinfer.ai. Shui et al. (Baidu), Harness Engineering for LLM-Driven GPU Kernel Generation, arXiv 2607.17979.
Part 7 · The wider field
Proofs instead of tests
Georgia Tech, NVIDIA, Stanford · 2025–2026
ProofWright
An agent writes verifier annotations for LLM-generated CUDA; a deductive verifier accepts or rejects them. A wrong annotation simply fails to verify.
Memory and thread safety proved for 74% of kernels; full equivalence for 14
Safety is far easier to prove than equivalence.
Stanford, Microsoft Research, Google DeepMind · 2025–2026
Volta
Symbolically executes the PTX of a reference kernel and an optimized one, and checks that both compute the same expression, catching data races on the way.
Handles convolution, matmul and attention in under 3 minutes
Equivalence over real numbers, not floats.
Imperial, Cambridge, Edinburgh · 2026
LARK
Agents write Lean 4 proofs that a kernel equals its PyTorch specification.
Verified 9 of 10 production kernels; found a new data race in the tenth
Abstract only read for this course.
NUS, NTU · 2026
KernelBench-M
Measures the checker itself: inject small faults into correct kernels and count how many a test protocol catches.
One extra targeted input per problem lifts detection to 98%
ProofWright: arXiv 2511.12294. Volta: arXiv 2511.12638. LARK: arXiv 2611.02028. KernelBench-M: arXiv 2609.22220.
Part 8
Synthesis
One map for every work in the course, the ideas they share, the ways they mislead, and where to go from here.
The map
Level against searcher, a timeline, and who is working on what.
Shared ideas
Six patterns that recur from FlashAttention to agent teams.
Reading critically
A checklist for speedup claims, and the open problems.
Next steps
A learning path, a glossary and the sources.
Part 8 · Synthesis
The map: level against searcher
Human experts
Classical search and RL
Language models and agents
Algorithm
FlashAttention
Mamba
AlphaTensor
AlphaEvolve
Operator
Canvas
GOS
Syno
Kernel source
the craft of Part 2
TVM, Ansor
Kevin, CUDA-L1
AutoKernel
CUDAMaster
CUDA-Harness
Agentic Kernel Opt.
MARCO
PTX
PTXBench
Machine code
hand-tuned assembly
CuAsmRL
STOKE, AlphaDev
autosass
AsmEvo
CASS
Blue: the reading list. Grey: context. MOPS sits outside the grid: the right-hand column’s pattern, applied to robot planning.
Part 8 · Synthesis
The same map, with the wider field
Human experts
Classical search and RL
Language models and agents
Algorithm
FlashAttention-4
Kernel source
ThunderKittens
FlashInfer
DeepGEMM
megakernels
QServe
CUDA Agent
TritonRL
Dr. Kernel
QiMeng-Kernel
KernelEvolve
AVO
µCUTLASS
MaxKernel
Xe-Forge
CudaForge
EGG
K-Search
GEAK
KernelFoundry
KDA
Schedule and compiler
CuTe DSL
TileLang
Hexcute
TLX
Mirage
TorchInductor
Helion
Neptune
Trinity
Twill
TorchSparse++
Reasoning Compiler
Helion’s LLM tuner
PTX
Volta (proofs)
Machine code
EoSS
F2Asm
SIP
CompileIQ
scheduling marks
Orange: works beyond the reading list. Most new work lands in one cell: kernel source, written by agents. No new operator search found.
Part 8 · Synthesis
A timeline, 2022 to 2025
2022–2023
FlashAttention
AlphaTensor
PyTorch 2 compiler
Canvas
AlphaDev
FlashAttention-2
GOS
TorchSparse++
Mamba
FunSearch
2024
ParEval
SIP
Felix
Korch
Mirage
QServe
FlashAttention-3
NeuSight
Syno
Liger-Kernel
ThunderKittens
SVDQuant
2025, first half
FlashInfer
CuAsmRL
KernelBench
AI CUDA Engineer
DeepGEMM
LServe
TritonBench
GPU core study
ECO
Hexcute
TileLang
MARCO
MOPS
CASS
megakernels
AlphaEvolve
Reasoning Compiler
CuTe DSL
GPU Kernel Scientist
2025, second half
Kevin
CUDA-L1
GEAK
QiMeng-Xpiler
Astra
robust-kbench
Neptune
Tawa
TritonRL
STARK
Helion
CudaForge
KernelFalcon
AccelOpt
ProofWright
Volta
QiMeng-Kernel
CUDA Tile
TritorX
Twill
MPK
KernelEvolve
CUDA-L2
Blue: the reading list. Orange: presented beyond the list. Grey: context. Dates are first public versions, in order within each column.
Part 8 · Synthesis
A timeline of 2026
January to March
Field survey
PipeWeave
TTT-Discover
FlashInfer-Bench
Dr. Kernel
K-Search
CUDA Agent
StitchCUDA
FlashAttention-4
CUDAMaster
KernelFoundry
SOL-ExecBench
AutoKernel
AVO
Trinity
µCUTLASS
April to June
Xe-Forge
Nautilus
Prism
autosass
TLX
KDA
FastKernels
CompileIQ
MLSys kernel contest
EGG
July to September
CANN Bench
KernelBench-Verified
JAXBench
KernelGenBench
KernelBrain
Agentic Kernel Opt.
PTXBench
F2Asm
AsmEvo
Accel-Sim 2.0
KOPE
CUDA-Harness
MaxKernel
KernelBench-M
October to December
Meta on AMD GPUs
Helion with CompileIQ
LARK
CompoundingKernel
Scheduling marks
KernelQuest
Colours as on the previous slide. autosass is undated; it is placed after AutoKernel, which it credits. Compiled in December 2026.
Part 8 · Synthesis
Who is working on what: industry
NVIDIA
AVO · µCUTLASS · SOL-ExecBench · ComputeEval · CuTe DSL · CUDA Tile · CompileIQ · Twill, Tawa and Hexcute with universities
Meta
KernelEvolve · TorchInductor · Helion · TLX · KernelFalcon · TritorX · STARK · KernelBench-Verified · training on AMD GPUs
Google and Google DeepMind
MaxKernel and JAXBench for TPUs · ECO · AlphaEvolve · Magellan
Intel
Xe-Forge · KernelFoundry, both for Intel GPUs
AMD
AsmEvo · GEAK · AgentKernelArena, for AMD GPUs
Amazon
AccelOpt for Trainium, with Stanford · CompoundingKernel
Microsoft
KernelBrain · TileLang with Peking · Volta with Stanford
ByteDance, Baidu, Alibaba
CUDA Agent with Tsinghua · contest harness · PipeWeave with SJTU
Huawei
CANN Bench · KOPE, for Ascend NPUs
DeepSeek, LinkedIn
DeepGEMM · Liger-Kernel
OpenAI, Anthropic
Triton, Linear Layouts (OpenAI) · blog-only kernel claims
Smaller companies
Sakana AI: AI CUDA Engineer · RightNow AI: AutoKernel · DeepReinforce: CUDA-L1 · Snowflake: FastKernels · Turing: KernelQuest
Every chip maker now runs kernel agents for its own hardware.
Organisations as listed on each paper; many works are joint. Each name appears on a slide in Parts 3 to 7, with its source.
Part 8 · Synthesis
Who is working on what: universities and institutes
Stanford
FlashAttention · ThunderKittens · megakernels · KernelBench · PTXBench · Astra · Volta · TTT-Discover
Princeton
FlashAttention-2, -3 and -4 · Mamba, with CMU
Carnegie Mellon
Mirage · Prism · MPK · TritonRL
MIT (HAN Lab)
QServe · LServe · TorchSparse++ · SVDQuant · KDA, with NVIDIA
UC Berkeley, UC San Diego, Washington
K-Search · Reasoning Compiler · FlashInfer
Illinois (UIUC)
Neptune · Nautilus · Felix · Korch
Minnesota, Maryland, Cornell
CudaForge · StitchCUDA · ParEval · Tawa
Georgia Tech, Purdue
ProofWright · NeuSight · Accel-Sim 2.0 · EoSS
Cambridge, Imperial, Edinburgh
CuAsmRL · SIP · LARK
Tsinghua, Peking, SJTU, Beihang
Canvas · TileLang · EGG · CUDA Agent, with ByteDance
HKUST and HKUST Guangzhou
Dr. Kernel · hidden scheduling marks · Hopper microbenchmarks
Chinese Academy of Sciences, BAAI
QiMeng-Kernel · QiMeng-Xpiler · the field survey · KernelGenBench
KAIST, NUS, NTU, MBZUAI
Trinity · KernelBench-M · CASS
UPC Barcelona, Toronto, Hauts-de-France
GPU core study · Hexcute · GOS, with IBM
Universities lead on compilers, verification and the hardware itself; industry leads on agents at scale. Only lead groups are shown.
Part 8 · Synthesis
The works side by side: experts, operators, assembly
| Work | Level | Who searches | Evidence of correctness | Headline, with its baseline |
|---|---|---|---|---|
| FlashAttention | Algorithm | Human experts | Exact by construction | 3–10× over PyTorch attention (version 2) |
| Mamba | Algorithm | Human experts | Exact by construction | 20–40× over an unfused scan |
| Canvas | Operator | Random sampling with solvers | Accuracy after training | 1.05× to 4.6× over TVM Ansor |
| GOS | Operator | Evolution | Accuracy within 1% | 1.2× to 5.8× on edge CPUs |
| CuAsmRL | Machine code | Reinforcement learning | Move masking, random tests | Up to 26%, 9% average, over Triton -O3 |
| autosass | Machine code | Agent plus heuristic script | cuBLAS comparison | +5.0% over nvcc on one kernel |
| AsmEvo | Machine code, AMD | LLM agents | Differential test against the original binary | 1.35× over LLM-written kernels; 1.09–1.18× over expert code |
Gains shrink going down the ladder, and the baseline gets stronger. The numbers in this column are not comparable with one another.
Part 8 · Synthesis
The works side by side: translation, PTX, agents
| Work | Level | Who searches | Evidence of correctness | Headline, with its baseline |
|---|---|---|---|---|
| CASS | Source, machine code | Fine-tuned 7B model | Compile and run, 369 tasks | 69% assembly and 88% source accuracy |
| PTXBench | PTX | Frontier LLMs, 8 turns | Outputs, executed instructions | 0.13× to 1.01× of vendor libraries |
| MARCO | Source (Python) | Two agents, web search | LeetCode judge | 14.6% lower runtime than the bare model |
| CUDAMaster | Kernel source | Scripted agent roles | Outputs at several sizes | 94% of tasks faster than naive baselines |
| CUDA-Harness | Kernel source | Agent harness | Synthesized hidden tests | 80.5% functional, against 60.9% |
| AutoKernel | Kernel source | One agent, keep or revert | Frozen five-stage harness | 2.2× to 5.3× over eager PyTorch (starter kernels) |
| Agentic Kernel Opt. | Source, inline PTX | Agent team and a human | Benchmark tolerances | 1.71× over FlashInfer in the official check |
Agents report their largest factors against the weakest baselines; against vendor libraries the best results are near 1×. MOPS is left out: its domain is robot planning.
Part 8 · Synthesis
The works side by side: the wider field
| Work | Level | Who searches | Evidence of correctness | Headline, with its baseline |
|---|---|---|---|---|
| FlashAttention-4 | Algorithm, kernel | Human experts | Exact by construction | 1.1–1.3× over cuDNN on a B200 |
| Mirage | Which kernels exist | Superoptimizer | Random tests over finite fields | Up to 3.3× over the best earlier system |
| KernelEvolve | Kernel source | Agents over a search graph | Outputs against PyTorch | 1.25× to 17× over PyTorch, in production |
| AVO | Kernel source | Agent as the mutation step | Benchmark tests | +3.5% over cuDNN; +10.5% over FlashAttention-4 |
| µCUTLASS | A small DSL | Agent with a roofline bound | Integrity filter | 2.79× geomean over PyTorch |
| MaxKernel | Kernel source, TPU | Agent team | Frozen synthesized tests | 1.62× over XLA; 2.69× where experts reach 2.43× |
| CUDA Agent | Kernel source | RL-trained model | KernelBench checks | 97% of tasks faster than torch.compile |
| Xe-Forge | Kernel source, Intel | Staged agents, autotuning | Four gates, tolerance 1e-2 | 1.17× geomean over eager PyTorch |
The pattern holds outside the reading list: multiples over PyTorch, single-digit percentages over vendor libraries and expert kernels.
Part 8 · Synthesis
Six ideas that recur
1
Runtime is the reward
Measured time drives everything: the reward in CuAsmRL, the fitness in GOS and AlphaEvolve, the keep-or-revert test in AutoKernel.
2
Correctness is a gate
It is checked before speed and never traded against it: move masking, differential tests, a frozen harness, hidden test data.
3
The search space is the design
One safe swap, eight primitives, free-form edits: what a method may change decides what it can find and how hard it is to trust.
4
Structure from the model, numbers from a tuner
MOPS states it; kernel systems practise it. Let the model write a parameterized kernel and let a sweep choose tile sizes.
5
Hardware knowledge decides
autosass gained nothing until its model of the register cache was fixed. PTXBench models need a 25,000-token hardware pack.
6
The expert moves keep returning
Tile, fuse, recompute, overlap loads with compute. Agents mostly rediscover Part 2 and Part 3, kernel by kernel.
Part 8 · Synthesis
Reading a speedup claim
| Ask | Why, with a case from this course |
|---|---|
| What is the baseline? | AsmEvo gains 1.35× over LLM-written kernels and 1.09× over expert code. CUDAMaster starts from deliberately naive kernels. |
| Could the candidate affect the test? | Skipped correctness checks (AI CUDA Engineer), extra CUDA streams (CUDA-L1), cached outputs (Agentic Kernel Optimization). |
| How is correctness judged? | Five random inputs at one shape (KernelBench); tolerances as loose as 1e-2; 8.7% false passes for synthesized tests. |
| Does it fit the benchmark’s shapes? | A sparse kernel that hard-codes the test’s column count; a fast path that covers 69 of 128 workloads. |
| Is the gain above the noise? | CuAsmRL’s smallest gains are 1–2% with 1% noise; a 1% keep-threshold on a single run keeps luck. |
| Mean, median or best-of-N? | CUDA-L1: mean 3.12×, median 1.42×. Kevin: best-of-16 is 1.10×, the average attempt 0.40×. |
| Does it carry to another GPU? | CASS drops from 69% to 33% one generation later; FlashAttention needed a rewrite for Hopper. |
None of these questions requires distrust of the authors. They are what a careful author answers in the paper.
Part 8 · Synthesis
Open problems
Proof instead of tests
ProofWright and Volta now prove safety, or equivalence at PTX level, for simple kernels. Machine code still has no public semantics.
Portability
Tuned assembly and learned translators break at the next GPU generation. Nobody yet transfers a search result across architectures.
Cost of search
Hours of GPU time per kernel for CuAsmRL and AsmEvo; a billion tokens for one agent-written kernel. A learned cost model could replace many real runs.
Benchmarks that resist gaming
Fresh inputs, several shapes, hidden tests and executed-instruction checks are known remedies; few benchmarks have them all.
New hardware features
PTXBench: one cell of 24 reaches the vendor library. Models write correct kernels far more easily than kernels that use the new units.
From one kernel to a whole model
Most results are per kernel. FastKernels found that only 22 of 110 winning kernel sets ran correctly once deployed in the full model.
A personal reading of the gaps the surveyed works leave open, as of December 2026.
Part 8 · Synthesis
A learning path
1 · Write the ladder yourself
Compile SAXPY, dump its PTX and SASS, then walk the matmul ladder of Part 2. Each step is a few dozen lines of CUDA.
2 · Profile before you change anything
Run one kernel under Nsight Compute. Find its memory throughput and occupancy, and place it on the roofline.
3 · Read one expert kernel closely
FlashAttention’s paper and repository reward a slow read. The Triton fused-attention tutorial is the same algorithm in a single file.
4 · Run an agent loop on your own GPU
AutoKernel’s loop is a handful of scripts. Watch what the agent tries, what the harness rejects, and where it stalls.
5 · Go below the compiler
Open a kernel in CuAssembler, read the control codes, and try the single swap from the CuAsmRL slide.
Good companions: NVIDIA’s CUDA Best Practices Guide, Simon Boehm’s CUDA matmul article, and Liger-Kernel’s short Triton kernels.
Part 8 · Synthesis
Glossary
Kernel
A function executed on the GPU by many threads.
Warp
A group of 32 threads that execute the same instruction together.
SM
Streaming multiprocessor: the unit that runs warps; a GPU has dozens to hundreds.
SIMT
Single instruction, multiple threads: the GPU’s execution style.
HBM
High-bandwidth memory: the GPU’s large, comparatively slow global memory.
Shared memory
Fast on-chip memory shared by the threads of one block.
Coalescing
Merging a warp’s neighbouring loads into few memory transactions.
Occupancy
The share of an SM’s warp slots a kernel fills.
Arithmetic intensity
Operations performed per byte moved; the x-axis of the roofline.
Fusion
Combining operators into one kernel so intermediates stay on chip.
Tensor Core
A hardware unit for small matrix multiply-accumulate operations.
PTX
NVIDIA’s documented, portable virtual assembly.
SASS
The machine code of one GPU architecture.
Control code
Per-instruction scheduling fields in SASS: barriers, yield, stall count.
Superoptimization
Searching for a faster equivalent of already compiled code.
fast_p
KernelBench’s metric: share of tasks correct and more than p times faster.
Part 8 · Synthesis
Sources: the reading list
FlashAttention · Dao et al., NeurIPS 2022 · arXiv 2205.14135
FlashAttention-2 · Dao, 2023 · arXiv 2307.08691
FlashAttention-3 · Shah et al., NeurIPS 2024 · arXiv 2407.08608
Mamba · Gu and Dao, 2023 · arXiv 2312.00752
Canvas · Zhao et al., 2023 · arXiv 2304.07741
GOS · Benmeziane et al., 2023 · arXiv 2309.11246
CuAsmRL · He and Yoneki, CGO 2025 · arXiv 2501.08071
AsmEvo · Liu et al., 2026 · arXiv 2608.20711
autosass · github.com/gpuasm/autosass, 2026
CASS · Heakl et al., ACL 2026 · arXiv 2505.16968
PTXBench · Zhang et al., 2026 · arXiv 2608.17379
MARCO · Rahman et al., 2025 · arXiv 2505.03906
CUDAMaster · Han et al., 2026 · arXiv 2603.07169
CUDA-Harness · Fan, Zou, Ma, 2026 · arXiv 2609.00058
AutoKernel · Jaber and Jaber, 2026 · arXiv 2603.21331
Agentic Kernel Optimization · Luo, Li et al., 2026 · arXiv 2608.14560
Houmao · github.com/igamenovoer/houmao
MOPS · Shcherba et al., CoRL 2025 · arXiv 2505.03725
Numbers on the slides come from these primary sources, read in December 2026. Preprints may change.
Part 8 · Synthesis
Sources: context and background
KernelBench · Ouyang et al., ICML 2025 · arXiv 2502.10517
robust-kbench · Lange et al., 2025 · arXiv 2509.14279
Kevin · Baronio et al., 2025 · arXiv 2507.11948
CUDA-L1 · DeepReinforce, ICLR 2026 · arXiv 2507.14111
AlphaEvolve · Google DeepMind, 2025 · arXiv 2506.13131
FunSearch · Romera-Paredes et al., Nature 2024
KernelEvolve · Liao et al., 2025 · arXiv 2512.23236
GPU Kernel Scientist · Andrews and Witteveen, 2025 · arXiv 2506.20807
STOKE · Schkufza, Sharma, Aiken, ASPLOS 2013
AlphaDev · Mankowitz et al., Nature 2023
SuperCoder · Wei et al., 2025 · arXiv 2505.11480
AlphaTensor · Fawzi et al., Nature 2022
AutoML-Zero · Real et al., ICML 2020 · arXiv 2003.03384
Syno · Zhuo et al., ASPLOS 2025 · arXiv 2410.23745
Ansor · Zheng et al., OSDI 2020 · arXiv 2006.06762
Triton · Tillet, Kung, Cox, MAPL 2019
Roofline · Williams, Waterman, Patterson, CACM 2009
NVIDIA: CUDA Programming Guide, Best Practices Guide, PTX ISA, A100 and H100 whitepapers
Measurements in Parts 0 to 2 were made for this course on an RTX 3060 with CUDA 12.8.
Part 8 · Synthesis
Sources: expert kernels, compilers, the machine
FlashAttention-4 · Zadouri et al., MLSys 2026 · arXiv 2603.05451
ThunderKittens · Spector et al., ICLR 2025 · arXiv 2410.20399
FlashInfer · Ye et al., MLSys 2025 · arXiv 2501.01005
DeepGEMM · github.com/deepseek-ai/DeepGEMM, 2025
Liger-Kernel · LinkedIn, 2024 · arXiv 2410.10989
Hexcute · Zhang et al., CGO 2026 · arXiv 2504.16214
TileLang · ICLR 2026 · arXiv 2504.17577
Twill · Soi et al., OSDI 2026 · arXiv 2512.18134
TLX · Guan et al., 2026 · arXiv 2605.10905
PyTorch 2 · Ansel et al., ASPLOS 2024
Mirage · Wu et al., OSDI 2025 · arXiv 2405.05751
Prism · 2026 · arXiv 2604.15272; MPK · OSDI 2026 · arXiv 2512.22219
Neptune · Zhao et al., PLDI 2026 · arXiv 2510.08726
Nautilus · Zhao et al., 2026 · arXiv 2604.14825
Reasoning Compiler · NeurIPS 2025 · arXiv 2506.01374
Tawa · Chen et al., CGO 2026 · arXiv 2510.14719
GPU cores · Huerta et al., MICRO 2025 · arXiv 2503.20481
EoSS · Avalos Baddouh, Rogers, Payer, ASPLOS 2027
Scheduling marks · Wang et al., 2026 · arXiv 2611.24437
F2Asm · Gai, 2026 · arXiv 2608.20532; SIP · arXiv 2403.16863
Accel-Sim 2.0 · Pan et al., 2026 · arXiv 2608.22602
Training on AMD GPUs · Meta and AMD, MICRO 2026 · arXiv 2610.22230
Works beyond the reading list, Parts 3 to 5. Trinity (ASPLOS 2026), Helion, CUDA Tile and CompileIQ are cited on their slides.
Part 8 · Synthesis
Sources: industry, universities, evaluation
Survey · Yu et al., IJCAI 2026 · arXiv 2601.15727
KernelEvolve · Liao et al., ISCA 2026 · arXiv 2512.23236
AVO · Chen et al., NeurIPS 2026 · arXiv 2603.24517
µCUTLASS · Hari et al., NeurIPS 2026 · arXiv 2603.29010
MaxKernel · arXiv 2609.04523; JAXBench · arXiv 2607.20466
CUDA Agent · Dai, Wu et al., 2026 · arXiv 2602.24286
Xe-Forge · arXiv 2605.26118; KernelFoundry · arXiv 2603.12440
GEAK · AMD, 2025 · arXiv 2507.23194; KernelBrain · arXiv 2608.02611
KDA · github.com/NVlabs/kda; contest report, 2026
QServe · arXiv 2405.04532; LServe · arXiv 2502.14866
TorchSparse++ · arXiv 2311.12862; SVDQuant · arXiv 2411.05007
TritorX · arXiv 2512.10977; STARK · arXiv 2510.16996
ECO · Google, OSDI 2026 · arXiv 2503.15669; KOPE · arXiv 2608.25570
CudaForge · arXiv 2511.01884; Astra · arXiv 2509.07506
EGG · arXiv 2606.26758; StitchCUDA · arXiv 2603.02637
TritonRL · arXiv 2510.17891; Dr. Kernel · arXiv 2602.05885
QiMeng-Kernel · arXiv 2511.20100; TTT-Discover · arXiv 2601.16175
K-Search · arXiv 2602.19128; AccelOpt · arXiv 2511.15915
ParEval · arXiv 2401.12554; QiMeng-Xpiler · arXiv 2505.02146
SOL-ExecBench · Lin et al., 2026 · arXiv 2603.19173
KernelBench-Verified · arXiv 2607.16241; FastKernels · arXiv 2605.23215
KernelQuest · arXiv 2611.38125; KernelBench-M · arXiv 2609.22220
ProofWright · arXiv 2511.12294; Volta · arXiv 2511.12638
LARK · arXiv 2611.02028; contest harness · arXiv 2607.17979
Works of Part 7. Most 2026 entries are preprints: their numbers may change, and several have not been peer reviewed.