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

- **GitHub URL**: https://github.com/sgl-project/sglang-torchtpu
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A+ (89/100 · Maintenance 35/35 · Adoption 17/25 · Releases 17/20 · License 20/20)
- **Latest Release**: tpu-v0.1.0 (2026-10-19) — https://github.com/sgl-project/sglang-torchtpu/releases
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: Docker, Self-Hosted, API
- **Momentum**: 98 ★ total (+0 24h / +9 7d) · 69 forks
- **When to Use**: Best for: Teams with TPU7x capacity and PyTorch expertise that want to self-host a supported language or vision-language model behind an OpenAI-compatible endpoint, starting with a validated serving recipe. Skip if: You lack TPU7x access, need a backend for an existing GPU fleet, or want a managed API without owning model serving, compilation warmup, or multi-host operations.

## Overview
```text
### Architecture & Core Mechanics
SGLang-TorchTPU pairs the SGLang engine in `python/` with `sglang-tpu`, an out-of-tree plugin backed by `torch_tpu`. Applications enter through the SGLang serving API, including `/v1/chat/completions`; the TPU backend handles execution on the accelerator through PyTorch, with `torch.compile` and direct compilation available. TPU kernels, memory management, and backend integrations live in `sglang_tpu/`.

The plugin declares a dependency on `sglang` and registers `tpu_oot = sglang_tpu:activate` in `sglang.srt.platforms` and `tpu_oot_hooks = sglang_tpu.hooks:register` in `sglang.srt.plugins`. That separates TPU-specific code from the serving engine, but it does not make the plugin interchangeable with arbitrary SGLang builds: the release requires the engine and plugin wheels to be installed together.

### Key Capabilities & Differentiators
TPU7x (Ironwood) is the development and testing focus: one host provides four chips and eight TensorCores, with TP up to 8; the two-host configuration reaches TP16. A four-host topology separates prefill and decode into two hosts each, with TP resharding. The backend supports tensor, expert, data, pipeline, and context parallelism, plus prefix caching and HiCache offload to host memory.

Low-precision options include FP8, MXFP4, INT4 W4A16, and FP8 KV cache. EAGLE3, DFlash, DFlash2, DSPark, and MTP are available for supported model configurations. Integration depth varies: GPT-OSS 20B/120B have serving recipes and Qwen3.8-27B has accuracy and MTP recipes, whereas Kimi-K3 is represented by a small-model compile test with dummy weights. For vision-language serving, the encoder can run on a separate host or chip allocation. In one 235B-A22B comparison at 5 requests/s, time to first token was 392 ms with a separate encoder versus 2,091 ms with the encoder on the same host; this is a topology-specific result, not a general latency target.

### Trade-offs & Limitations
Compared with SGL-JAX, this is the SGLang TPU path for teams that want PyTorch rather than JAX. Its plugin structure keeps TPU code separate, but the release still depends on the forked engine. Treat the engine and plugin as one upgrade unit, and check model and topology coverage in `SUPPORT.md` and `SUPPORT_MATRIX.md`. Compared with the managed OpenAI API, self-hosting gives you control over model selection and placement, while leaving capacity planning, warmup, and availability to your team. A compatible chat endpoint does not imply full API parity.

Use a single-host recipe as the baseline before paying for more hosts. Splitting the vision encoder can reduce contention and language-server HBM use, but it adds a service to operate. TPU encoder-only mode requires `--enable-torch-compile`, encoder data parallelism is not supported on TPU, and a language-only server returns HTTP 503 for image requests without a registered encoder. Size HBM and host memory against your actual model, precision, context lengths, and concurrency rather than extrapolating from one benchmark.

### Hardware & Deployment Guide
The `tpu-v0.1.0` release tracks SGLang 0.5.22. The shortest self-hosting path is `lmsysorg/sglang:v0.1.0-tpu` on a TPU7x host. The documented Docker launch uses `--privileged`, `--net=host`, `--shm-size=64g`, and `SGLANG_PLATFORM=tpu_oot`. Review the broad privileges and host-network exposure before deployment; 64 GB is the example's shared-memory setting, not a universal capacity requirement.

For a wheel install, use Linux x86_64 with Python 3.11–3.14 and install both release wheels together, using the PyTorch CPU wheel index as an extra index. A source install instead uses `python/pyproject_tpu.toml` for the engine before installing the root plugin. Clone the repository to run the GPT-OSS-20B recipe via `benchmark.tpu.launch_server`, then verify the local OpenAI-compatible endpoint on port 30000. CPU-only unit tests are available, but kernel and end-to-end validation require TPU hardware.
```

## Key Capabilities
```text
- Plugin boundary: `tpu_oot` activates the TPU platform and `tpu_oot_hooks` registers runtime hooks for the paired SGLang build.
- Topology: TPU7x configurations include single-host TP8, two-host TP16, and a four-host split with two prefill and two decode hosts.
- KV management: Prefix caching reuses common prompt state, while HiCache can offload KV data to host memory.
- Precision: FP8, MXFP4, INT4 W4A16, and FP8 KV cache are available for applicable configurations.
- Multimodal serving: The vision encoder can use a separate host or chip allocation and its own TP size; TPU encoder data parallelism is not supported.
- Deployment: `tpu-v0.1.0` pairs the SGLang 0.5.22 engine build with the TPU plugin and offers both a Docker image and matching wheels.
```

## Quick Start / Clone
```bash
docker pull lmsysorg/sglang:v0.1.0-tpu
```
