Sankur Kundu

kiln · an ML compiler, end to end

fire the graph.

The pipeline of XLA, TVM and torch.compile, from scratch: decode ONNX, fold and canonicalize the graph, fuse it into a few kernels over an affine loop IR, generate SIMD C or CUDA, compile it at run time and auto-tune every matrix multiply on the machine it runs on. On 4 CPU cores it is the fastest of five engines.

ONNXdecode
Graphfold · fuse
Loopsaffine IR
CodeSIMD C · CUDA
Tuneon device
117 msBERT on 4 CPU cores, 8 × 128 tokens: torch.compile 149, ONNX Runtime 153, JAX/XLA 189, PyTorch 198
7.9 msSmolLM2-135M on a T4 with fp16 tensor cores: 1.65× faster than torch.compile (13.1 ms)
3.7×Faster than torch.compile on the MLP on the T4 (0.30 vs 1.10 ms); auto-tuning worth up to 1.70×
16 MBArena holding BERT's 381 MB of intermediates, planned at compile time
01 · On the CPU

Fastest of five engines

BERT, 8 sequences of 128 tokens, 4 CPU cores; medians of every timing. Outputs match PyTorch's.

Lower is better. kiln has the lowest median latency on all three of its CPU benchmark models (bench/run.sh).

02 · On the GPU

CUDA it writes for itself

The GPU backend generates CUDA with fp16 tensor-core matmuls, split-K and CUDA graphs, compiles it with NVRTC at run time and tunes it on the device.

SmolLM2-135M · 1.65×

7.9 ms against torch.compile's 13.1 ms on an NVIDIA T4 in fp16.

MLP · 3.7×

0.30 ms against 1.10 ms; auto-tuning alone is worth up to 1.70×.

BERT · behind

On BERT in fp16 kiln trails torch.compile, and in fp32 the cuBLAS-based engines stay ahead. Stated, not hidden.

03 · Correctness

Checked under every schedule

CI checks the generated C and CUDA against PyTorch with each optimisation switched off and under every tuned schedule, on an emulator of the CUDA execution model, so a fast wrong kernel cannot ship.

Outputs match PyTorch

On BERT and SmolLM2, end to end.

Every schedule tested

Each auto-tuned variant is run against the reference, not just the winner.

One arena

A memory planner packs every intermediate into one buffer: 381 MB of BERT intermediates in 16 MB.

What kiln adds

A whole compiler stack, measured honestly

Every stage of a production ML compiler, built from scratch and benchmarked against the engines people actually use.

  1. Graph to loops to code

    ONNX decoding, constant folding, fusion over an affine loop IR, SIMD C and CUDA generation.

  2. Auto-tuning on the device

    Every matmul tuned where it runs; worth up to 1.70×.

  3. Beats torch.compile on CPU

    117 ms vs 149 ms on BERT, fastest of five engines.

  4. Verified, not just fast

    Generated code checked against PyTorch under every tuned schedule in CI.

Where it falls short

On an NVIDIA T4 in fp16 kiln trails torch.compile on BERT, and in fp32 the cuBLAS-based engines stay ahead of it.

@software{kundu2026kiln,
  author  = {Kundu, Sankur},
  title   = {kiln: an ML compiler from ONNX to fused, auto-tuned SIMD C and CUDA},
  year    = {2026},
  url     = {https://github.com/Shakhtar-Sankur/kiln},
  license = {Apache-2.0}
}
Sankur Kundu

Sankur Kundu

ML systems engineer & independent researcher · Bhubaneswar, India · sankur.kundu.tw@gmail.com

Builds the systems that train and serve language models. Also the author of lipi, a tokenizer that needs fewer tokens than GPT-4o's and Gemini's in 23 of 24 Indian languages; Babelguard, an open early-warning system for scams across languages; ratchet, RL post-training from scratch; kessler, an independent space-traffic audit that runs every day. Fixes merged into Apple's MLX, Meta's ExecuTorch, Hugging Face's OpenEnv and Oxford's PyZX, and pull requests in review at Google's JAX, NVIDIA, MIT, Carnegie Mellon and ETH Zurich.