Inside the inference engine we're building
This paper lays out the design of the LLM inference engine GIKSN will build in Rust: how the code will be split into crates, what happens to a request from the moment it arrives to its last streamed token, how memory and scheduling will work, and how each layer will be verified before the next one is built on top of it. Nothing described here exists yet. The point of publishing the design first is so that it can be argued with before it is written.
An inference engine has one job: take a trained model and serve as many requests as possible, as fast as possible, on hardware that is always too small. Systems like vLLM and SGLang do this extremely well. Ours will be smaller, written in Rust from the kernels up, and built one testable layer at a time.
The first target is a single consumer GPU with 8 GB of memory. That constraint is deliberate. On a large datacenter GPU, a naive design can hide behind spare memory. On 8 GB, every byte of KV cache and every wasted copy shows up immediately.
How the code will be organised
The engine will be one Cargo workspace with a crate per concern, so that the boundaries in the design are boundaries the compiler enforces.
| Crate | Responsibility |
|---|---|
model | Reading model configs, loading safetensors weights, the tokenizer and chat template, and a plain CPU reference implementation of the forward pass |
kernels | GPU kernels: CUDA C++ sources compiled at build time, and their Rust-native ports |
gpu | Device and stream management, memory allocation and safe launch wrappers |
engine | The KV cache, the scheduler, sequences and the request lifecycle |
server | The HTTP API, streaming, metrics and health checks |
router | Later: spreading load across several engine replicas |
bench | The memory calculator, load generator and benchmark runner |
The CPU reference in model is the most important piece and the least glamorous. Every GPU kernel will be tested against it.