JAX backend for SGL
Project description
SGL-JAX: High-Performance LLM Inference on JAX/TPU
SGL-JAX is a high-performance, JAX-based inference engine for Large Language Models (LLMs), specifically optimized for Google TPUs. It is engineered from the ground up to deliver exceptional throughput and low latency for the most demanding LLM serving workloads.
The engine incorporates state-of-the-art techniques to maximize hardware utilization and serving efficiency, making it ideal for deploying large-scale models in production on TPUs.
Key Features
- High-Throughput Continuous Batching: Implements a sophisticated scheduler that dynamically batches incoming requests, maximizing TPU utilization and overall throughput.
- Optimized KV Cache with Radix Tree: Utilizes a Radix Tree for KV cache management (conceptually similar to PagedAttention), enabling memory-efficient prefix sharing between requests and significantly reducing computation for prompts with common prefixes.
- FlashAttention Integration: Leverages a high-performance FlashAttention kernel for faster and more memory-efficient attention calculations, crucial for long sequences.
- Tensor Parallelism: Natively supports tensor parallelism to distribute large models across multiple TPU devices, enabling inference for models that exceed the memory of a single accelerator.
- OpenAI-Compatible API: Provides a drop-in replacement for the OpenAI API, allowing for seamless integration with a wide range of existing clients, SDKs, and tools (e.g., LangChain, LlamaIndex).
- Native Qwen Support: Includes first-class, optimized support for the Qwen model family, including recent Mixture-of-Experts (MoE) variants.
Architecture Overview
SGL-JAX operates on a distributed architecture designed for scalability and performance:
- HTTP Server: The entry point for all requests, compatible with the OpenAI API standard.
- TokenizerManager: Runs in the main process, handles text tokenization
- Scheduler: The core of the engine. It receives requests, manages prompts, and schedules token generation in batches. It intelligently groups requests to form optimal batches for the model executor.
- TP Worker (Tensor Parallel Worker): A set of distributed workers that host the model weights, distributed via tensor parallelism. They execute the forward pass for the model.
- Model Runner(Included in TP Worker): Manages the actual JAX-based model execution, including the forward pass, attention computation, and KV cache operations.
- DetokenizerManager: Runs in a subprocess, handles output token decoding
More details in architecture.
Getting Started
Documentation
For more features and usage details, please read the documents in the docs directory.
Supported Models
SGL-JAX is designed for easy extension to new model architectures. It currently provides first-class support for:
- Qwen
- Qwen 2 / Qwen 2 MoE
- Qwen 3 / Qwen 3 MoE
- Llama
- Gemma 2
- DeepSeek V2 / V3
- GLM-4 MoE
- Grok-2
- Bailing MoE / Bailing MoE V2
- MiMo-7B
- MiMo-V2-Flash
- MiMo-V2.5-Pro
SGL-JAX also supports multimodal models with the same usage interface as LLMs. The architecture has been adapted to support flexible multimodal model architectures.
- Wan 2.1 T2V: Text-to-Video generation model.
- Wan 2.2 T2V: Text-to-Video generation model. Uses different DiT models at different noise stages for denoising.
- Qwen2.5-VL: Vision-language model series based on Qwen2.5.
For multimodal model usage, see the Usage Guide and Architecture Design.
Performance and Benchmarking
For detailed performance evaluation and to run the benchmarks yourself, please see the scripts located in the benchmark/ and python/sgl_jax/ directories (e.g., bench_serving.py).
Testing
The project includes a comprehensive test suite to ensure correctness and stability. To run the full suite of tests:
python test/srt/run_suite.py
Contributing
Contributions are welcome! If you would like to contribute, please feel free to open an issue to discuss your ideas or submit a pull request.
Before contributing, please read our Contribution Guide for setup instructions, coding standards, and contribution workflow.
You can also join our community on Slack to discuss ideas, get help, or collaborate with other contributors: 👉 Join the SGLang Slack workspace (https://slack.sglang.io/), then participate in discussions in the SGL-JAX Slack Channel.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sglang_jax-0.0.3rc0.tar.gz.
File metadata
- Download URL: sglang_jax-0.0.3rc0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d7ad75e7eae705a1986a4986b076e3861f6387229934b92bfbccb41a9adfce9
|
|
| MD5 |
305a82b32def77ec37effa04c6512ff5
|
|
| BLAKE2b-256 |
372c412ca457ffc43a9199676188a07a123a512e5c784301565d052d8ba9e972
|
File details
Details for the file sglang_jax-0.0.3rc0-py3-none-any.whl.
File metadata
- Download URL: sglang_jax-0.0.3rc0-py3-none-any.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd54127d0152e32542497f9d51c5343bc027177593dbfb9167add37a193856fe
|
|
| MD5 |
9a2f04792037cbbf4343bad37445daee
|
|
| BLAKE2b-256 |
fa7ff6165e74846bed37ff5f00a0fa3fc53299b876f571164d282f66063dd3d0
|