Show HN: Tiny-vLLM – high performance LLM inference engine in C++ and CUDA
TL;DR Highlight
Build a mini vLLM in C++/CUDA from scratch and learn inference internals through a course
Who Should Read
A backend developer who only uses LLM APIs and wants to understand how KV cache, batching, and PagedAttention actually work
Core Mechanics
- Course and source live in one repo
- It includes the full inference server source and a course that walks you through building it.
- The author says lecturers are welcome to use it as teaching material.
- It runs Llama 3.2 1B Instruct end to end
- It loads the model from Safetensors, the weight file format.
- The full forward pass, prefill and decode, is implemented with CUDA kernels.
- Scope follows vLLM's core ideas
- It covers KV cache, static batching, and continuous batching.
- It also covers online softmax, FlashAttention-like attention, and PagedAttention.
- An LLM is a weights file plus a blueprint
- The weights file is not executable and the architecture is only a plan.
- An inference server is the program that turns both into running code.
- Training is out of scope
- It only covers running a trained model fast on NVIDIA GPUs for parallel requests.
- For training, the author recommends nanoGPT and llm.c.
- AMD GPUs also build
- Pass -DUSE_HIP=ON to build with hipcc and hipBLAS via ROCm/HIP.
- The author tested gfx90a, gfx1100, and gfx1201.
Community Reactions
- Commenters praised the README
- Several called it one of the clearest walkthroughs of inference internals.
- One said the lesson format makes it approachable even without CUDA experience.
- KV cache section called especially useful
- One commenter said most OOM and throughput issues trace back to KV cache.
- They said it helps explain how sequence length and batch size fill the cache under real traffic.
- Comparison to early llama.cpp
- One commenter said it reminds them of the first llama.cpp but is better documented.
- Missing CUDA error checks pointed out
- One commenter noted that CUDA API return values are not checked.
- They joked the author may consider that not 'tiny' enough.
How to Apply
- Read the README's KV cache section first
- Spend 30 minutes today on 'Why KV cache exists' and 'Prefill vs decode'.
- Note how they relate to slow long contexts or OOM in your service.
- Open a Safetensors header yourself
- Read the first 8 bytes of your model.safetensors for the header size, then print the JSON header.
- Check dtype and shape to see the model structure.
- Build and run the repo with ./test.sh
- Clone it on a machine with an NVIDIA GPU and CUDA Toolkit.
- If paths fail, fix NVCC in CMakeLists.txt and the CUDA path in .vscode.
- Read the batching section and audit your serving config
- Learn static vs continuous batching and check batching settings on your self-hosted server.
- If you use vLLM, read the PagedAttention section to understand its memory settings.
Try It
# Paste into Claude or ChatGPT as is (simplified version of the repo's ideas: for learning)
I'm a backend developer who uses LLM APIs. I'm not an ML major.
Based on the service conditions below, explain how much memory the KV cache uses and why OOM or low throughput happens.
- Model: {{model name}} (tell me layers, KV heads, head dim if I don't know them)
- Precision: {{bf16 etc.}}
- Average context length: {{tokens}}
- Concurrent requests: {{count}}
- GPU memory: {{GB}}
Requests:
1. Show the KV cache memory formula step by step.
2. Compute a rough value for the conditions above.
3. Explain with analogies how static batching, continuous batching, and PagedAttention each reduce the problem.Terminology
Related Papers
A Beginner's Guide to Local AI with Inkling, Qwen, and Unsloth
Install Unsloth Desktop, load a quantized Qwen model, and share a private ChatGPT-like AI on your home LAN.
Muru – AI-assisted Rust server for Python apps by mod_WSGI's creator
mod_wsgi's creator is building Muru, an AI-assisted Rust ASGI/WSGI server, documenting it in public
87% of the Anthropic power will come from gas and 11% from coal in 2028
Analysis of Anthropic's contracted data centers: 87% gas, 11% coal power in 2028
Anthropic’s Nasdaq debut
Anthropic listed on Nasdaq and closed its first day below its opening price.
OpenAI still has a WebRTC Problem
WebRTC drops late audio, hurting voice AI; MoQ retransmits and buffers instead
Gemini 4 Neon
Gemini 4 Neon cuts cost per task 32% versus Carbon, at $3 input and $15 output per million tokens
AI is killing All About Berlin
After Google AI Overviews, a Berlin guide site lost 70-75% of its traffic.
Not Everything Needs an LLM
PostHog used small decision models to skip 98.7% of expensive LLM calls