Skip to content

KernelDojo.com · 19 forks · 27 Nov 2026

Advanced GPU Kernel Engineering

Nineteen libraries, forked for reading. The work is a pull request to the original repository, from your own fork, onto their default branch. The Blockchains copy is not the place a student patch lands.

The method

  1. 01

    Fork the original repository to your own account. The Blockchains fork is the reading copy. Your pull request targets their default branch, not Blockchains.

  2. 02

    Open the one path named on the card. If the file is not there, stop and say so.

  3. 03

    Draw the bytes before you time. Roofline, fusion, tiles, or skip-error. The diagrams on this page are the templates.

  4. 04

    Match numerics against a reference you can name. A fast kernel that is a different function fails.

  5. 05

    Change one mechanism. Fusion, or sparsity, or precision, or a skip. Not two.

  6. 06

    Open Compare on the original repo. Base is their default branch. Head is your fork. Include the test and what you did not measure.

  7. 07

    Keep upstream numbers in the upstream sentence. Your table contains only runs you did.

Eight sessions, 38 hours

Hours are the work, not a video. Each session opens one fork and leaves a number you computed. None of those numbers is a GPU time.

  1. 01 · 4 h

    llm.c

    Read one kernel

    Open train_gpt2.cu. Find one matmul. Do not time it. Write what it reads and what it writes, in bytes, for a shape you choose.

  2. 02 · 4 h

    Liger

    Delete a round trip

    In src/liger_kernel/ops, name the activation that no longer returns to memory. Compute the eager byte count and the fused one. The step will not match that ratio.

  3. 03 · 6 h

    FlashAttention

    Exact attention

    In csrc/flash_attn, find the tile. Use the desk below: the score matrix is resident or it is not. Tiling does not cut the math.

  4. 04 · 4 h

    FlashInfer

    Pages, or not

    Compute page waste for lengths 100 and 5, then for 17 and 3. Explain which case paging loses. If the model recomputes K and V, write “nothing to page”.

  5. 05 · 6 h

    SpargeAttention

    A tile that does not launch

    In csrc/ or Triton_SpargeAttn/, point at the branch that skips a tile. A zero mask after a dense GEMM is the wrong branch. Do not copy the paper’s speed.

  6. 06 · 6 h

    Sage, bitsandbytes, Transformer Engine, Nunchaku

    The scale

    Run quant_codes on a vector with one outlier. Record which entries became 0. Name the device capability before you call anything FP8 or FP4.

  7. 07 · 4 h

    ThunderKittens, CUTLASS, TileLang

    Tiles as the language

    Cover a length that is not a multiple of the block. Count the tail. Say which elements a missing mask would store.

  8. 08 · 4 h

    Flash Linear Attention

    A different algorithm

    Write one sentence on why the N² score-byte formula does not apply. If you cannot, you have not opened the README.

Desk

The same functions as modules/gpu/kernel_math.py. The unit test is the answer key. This is not a profile.

Score matrix
33,554,432 B
Q, K and V
3,145,728 B
One 64×64 tile
8,192 B
Tiles in the matrix
4,096 B

BF16, head dim 128. At N=4096 the matrix is 33,554,432 bytes and one tile is 8,192. Exact tiling still covers every tile. It stops the matrix living in memory.

Quant. Values 0.2, 0.05, 0.02, 8 onto 127 levels become 3, 1, 0, 127. The 8 stays at 127. The 0.02 becomes 0.

Pages. Lengths 100 and 5, page 16: waste 23, padding waste 95. Lengths 17 and 3: waste 28, padding waste 14. The second case is worse.

Diagrams

Original figures for the method. They are not a paper’s artwork and they are not measurements.

Roofline diagram. A rising memory-bound line meets a flat compute ceiling at the ridge.
Left of the ridge, deleting bytes is the only lever. Right of it, you need more math throughput.
Fusion diagram. Eager RMSNorm writes an activation that the next linear reads back. The fused kernel stores once.
The ratio on that activation is 2×. The step is not 2×. Weights still move.
Grid of attention tiles. Filled tiles are exact, gold tiles are a cheap proxy, empty tiles must be skipped rather than zeroed after a dense multiply.
Empty means the kernel did not launch. A zero mask after a full GEMM still did the work.
Skip-error diagram. Signal is high at the first and last step. Error climbs through skipped middle steps until a reset.
Simulated. Not a DiT. Threshold zero must not drift. A segment reset beats carrying the error.
Online softmax. Three tiles arrive in order. When the maximum jumps, the running sum is rescaled. The score matrix is never stored.
Tiling does not reduce the math. Forgetting the rescale makes an exact kernel inexact.
Four bars, three short and one tall. The tall bar sets the quantisation step.
One outlier sets the step. Smaller values round down, sometimes to zero. The picture goes flat before a NaN.
Paged KV for lengths 100 and 5 on pages of 16, which wastes less than padding both to 100. A coarse page can still lose.
Lengths 100 and 5: paging wastes 23, padding wastes 95. Lengths 17 and 3: paging wastes more. A page is not free.

