SGLang router is a standalone module implemented in Rust to achieve data parallelism across SGLang instances.
Please check https://docs.sglang.ai/router/router.html
- Rust and Cargo installed
# Install rustup (Rust installer and version manager)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Follow the installation prompts, then reload your shell
source $HOME/.cargo/env
# Verify installation
rustc --version
cargo --version
- Python with pip installed
$ cargo build
- Build the wheel package:
$ pip install setuptools-rust wheel build
$ python -m build
- Install the generated wheel:
$ pip install <path-to-wheel>
If you want one handy command to do build + install for every change you make:
$ python -m build && pip install --force-reinstall dist/*.whl
For development purposes, you can install the package in editable mode:
Warning: Using editable python binding can suffer from performance degradation!! Please build a fresh wheel for every update if you want to test performance.
$ pip install -e .
Note: When modifying Rust code, you must rebuild the wheel for changes to take effect.
- If rust analyzer is not working in VSCode, set
rust-analyzer.linkedProjects
to the absolute path ofCargo.toml
in your repo. For example:
{
"rust-analyzer.linkedProjects": ["/workspaces/sglang/sgl-router/Cargo.toml"]
}
The continuous integration pipeline consists of three main steps:
- Uses
cibuildwheel
to create manylinux x86_64 packages - Compatible with major Linux distributions (Ubuntu, CentOS, etc.)
- Additional configurations can be added to support other OS/architectures
- Reference: cibuildwheel documentation
- Creates a source distribution containing the raw, unbuilt code
- Enables
pip
to build the package from source when prebuilt wheels are unavailable
- Uploads both wheels and source distribution to PyPI
The CI configuration is based on the tiktoken workflow.