datawhalechina/zero-to-sglang

Public

Official SGLang x Datawhale course on LLM inference: understand inference, build a mini-sglang from scratch, then read the real SGLang source and land your first PR. Available in English and Chinese.

  • Stars1.7k+80 tuần này
  • Forks134
  • Watchers9
  • Issues5
  • Ngày tạo27/08/2026
  • Cập nhật gần nhất01/11/2026
  • Ngôn ngữPython
  • Giấy phép—
README.md27.1 KBRaw
zero-to-sglang banner

zero-to-sglang

English 简体中文

📚 Build SGLang from Scratch

A hands-on tutorial on LLM inference: build a mini-sglang from scratch, then read the real SGLang source.

GitHub stars GitHub forks Language GitHub Project Online Reading

Start from what inference really is, build a mini-sglang by hand, then read the real SGLang source

Datawhale × RadixArk


Course status: Part 0, Part I, and Chapters 1–2 of Part II are complete in both English and Chinese. The remaining chapters of Part II and Parts III–IV are under development. You can switch to 简体中文 at any time. Want to help? See Contributing.

🎯 About

  Large models have moved on from the training race to the inference race. Once applications took off, inference cost and latency became the real bottleneck: on the same GPU, a good inference engine can serve several times more requests. Yet there are few tutorials on inference engines. They either stay at the concept level without touching code, or drop you straight into the SGLang source with no idea where to start.

  This course fills that gap. The first half starts from the core questions of inference: why KV Cache exists, how prefill differs from decode, what compute-bound and memory-bound actually mean. The middle part walks you through building a mini-sglang from scratch: forward pass, generation, KV Cache, HTTP serving, Continuous Batching, Paged KV Cache, RadixAttention, added one at a time. The last part returns to the real SGLang, explains how its cutting-edge optimizations are actually implemented, and finally shows you how to land your first solid PR in SGLang.

  The project is jointly launched by Datawhale and RadixArk (the company founded by the SGLang team). SGLang is technically solid and actively iterated in the inference framework space. If you like this project, please give the official SGLang repository a ⭐.

✨ What you will learn

  • 📖 Understand inference: KV Cache, prefill/decode, compute-bound vs. memory-bound, and what these concepts actually mean
  • 🏗️ Build the engine

Nội dung README thuộc về datawhalechina và cộng đồng đóng góp, giấy phép Không có giấy phép. Nguồn: github.com/datawhalechina/zero-to-sglang