Install it, run it, then pick your reading path: the quick tour, the from-zero story, or the source itself.
git clone https://github.com/arpitsinghgautam/nano-triton
cd newt
pip install -e . # needs torch + an NVIDIA GPU + CUDA toolkit
python -m pytest tests -q # 176 tests (GPU ones self-skip without CUDA)
python examples/01_vector_add.py
The quick tour: highlights, quick start, benchmark tables, the concept-mapping table.
This site's story in one markdown file, written for readers starting from zero.
vector add, fused softmax, layernorm, autotuned matmul, fused flash attention, and the deuteron versions.
newt/compiler/codegen.py: AST to CUDA C++ in ~2,500 lines. The heart of the project.
Full result tables, and bench.py to reproduce them (use --cooldown on laptops).
Each compiler stage in the journey chart landed as one commit, so the history reads like a build log.
newt/language.py the nl.* DSL surface (mirrors triton.language)
newt/compiler/types.py dtypes, pointers, promotion, broadcasting
newt/compiler/codegen.py AST -> CUDA C++ (the compiler, ~2.5k lines)
newt/runtime/cuda.py ctypes NVRTC + CUDA driver bindings
newt/runtime/jit.py @newt.jit, specialization cache, launch
newt/runtime/autotuner.py @newt.autotune / @newt.heuristics
deuteron/language.py dt.* surface + eager (PyTorch) implementations
deuteron/codegen.py tile-DSL AST -> newt kernel source
deuteron/runtime.py tracing, oracle, autotuner, config cache
tests/ 176 tests, both frameworks, one suite
examples/ vector add -> softmax -> layernorm -> matmul -> attention
benchmarks/bench.py newt vs triton-windows vs torch
| term | meaning |
|---|---|
| kernel | a function that runs on the GPU across many parallel workers |
| thread / warp / block / grid | one worker / 32 lockstep workers / a cooperating group with shared memory / all blocks in one launch |
| SM | streaming multiprocessor: the GPU's core cluster; runs whole thread blocks |
| DRAM / HBM | the GPU's large, slow main memory |
| shared memory (smem) | small fast per-block scratchpad, organized in 32 banks |
| coalescing | adjacent threads touching adjacent memory, so reads combine into wide transactions |
| bank conflict / swizzle | threads colliding on one smem bank / the XOR index permutation that prevents it |
| tensor core | dedicated matrix-multiply hardware inside each SM |
| WMMA / mma.sync / ldmatrix | NVIDIA's high-level tensor-core API / the raw PTX instruction / the cooperative fragment loader |
| cp.async | background copy from global to shared memory, bypassing registers |
| PTX / SASS / cubin | portable GPU assembly / real machine code / the compiled binary container |
| NVRTC | NVIDIA's C++ compiler, usable as an in-process library |
| AST / JIT / constexpr / DSL | parsed code structure / compile-on-first-use / compile-time constant / a small embedded language |
| autotuning | automatically searching configuration knobs, keeping the fastest correct one |
| memory-bound / compute-bound | limited by bandwidth / by arithmetic throughput (the roofline model) |