The forks

Each card names a path that was present in the upstream tree on 27 Nov 2026. If a later commit moves it, the card is stale and you should say so.

  1. 01 · Attention

    25,357 upstream

    FlashAttention

    csrc/flash_attn — confirmed in Dao-AILab/flash-attention

    Exact attention. Scores stay in tiles and the softmax runs online, so the N² matrix is never stored. Every sparse or quantised attention on this shelf is a deviation from this algorithm, and has to be compared with it.

    Failure. A causal or padding mask applied after the GEMM, or filled with zero instead of a large negative, changes the softmax. The kernel can be fast and wrong.

    Speed on their README is theirs. Nothing on this page was timed here.

    Desk: set N and compare the score matrix with one 64×64 tile. Exact attention still does every score. It just refuses to store them.

    BSD-3-Clause · PythonDiagram · tiles

  2. 02 · Attention

    7,020 upstream

    FlashInfer

    README.md, then the CUDA sources in the tree. Do not assume a path you have not opened.

    Serving kernels for LLM decode: attention variants, sampling, and a page table so a finished request can return KV pages without a copy. The batching unit is the token, not the diffusion step.

    Failure. Paging a DiT that recomputes K and V every step. There is often no growing cache. Say so, or do not cite this repo.

    Built for LLM serving. A video step is a different working set.

    Desk: lengths 100 and 5 beat padding. Lengths 17 and 3 do not. Write both.

    Apache-2.0 · CUDADiagram · tiles

  3. 03 · Attention

    1,269 upstream

    SpargeAttention

    csrc/ and Triton_SpargeAttn/ — both present in thu-ml/SpargeAttn

    Training-free sparse attention. The lesson is the branch that does not launch a tile. A mask of zeros after a dense GEMM is a different, slower program.

    Failure. Dropping the diagonal, or the text tokens a video model uses as a sink. Prompt adherence dies while mean LPIPS barely moves.

    ICML 2025 claims stay in the paper. Your table stays empty until you fill it.

    After you can point at a skipped tile, estimate the fraction you skipped. A fraction is not a speedup.

    Apache-2.0 · CUDADiagram · tiles

  4. 04 · Attention

    6,096 upstream

    Flash Linear Attention

    README.md in fla-org/flash-linear-attention. Open the implementation the README names before you time anything.

    Triton kernels for linear-attention variants. The recurrence is not softmax attention. Bytes, gradients and failure modes do not transfer in either direction.

    Failure. Reporting a linear-attention speedup as a FlashAttention result. They are different functions.

    A win here does not transfer to the exact tiled kernel above.

    State the recurrence in one line. If the line still says softmax, stop.

    MIT · PythonDiagram · roofline

  5. 05 · Quant

    4,026 upstream

    SageAttention

    csrc/ — present in thu-ml/SageAttention

    Attention matmul in INT8 and FP8. Narrow the product, and check the online softmax before you trust the frame. Outliers set the scale. The bulk of the scores then round toward zero.

    Failure. A per-tensor scale taken over padding. Zeros in the batch lie about amax, and the picture goes flat without a NaN.

    Upstream says about 2–5× versus FlashAttention without losing end-to-end metrics, across language, image and video. CLAIMED BY SOURCE.

    Quantise a head of scores with one large logit. See which neighbours collapse.

    Apache-2.0 · PythonDiagram · tiles

  6. 06 · Quant

    3,967 upstream

    Nunchaku

    nunchaku/csrc and nunchaku/ops — both present in nunchux-ai/nunchaku

    SVDQuant kernels for 4-bit diffusion. Outlier channels move into a low-rank branch so the 4-bit GEMM is not asked to represent them. That is the Module 5 failure, turned into a kernel.

    Failure. Pointing the kernel at weights whose licence you have not read. Apache-2.0 covers this code, not the checkpoint.

    Read the model card before any download. Do not mix this timing with a BF16 ablation from another paper.

    Name the low-rank branch and the 4-bit branch. If you cannot, you are not in nunchaku/ops yet.

    Apache-2.0 · PythonDiagram · fusion

  7. 07 · Quant

    8,557 upstream

    bitsandbytes

    bitsandbytes/functional.py — present in bitsandbytes-foundation/bitsandbytes. The CUDA backends sit beside it.

    k-bit matrix kernels for PyTorch, including the 8-bit and 4-bit paths people use to keep an LLM resident. The lesson is the scale and the outlier, not the flag that selects the dtype.

    Failure. A silent fallback to the wide type. If the kernel did not run in the narrow format, the timing is not a quant result.

    Training and LLM inference. Not a licence to quantise a video model you have not named.

    Find the scale next to the narrow matrix. A missing scale means the kernel is not the one you think.

    MIT · PythonDiagram · roofline

  8. 08 · Quant

    3,619 upstream

    Transformer Engine

    transformer_engine/pytorch — present in NVIDIA/TransformerEngine

    NVIDIA’s FP8 and FP4 transformer kernels for Hopper, Ada and Blackwell. The library fuses the cast into the GEMM. The thing you must record is the device capability the kernel actually ran on.

    Failure. Labelling a BF16 fallback as FP8 or FP4. Blackwell FP4 and a Hopper FP8 run are different rows.

    Performance claims on the NVIDIA page are theirs. CLAIMED BY SOURCE until you measure.

    Read the FP8 cast beside the GEMM. Record SM. A fallback is a different row.

    Apache-2.0 · PythonDiagram · fusion

  9. 09 · Fusion

    6,715 upstream

    Liger Kernel

    src/liger_kernel/ops — present in linkedin/Liger-Kernel

    Triton fusions used in training: RMSNorm, RoPE, SwiGLU, fused linear cross-entropy. An activation that used to round-trip to memory stays on chip. That is the entire trick.

    Failure. Quoting a training-step ratio as a video-sampler ratio. The working set is not the same.

    Their numbers are training steps. Do not carry them across.

    Count bytes of the fused op versus the eager chain. Exclude the weight read, then put it back.

    BSD-2-Clause · PythonDiagram · fusion

  10. 10 · Tiles

    3,809 upstream

    ThunderKittens

    include/kittens.cuh — present in HazyResearch/ThunderKittens

    Tile primitives for Hopper CUDA. You write the kernel as tiles, not as a thread index you hope the compiler will vectorise. Occupancy is not the result. The result is a roofline you can defend.

    Failure. A tile that wins on a long sequence and loses on a short one, because the tail and the launch dominate. Ship the shape you measured.

    A way to author a kernel. Not a speedup until the kernel is yours and timed.

    Pick a tile edge from the headers. Run tile_grid on a length that is not a multiple.

    MIT · CUDADiagram · roofline

  11. 11 · Tiles

    10,782 upstream

    CUTLASS

    include/ and examples/ — both present in NVIDIA/cutlass. Licence text is BSD-3-Clause in LICENSE.txt.

    CUDA templates and CuTe layouts under a large share of high-end GEMMs. Open it when Triton is no longer the right tool, and only after you can explain the Triton result you are replacing.

    Failure. A green example that is not your shape. Pin the commit. A newer template is a different kernel.

    An example timing is not your model’s step time.

    Open one example whose shape you understand. Pin the commit in the note.

    BSD-3-Clause · C++Diagram · roofline

  12. 12 · Tiles

    9,048 upstream

    TileLang

    README.md and LICENSE — MIT, with a dated collaboration note covering 1 Dec 2024 to 14 Mar 2025. Read that note before you redistribute.

    A language for writing GPU kernels as tiles, then lowering them. Use it to express one fusion you already understand in Triton. Do not start here.

    Failure. Treating the DSL as the result. The result is still the kernel it emits, checked against PyTorch.

    Star count is upstream. This preview did not build TileLang.

    Read the MIT licence, including the dated collaboration note, before you copy an example out.

    MIT · PythonDiagram · fusion

  13. 13 · CUDA

    31,571 upstream

    llm.c

    train_gpt2.cu — present at the root of karpathy/llm.c

    GPT-2 training written as C and CUDA you can read in an afternoon. The matmul and the attention are not hidden behind a framework. Use it to see a kernel before you trust a library that wraps one.

    Failure. Calling this an inference stack. It is a training program. The memory story of decode is different, and Module 0 exists to say how.

    MIT. Educational. Not a serving runtime, and not a measured KernelDojo benchmark.

    One matmul, one sentence on its bytes. Training, not decode. Their default branch is master.

    MIT · CUDADiagram · roofline

  14. 14 · Language

    20,656 upstream

    Triton

    python/ and CONTRIBUTING.md — both present at the root of triton-lang/triton

    The language this programme writes kernels in. A Triton program is a tile program: you choose the block, the compiler maps it to the GPU. CUTLASS is what you open after you can explain the Triton result, not before.

    Failure. A pull request that adds an API without a test, or a benchmark that includes the compile. Steady state only.

    20,656 upstream stars on 28 Nov 2026. Their examples are not your model’s step time.

    Read CONTRIBUTING.md. A student PR is a failing test made green, or a tutorial that is wrong. Not a new compiler feature on the first week.

    MIT · PythonDiagram · fusion

  15. 15 · Quant

    3,039 upstream

    torchao

    torchao/ and CONTRIBUTING.md — both present in pytorch/ao

    PyTorch-native quantisation for training and inference. The kernel is the narrow GEMM plus the scale. The policy file does not make the numerics right.

    Failure. Casting the residual in the narrow type. The update disappears inside one quantum of the activation.

    3,039 upstream stars on 28 Nov 2026. Licence is BSD; read LICENSE before you copy a file out.

    Open torchao/. Find one quantised GEMM and the scale beside it. PR against pytorch/ao main.

    BSD · PythonDiagram · quant

  16. 16 · Attention

    10,584 upstream

    xFormers

    xformers/ and CONTRIBUTING.md — both present in facebookresearch/xformers

    Memory-efficient attention and the fused blocks around it. It is a neighbour of FlashAttention, not a second name for the same kernel. Say which function you called.

    Failure. Reporting an xFormers op and a FlashAttention op as one ablation row. They are different code.

    10,584 upstream stars on 28 Nov 2026. BSD-3-Clause.

    Name the function you would change in xformers/. Do not describe it as FlashAttention.

    BSD-3-Clause · PythonDiagram · tiles

  17. 17 · Fusion

    9,014 upstream

    Apex

    apex/ and csrc/ — both present in NVIDIA/apex. The default branch is master, not main.

    NVIDIA’s fused optimisers, layer norm and amp extensions. Some of this landed in PyTorch itself. If the function you wanted is now in core, time that, and say the Apex path was the ancestor.

    Failure. A pull request against main. Their default branch is master. A PR aimed at the wrong base does not land.

    9,014 upstream stars on 28 Nov 2026. BSD-3-Clause.

    Default branch is master. If the fused op now lives in PyTorch, say so in the PR and do not time the abandoned path.

    BSD-3-Clause · PythonDiagram · fusion

  18. 18 · Attention

    313 upstream

    FlashInfer Bench

    flashinfer_bench/ and CONTRIBUTING.md — both present in flashinfer-ai/flashinfer-bench

    The bench where a kernel is a submission, not a screenshot. You take a definition, write the kernel, and the project’s runner records the trace. That trace is the result. A number you typed is not.

    Failure. A submission without the trace their runner produces. Also: treating their leaderboard as a KernelDojo measurement.

    313 upstream stars on 28 Nov 2026. Apache-2.0. This is the contribution surface for serving kernels.

    Read CONTRIBUTING.md. A kernel PR needs the runner’s trace. A pasted number is rejected.

    Apache-2.0 · PythonDiagram · tiles

  19. 19 · Language

    796 upstream

    HF Kernels

    kernels/ and CONTRIBUTING.md — both present in huggingface/kernels. kernel-builder/ is the build side.

    Build a compute kernel and load it. The hub is the distribution step, after the kernel matches a reference. The kernel’s licence and the model’s licence are two documents.

    Failure. Publishing a kernel you have not matched against eager PyTorch, or shipping weights under the kernel’s Apache licence.

    796 upstream stars on 28 Nov 2026. Apache-2.0.

    Read CONTRIBUTING.md. Match eager PyTorch before you ask the hub to load the kernel.

    Apache-2.0 · RustDiagram · fusion

all · 19 showing. A fork keeps the upstream licence. It is not a grant to relicense. Programme notes live with the KernelDojo repo.