# Repository Briefing: sgl-project/mini-sglang
> Source: https://repoforai.com/repo/sgl-project/mini-sglang (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/sgl-project/mini-sglang
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: B (55/100 · Maintenance 6/35 · Adoption 23/25 · Releases 6/20 · License 20/20)
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: Docker, Self-Hosted, Local AI, CLI, GPU, API
- **Momentum**: 5,706 ★ total (+2 24h / +47 7d) · 1,018 forks
- **When to Use**: Best for: CUDA-equipped teams studying serving internals, testing scheduling and KV-cache changes, or prototyping a self-hosted API with Qwen or Llama models. Skip if: You need native macOS or Windows support, have no NVIDIA CUDA environment, or require a managed or production-ready service without owning compatibility and load testing.

## Overview
```text
### Architecture & Core Mechanics
Mini-SGLang is a compact SGLang implementation of roughly 5,000 lines of Python. The `python -m minisgl` entrypoint supports both an OpenAI-compatible API server and a terminal chat shell. The execution design combines prefix KV lookup and reuse through Radix Cache, chunked prompt prefill, and overlap between CPU scheduling and GPU work. Tensor parallelism distributes model execution across GPUs when enabled.

The `minisgl` package depends on PyTorch `<2.10.0` and Transformers `>=4.56.0,<=4.57.3`, and integrates FlashAttention and FlashInfer. The Python layer makes the scheduling and caching logic easier to inspect, but GPU execution still depends on native CUDA kernels. The OpenAI-compatible API is the client integration boundary; compatibility should be tested against the calls an application actually makes.

### Key Capabilities & Differentiators
The examples cover Qwen3-0.6B on one GPU and Llama-3.1-70B-Instruct with `--tp 4`. Radix Cache targets traffic with repeated prefixes, while chunked prefill lowers peak memory pressure from processing long prompts without removing the need to hold active KV state. The interactive shell supports `/reset`, and `--model-source modelscope` provides an alternate download path when Hugging Face is hard to reach.

The offline benchmark runs 256 sequences on one H200 with Qwen3-0.6B and Qwen3-14B, sampling input and output lengths between 100 and 1,024 tokens. The online benchmark replays the first 1,000 Qwen trace requests against Qwen3-32B on four NVLink-connected H200s. That comparison uses `--cache naive` for Mini-SGLang and `--disable-radix` for SGLang, so it is not a test of the benefit of radix prefix reuse. The configurations establish test scope, not performance on other hardware or traffic.

### Trade-offs & Limitations
Mini-SGLang is a better fit than full SGLang when the goal is to trace or modify scheduling, prefill, and cache code. It is not a drop-in substitute just because both expose similar serving concepts. Evaluate full SGLang when broader serving functionality matters, and verify API coverage and behavior under load before selecting either engine. The benchmark configurations are useful starting points, but they do not establish production readiness or a general throughput or latency advantage.

Compared with the OpenAI API, self-hosting gives you control over model selection and where inference runs, but shifts GPU capacity planning, driver compatibility, and service operations to your team. VRAM depends on weights and active KV state, so size against realistic context lengths and concurrency. Tensor parallelism adds inter-GPU communication, making topology relevant. The engine is MIT-licensed; model weights and third-party dependencies have separate terms.

### Hardware & Deployment Guide
Use Linux on x86_64 or aarch64 with an NVIDIA GPU, Python 3.10 or newer, and a CUDA Toolkit compatible with the NVIDIA driver for JIT-compiled kernels. Source installation uses `uv pip install -e .` inside a virtual environment; `python -m minisgl --model Qwen/Qwen3-0.6B` starts the server, and `--shell` switches to local terminal interaction. Windows users can use WSL2 with CUDA GPU support; native Windows and macOS are not supported.

The Dockerfile defaults to CUDA 12.8.1, Ubuntu 24.04, and Python 3.12. Build with `docker build -t minisgl .`, run with NVIDIA Container Toolkit and `--gpus all`, and publish `1919:1919` for the example that binds to `0.0.0.0`. Mount `/app/.cache/huggingface`, `/app/.cache/tvm-ffi`, and `/app/.cache/flashinfer` to retain caches between runs. Package metadata marks version 0.1.0 as alpha, with no published GitHub release listed; pin a tested commit and record the working driver and dependency versions.
```

## Key Capabilities
```text
- Implementation: The `minisgl` CLI exposes OpenAI-compatible serving and interactive `--shell` mode.
- Prefix reuse: Radix Cache shares KV state across requests with common prefixes; `--cache naive` provides a comparison configuration.
- Execution: Chunked prefill limits peak prefill memory pressure, and overlap scheduling runs CPU scheduling alongside GPU computation.
- GPU scaling: `--tp` selects tensor parallelism across GPUs, with FlashAttention and FlashInfer integrated as optimized kernels.
- Benchmarking: Offline and online scripts are separate; `MINISGL_DISABLE_OVERLAP_SCHEDULING=1` supports an offline scheduling ablation.
- Container deployment: The Docker build defaults to CUDA 12.8.1, Ubuntu 24.04, and Python 3.12, with separate cache mounts for Hugging Face, TVM FFI, and FlashInfer.
```

## Quick Start / Clone
```bash
# Create a virtual environment (Python 3.10+ recommended)
uv venv --python=3.12
source .venv/bin/activate
```
