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.
Get 5 new use cases every morning. Free, one short email, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Disclaimer
Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked "Seen in the wild", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email [email protected] and we will look at it promptly. Full disclaimer page