Pull down to go back
A Hackable ML Compiler Stack in 5,000 Lines of Python

A Hackable ML Compiler Stack in 5,000 Lines of Python

用 5,000 行 Python 打造可駭客改造的機器學習編譯器堆疊

The modern ML compiler landscape is overwhelming—TVM is 500K+ lines of C++, PyTorch stacks Dynamo, Inductor, and Triton on top of each other, and then there's XLA, MLIR, Halide, and Mojo. Most tutorials throw you straight into the complexity without explaining the high-level design. This project builds a working ML compiler from scratch in just ~5K lines of pure Python that generates raw CUDA code, taking small models like TinyLlama and Qwen2.5-7B and optimizing them end-to-end. It's a practical reference implementation that actually shows how these systems work under the hood.