An interactive, single-file HTML tutorial that explains how SGLang works under the hood -- from first principles to implementation details.
12 chapters covering the full SGLang serving stack:
| # | Chapter | Key Concepts |
|---|---|---|
| 1 | The Big Picture | 3-process architecture, ZMQ pipeline |
| 2 | Tokenization & Lifecycle | Req data structure, 3 input paths |
| 3 | KV Cache & Memory | ReqToTokenPool, TokenToKVPoolAllocator |
| 4 | RadixAttention | Prefix caching, radix tree, LRU eviction |
| 5 | Scheduling | LPM policy, PrefillAdder budgets |
| 6 | Continuous Batching | Chunked prefill, TTFB control |
| 7 | Forward Pass | CUDA graph replay, ForwardMode dispatch |
| 8 | Attention Backends | AttentionBackend ABC, FlashInfer/Triton |
| 9 | Sampling | Temperature, top-k/top-p/min-p pipeline |
| 10 | Constrained Decoding | FSM masking, XGrammar, jump-forward |
| 11 | Parallelism | TP (AllReduce), DP (replicas), hybrid |
| 12 | Speculative Decoding | Draft-verify loop, EAGLE, bonus tokens |
Each chapter includes:
- Real source code snippets from the SGLang codebase with file paths
- Step-by-step "How It Works" explanations with pseudocode
- Interactive demos (memory grid, radix tree visualizer, sampling explorer, speculative decoding simulator)
- Single self-contained HTML file -- no build step, no dependencies
- Warm parchment design inspired by Claude (Anthropic)
- Sidebar navigation with progress tracking
- Mobile responsive
- 5 interactive JavaScript demos
- 15+ annotated source code blocks from the real SGLang codebase
# Clone and open
git clone https://github.com/odysa/mini-sglang.git
open mini-sglang/tutorial.html
# Or just download tutorial.html and double-click itThis tutorial was generated using a Claude Code skill that automates multi-phase codebase investigation, chapter writing, and interactive HTML generation. The skill is available at skill.md.
MIT