sgl-project/sglang-torchtpu
A PyTorch-native SGLang plugin for self-hosted LLM inference on Google TPUs
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & 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.
tpu_oot activates the TPU platform and tpu_oot_hooks registers runtime hooks for the paired SGLang build.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.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.
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.
Quick Start & Installation
docker pull lmsysorg/sglang:v0.1.0-tpuComparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| sglang-torchtpu ★ | 98 | +9 | Python | Apache-2.0 | A PyTorch-native SGLang plugin for self-hosted LLM inference on Google TPUs |
| OmniRoute | 92.1k | +1.5k | TypeScript | MIT | Self-hosted OpenAI-compatible gateway for multi-provider routing and fallback |
| freellmapi | 62k | +2.6k | TypeScript | MIT | Self-hosted LLM gateway for routing across free tiers and custom endpoints |
| bifrost | 10.2k | +125 | Go | Apache-2.0 | Self-hosted Go gateway for routing and governing multi-provider LLM traffic |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/sgl-project/sglang-torchtpu.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about sglang-torchtpu
How does the TPU plugin attach to SGLang, and can I use stock SGLang?
sglang-tpu plugin from the same release, then set SGLANG_PLATFORM=tpu_oot. The plugin registers platform activation and runtime hooks through separate SGLang entry-point groups. Do not substitute the stock PyPI sglang package for the paired engine wheel.What TPU capacity and memory should I budget for?
Can we self-host it commercially and redistribute our deployment image?
When should I choose it over SGL-JAX or the OpenAI API?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy