ThunderKittens: Simple, Fast, and Adorable AI Kernels

Benjamin Spector, Simran Arora, Aaryan Singhal, Daniel Y. Fu, Christopher Ré · DOI

Abstract

ThunderKittens (TK) is an embedded C++ framework designed to bridge the gap between high-level ease of use and low-level hardware performance in GPU kernel development. By centering abstractions around 16x16 matrix tiles and providing a structured Load-Compute-Store-Finish (LCSF) template, TK enables developers to write kernels that match or exceed the performance of industry standards like FlashAttention-3 and CuBLAS. TK's design minimizes cognitive load by automating complex memory management tasks such as swizzling, making high-performance GPU programming accessible even to non-experts while maintaining a library footprint of less than 1MB.

Introduction

As AI models evolve at breakneck speed, the hardware they run on has become increasingly complex. Modern GPUs, such as the NVIDIA H100, offer immense theoretical throughput, yet a significant "performance gap" persists between this theoretical capability and the actual speed of most production code. Currently, developers face a difficult trade-off: use high-level compilers like Triton, which are accessible but often fail to leverage the latest hardware-specific optimizations, or use low-level libraries like NVIDIA CUTLASS, which are incredibly fast but notoriously difficult to write and maintain due to their reliance on complex nested templates.

ThunderKittens (TK) proposes a third way. It is a small, "opinionated" framework that provides a set of abstractions as fast as low-level libraries but as intuitive as PyTorch. By focusing on the physical hierarchy of the GPU, TK allows developers to write high-performance kernels with significantly less code and specialized knowledge.

Design Philosophy and Methods

ThunderKittens introduces three primary abstractions that map directly to the physical structure of a GPU:

1. Warp-level: The 16x16 Tile

Instead of managing individual threads, TK treats a 16x16 matrix tile as the basic unit of data. This "sweet spot" aligns perfectly with the hardware's Tensor Cores, simplifying the math and ensuring peak efficiency. TK provides PyTorch-like operations (e.g., exp, matmul, sum) that operate directly on these tiles. Crucially, TK automatically handles "swizzling"—a complex memory layout technique required to prevent bank conflicts—allowing developers to focus on logic rather than memory hardware quirks.

2. Block-level: The LCSF Template

To maximize GPU utilization, data movement must be overlapped with calculation. TK provides a Load-Compute-Store-Finish (LCSF) template. Developers fill in these four functions, and the framework manages the underlying synchronization and pipelining. This structure ensures that the GPU's compute units remain busy while data is being fetched from or written to memory.

3. Grid-level: Persistent Scheduling

TK supports "persistent grids," which reduce the overhead associated with starting and stopping work on the GPU. This approach helps hide latency and ensures a steady stream of work for the hardware.

As an embedded C++ library, TK grants developers direct access to the latest hardware features, such as the H100’s asynchronous memory units, without the overhead of a heavy compiler or the complexity of a 600MB+ library like CuBLAS.

Performance Evaluation

ThunderKittens was benchmarked on an NVIDIA H100 80GB SXM GPU across several AI primitives, including standard matrix multiplication (GEMM), various Attention mechanisms, and emerging architectures like State Space Models (SSMs).

Key Results:

  • Attention Backwards: TK outperforms FlashAttention-3 by 10–40%.
  • Linear Attention: TK achieves a 14× speedup over the strongest existing baselines.
  • State Space Models (SSMs): TK outperforms prior implementations by 8×.
  • GEMM: TK matches the performance of NVIDIA’s highly optimized CuBLAS library using only approximately 40 lines of code.

Profiling data indicates that TK kernels exhibit significantly fewer "stalled cycles" and zero bank conflicts compared to industry-standard implementations, confirming that its abstractions effectively manage hardware resources.

Discussion and Insights

The success of ThunderKittens suggests that the primary bottleneck in AI progress may not be hardware limitations, but rather the difficulty of existing programming tools. The authors noted that several record-breaking kernels were authored by undergraduates with no prior CUDA experience, highlighting the framework's accessibility.

Furthermore, TK’s tiny footprint (<1MB) makes it ideal for specialized production environments, such as edge inference or high-frequency trading, where large library dependencies are a liability. By automating memory layout management, TK removes the most common source of performance bugs in GPU programming.

Limitations and Future Work

While the principles of ThunderKittens are broadly applicable, the current implementation is heavily optimized for NVIDIA’s H100 and A100 architectures. Future work includes expanding support for AMD and Apple Silicon GPUs. Additionally, while the LCSF template simplifies development, it still requires some boilerplate code. The authors have open-sourced the project and envision future high-level compilers that could target ThunderKittens abstractions to further automate the kernel creation process.

Conclusion

ThunderKittens demonstrates that high-performance GPU programming does not have to be an exercise in frustration. By providing the right abstractions at the right level of the hardware hierarchy, TK enables the creation of kernels that are simple, fast, and highly efficient.

Summary updated

BibTeX
@inproceedings{spector2025thunderkittens,
  author = {Benjamin Spector and Simran Arora and Aaryan Singhal and Daniel Y. Fu and Christopher Ré},
  title = {{ThunderKittens: Simple, Fast, and Adorable AI Kernels}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=0fJfVOSUra},
}
Figure