From 150 to 2143 tok/s: Someone Broke an LLM Inference Engine Into 10 Steps and Caught Up to 98% of vLLM
Eason Huang wrote an LLM inference engine from scratch on an RTX 3060, pushing Qwen3-0.6B from 150 tok/s to 2143 tok/s, close to vLLM and SGLang. The biggest gain came from memory management such as paged KV cache. The post includes diagrams and code for each optimization step.
According to Eason Huang's public tweets and long-form post, he wrote an LLM inference engine from scratch on a single RTX 3060 12GB, using Qwen3-0.6B in bf16. Each optimization was made as a separate git commit, ultimately pushing max throughput from 150 tok/s to 2143 tok/s, reaching about 98% of vLLM. In the same comparison, vLLM was 2176 tok/s and SGLang was 2187 tok/s.
Let's fill in the background first. What an LLM inference engine does is turn model weights into an API that can serve many requests concurrently. Incoming requests must be queued, split into batches and sent to the GPU, with KV cache and GPU memory managed, while keeping metrics such as first-token latency, per-token latency, and throughput under control. vLLM and SGLang are the two most commonly compared engines in this category.
Eason's test environment is not luxurious: RTX 3060, Qwen3-0.6B, bf16. The main benchmark simulates users arriving at 1.8 req/s with a Poisson distribution, issuing 100 requests, with input 512 tokens and output 128 tokens varying by ±80%, averaging about 90 output tokens. Metrics include TTFT (time to first token), TPOT (time per output token), ITL (inter-token latency), and E2E (end-to-end time). He also notes that his engine calls directly in-process, while vLLM and SGLang go through an HTTP server, so his latency numbers have a slight advantage.
The whole project is broken into 10 steps: static batching, KV cache, continuous batching, chunked prefill, FlashAttention plus ragged tensors, paged KV cache, prefix caching, CUDA Graphs, overlapped scheduling, and torch.compile. Each step has a code tag and can be diffed separately.

A few jumps are worth calling out separately.
KV cache reduced the decode step from 83.6 ms to 11.2 ms. The reason is straightforward: in a naive loop, every time a new token is generated, the entire attention over the full sequence must be recomputed across all 28 layers. But attention is causal, and the keys and values of past tokens do not change. Compute them once, store them, and reuse them directly afterward.

Continuous batching cut median TTFT from 2241 ms to 57 ms. Static batching has to wait for the slowest request in the batch to finish, so short requests are held back by long ones. Continuous batching immediately swaps in a new request whenever any request finishes, making the queue dynamic.

FlashAttention pushed throughput from 222 tok/s to 577 tok/s. Standard softmax attention has to write the full n×n matrix to HBM, making both reads and writes expensive. FlashAttention uses tiling and online softmax to keep Q, K, and V flowing through on-chip SRAM, without materializing the full attention matrix in HBM.

Paged KV cache was the largest single-step improvement, going from 577 tok/s to 1315 tok/s. Previously, each request reserved a full 2048-token KV slot, and at most 8 requests ran concurrently. But requests often do not use the full allocation. Paged KV allocates in 16-token pages on demand, allowing the same amount of GPU memory to hold more requests. The author wrote in the tweet that the biggest jump came from memory management, not from a particular kernel.

Prefix caching addresses redundant computation for shared system prompts and multi-turn conversations. A token's KV depends only on the tokens before it, so shared prefixes have identical KV. The author uses a vLLM-style hash chain for block-level matching and reference counting to manage shared blocks. Under a shared-prefix workload, TTFT p50 dropped from 47 ms to 17.8 ms.

CUDA Graphs address CPU launch overhead. Once the GPU computes quickly, the CPU's time to prepare and launch kernels becomes the bottleneck. Record the decode step into a graph, then replay it directly. In the blog, TPOT p50 dropped from 9.6 ms to 6.7 ms. Overlapped scheduling then lets the CPU run the next step ahead of time, bringing TPOT p50 to 6.1 ms, but TTFT gets worse.


torch.compile is the last major improvement. It fuses multiple small kernels, reducing HBM round trips. Combined with tuning, such as raising token_budget from 512 to 2048, it pushed max TPS from 1451 to 2143.

There is an easily overlooked judgment here: throughput and latency are not the same kind of problem. Most of TPOT comes from kernels and engine implementation, while TTFT and ITL are more determined by scheduling policy. Eason writes in the conclusion that the concepts themselves are not complicated; what is hard is how the server behaves under load. It is very easy to make a policy with beautiful averages and an ugly tail caused by starvation.
There is also a small addition in the comments. A commenter pointed out that vLLM v1 also supports CUDA graphs for prefill and mixed batches, and SGLang can use --enable-mixed-chunk to schedule prefill and decode in the same batch. Eason replied that he would correct the footnote. Such details are important for reproduction.
The code and long-form post are here:
- Long-form post: https://easonhuang.dev/blog/llm_inference_engine
- Code: https://github.com/GuyOnWifi/scheduler
From 150 to 2143 tok/s, a roughly 14x improvement was broken into commits that can be diffed step by step. For people who want to understand where an inference engine actually gets its speed, this is more useful than just looking at the final benchmark.
发布时间: 2026-12-02 12:26