DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to build a mini inference engine step by step with Zero to SGLang

Follow Part II to add forward pass, KV Cache, HTTP serving, paging, and RadixAttention to a mini-sglang.

Short answer: git clone https://github.com/datawhalechina/zero-to-sglang.git; then cd zero-to-sglang; read course-material/eng/part2/Chapter1_mini-sglang-What-an-Inference-Engine-Looks-Like.md for the architecture overview. All steps.

  • Research
  • Advanced
  • 8 hours
  • From the README
  • Any agent

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

  1. git clone https://github.com/datawhalechina/zero-to-sglang.git
  2. cd zero-to-sglang
  3. Read course-material/eng/part2/Chapter1_mini-sglang-What-an-Inference-Engine-Looks-Like.md for the architecture overview.
  4. Work through Chapter 3 (forward pass and generation) and Chapter 4 (KV Cache) using their concept files and Code Walkthrough files.
  5. Implement Chapter 5 (HTTP and concurrent requests), then Chapter 7 (Paged KV Cache) and Chapter 8 (RadixAttention), checking each step against the code walkthrough.
  6. 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

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer