Who it is forAn engineer who wants to understand inference engine internals by writing one, usually over several weeks alongside the course.
The problemReading a production engine like SGLang first is hard without knowing which parts do what.
The outcomeA self-built mini-sglang with forward pass, KV Cache, concurrent HTTP requests, Paged KV Cache, and RadixAttention, plus an understanding of the real engine's structure.
What you need first
- Python and basic software engineering habits
- Familiarity with PyTorch and neural network basics
- Git installed to clone the repository
- A GPU for Part 0 deployment and full mini-sglang performance tests (cloud GPU is fine; Part I needs no GPU)
Steps
git clone https://github.com/datawhalechina/zero-to-sglang.gitcd zero-to-sglang- Read course-material/eng/part2/Chapter1_mini-sglang-What-an-Inference-Engine-Looks-Like.md for the architecture overview.
- Work through Chapter 3 (forward pass and generation) and Chapter 4 (KV Cache) using their concept files and Code Walkthrough files.
- Implement Chapter 5 (HTTP and concurrent requests), then Chapter 7 (Paged KV Cache) and Chapter 8 (RadixAttention), checking each step against the code walkthrough.
- Install dependencies as each chapter requires, then compare your result with the reference implementation at https://github.com/sgl-project/mini-sglang. (inferred, check the README)
Prompt for your agent
Use the repo https://github.com/datawhalechina/zero-to-sglang and implement Chapter 4 (KV Cache) of Part II in <target-directory>. Expected output: a generation loop that reuses cached keys and values for a short prompt. Verify that the output tokens match a run without the cache for the same prompt.
Caveat. Chapters 6 (Continuous Batching) and 10 (Speculative Decoding) are still planned, so the build path has gaps that you must fill yourself.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for datawhalechina/zero-to-sglang and "Build a mini inference engine step by step"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer