A single-GPU LLM inference engine in Julia, built to learn how inference engines work on the inside and to try out tile-centric GPU programming with cuTile.jl. The hot kernels are cuTile kernels: GEMV/GEMM, paged flash-attention, fused norms and RoPE, and device sampling. Everything around them is plain Julia: safetensors loading, a byte-level BPE tokenizer, a paged KV cache, CUDA graphs and speculative decoding (n-gram, draft model, DFlash), an engine for several requests at once (continuous batching and a radix-tree prefix cache with a host-memory tier), and an OpenAI-compatible HTTP server in front of it.
The code aims to be easy to read and to measure: each kernel has a reference implementation it is tested against, a benchmark, and an entry in the performance page saying what it gained.
Learn more by reading my blog post!
git clone https://github.com/AntoineBut/TileInfer.jl && cd TileInfer.jl
julia --project -e 'using Pkg; Pkg.instantiate()'
julia --project -m TileInfer pull Qwen/Qwen3-0.6B
julia --project -m TileInfer serve Qwen/Qwen3-0.6B # http://127.0.0.1:8080, OpenAI APIcurl http://127.0.0.1:8080/v1/chat/completions -d '{
"messages": [{"role": "user", "content": "Name three primary colors."}], "stream": true}'Requires Julia 1.13 and an NVIDIA GPU that cuTile.jl supports. Qwen3-0.6B fits on any
card, Qwen3-4B needs about 9 GB, and 8B models need --int8 on a 16 GB card.
serve takes --host and --port (--host 0.0.0.0 for the local network), --int8 and
--kv-int8, and --max-batch, --max-queue and --max-context; when the queue is full,
requests are refused with a 503. Other commands: ls and rm to manage pulled models.
Models are stored in the Hugging Face hub cache, shared with Python's huggingface_hub. To
install a tileinfer executable instead of going through julia --project -m TileInfer, run
julia --project -e 'using Pkg; Pkg.Apps.develop(path = ".")'.
From Julia:
using TileInfer
using TileInfer: pull, load_model, load_tokenizer, encode, decode, generate
dir = pull("Qwen/Qwen3-0.6B")
model, tok = load_model(dir; backend = TileBackend()), load_tokenizer(dir)
decode(tok, generate(model, encode(tok, "The capital of France is"); max_new_tokens = 16))- Models: Llama 3, Mistral, Qwen3 and Apertus checkpoints from the Hugging Face hub, in BFloat16, with optional weight-only INT8 and an INT8 KV cache.
- Two backends: every op has a reference implementation (CUDA.jl broadcasts and
cuBLAS), which is the ground truth in tests, and a cuTile implementation. Float32 runs
match the Hugging Face
transformerslogits to ~1e-4. - Engine: a paged KV cache, allocation-free decode steps replayed from CUDA graphs, sampling on the device, and a host that runs one step behind the GPU.
- Serving: continuous batching of several requests, a prefix cache shared across them (the next turn of a chat runs only its new message), and an HTTP server with the routes of the OpenAI API that refuses requests when it is overloaded.
- Speculative decoding: n-gram lookup, a draft model, or a DFlash block drafter, with exact verification for both greedy and sampled decoding.
- Tooling: per-op and end-to-end benchmarks, a per-kernel breakdown of real steps, Nsight Compute profiling scripts, and codegen probes that compare equivalent cuTile kernels down to their SASS.
On an RTX 4080 SUPER (the card it is tuned on), in BFloat16, with decode measured after 1,023 cached positions:
| Qwen3-0.6B | Qwen3-4B | |
|---|---|---|
| Decode | 409 tok/s (73 % of the bandwidth roofline) | 79 tok/s (88 %) |
| Decode with INT8 weights | 542 tok/s | 139 tok/s |
| Prefill, 512-token prompt | 58k tok/s | 11.4k tok/s (91 TFLOP/s) |
| Speculative decoding (DFlash) | — | 1.8× to 3.2× on open prompts, 8.5× on a code edit |
Apertus 1.5 8B runs on the same 16 GB card with INT8 weights, at 80 tok/s.
The engine was built in milestones, each a working engine that the next one sped up: reference ops on cuBLAS (26 tok/s on Qwen3-0.6B), then cuTile kernels, paged flash-attention, CUDA graphs, and fused kernels with device sampling (409 tok/s). The performance page records what each feature gains, including the optimizations that did not pan out.
The documentation covers:
- Getting started: the command line, the HTTP API and the Julia API.
- Architecture: the layers of the engine, from the HTTP server down to the kernels, and how they map to vLLM's; with pages on the KV cache, the attention kernels and speculative decoding.
- History and roadmap: milestones so far and what comes next.
- Profiling and cuTile design choices: how kernels are measured, and the codegen rules learned along the way.
- References: papers, engines and package sources this builds on.
julia --project=test test/runtests.jl # full test suite, ~4 min
julia --project=test test/runtests.jl kernels # only matching test files
julia --project=bench bench/run.jl --model Qwen/Qwen3-0.6B # op and model benchmarks
julia --project=docs docs/make.jl # documentation site, no GPU neededTests that need a real checkpoint are skipped until Qwen/Qwen3-0.6B is pulled. Golden
outputs from the Hugging Face reference implementations live in test/fixtures/.
MIT, see LICENSE.