[model-gateway] change sgl-router to sgl-model-gateway (#14312)

This commit is contained in:
Simo Lin
2025-12-05 12:04:48 -08:00
committed by GitHub
parent 1ea6b740a7
commit 49dfa1d891
431 changed files with 86 additions and 93 deletions

4
.github/labeler.yml vendored
View File

@@ -1,10 +1,10 @@
# Configuration for the GitHub Labeler action
# Automatically adds labels to PRs based on the files changed
# Router specific (Rust code in sgl-router)
# Router specific (Rust code in sgl-model-gateway)
model-gateway:
- changed-files:
- any-glob-to-any-file: 'sgl-router/**/*'
- any-glob-to-any-file: 'sgl-model-gateway/**/*'
# Kernel specific
sgl-kernel:

View File

@@ -35,16 +35,16 @@ jobs:
- name: Check proto files are in sync
run: |
if ! diff -q python/sglang/srt/grpc/sglang_scheduler.proto sgl-router/src/proto/sglang_scheduler.proto; then
if ! diff -q python/sglang/srt/grpc/sglang_scheduler.proto sgl-model-gateway/src/proto/sglang_scheduler.proto; then
echo "❌ ERROR: Proto files are out of sync!"
echo ""
echo "The following files must be kept identical:"
echo " - python/sglang/srt/grpc/sglang_scheduler.proto"
echo " - sgl-router/src/proto/sglang_scheduler.proto"
echo " - sgl-model-gateway/src/proto/sglang_scheduler.proto"
echo ""
echo "Please ensure both files have the same content."
echo ""
echo "Differences:"
diff python/sglang/srt/grpc/sglang_scheduler.proto sgl-router/src/proto/sglang_scheduler.proto || true
diff python/sglang/srt/grpc/sglang_scheduler.proto sgl-model-gateway/src/proto/sglang_scheduler.proto || true
exit 1
fi

View File

@@ -50,9 +50,9 @@ jobs:
with:
path: sglang-repo
- name: Move sgl-router folder to root and delete sglang-repo
- name: Move sgl-model-gateway folder to root and delete sglang-repo
run: |
mv sglang-repo/sgl-router/* .
mv sglang-repo/sgl-model-gateway/* .
rm -rf sglang-repo
ls -alt
shell: bash
@@ -138,9 +138,9 @@ jobs:
with:
path: sglang-repo
- name: Move sgl-router folder to root and delete sglang-repo
- name: Move sgl-model-gateway folder to root and delete sglang-repo
run: |
mv sglang-repo/sgl-router/* .
mv sglang-repo/sgl-model-gateway/* .
rm -rf sglang-repo
ls -alt

View File

@@ -4,11 +4,11 @@ on:
push:
branches: [ main ]
paths:
- "sgl-router/**"
- "sgl-model-gateway/**"
pull_request:
branches: [ main ]
paths:
- "sgl-router/**"
- "sgl-model-gateway/**"
workflow_dispatch:
concurrency:
@@ -45,7 +45,7 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: sgl-router
workspaces: sgl-model-gateway
# Share cache across all benchmark jobs
shared-key: "rust-cache"
# Save cache even on failure
@@ -56,7 +56,7 @@ jobs:
- name: Check benchmarks compile
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
cargo check --benches
- name: Show sccache stats
@@ -92,7 +92,7 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: sgl-router
workspaces: sgl-model-gateway
# Share cache across all benchmark jobs
shared-key: "rust-cache"
cache-all-crates: true
@@ -104,7 +104,7 @@ jobs:
timeout-minutes: 30
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
# Try to use sccache, but disable if it fails
if command -v sccache &> /dev/null; then
echo "Testing sccache availability..."
@@ -130,7 +130,7 @@ jobs:
with:
name: request-processing-results-${{ github.sha }}
path: |
sgl-router/target/criterion/benchmark_summary/
sgl-model-gateway/target/criterion/benchmark_summary/
retention-days: 30
- name: Show sccache stats
@@ -164,7 +164,7 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: sgl-router
workspaces: sgl-model-gateway
# Share cache across all benchmark jobs
shared-key: "rust-cache"
cache-all-crates: true
@@ -176,7 +176,7 @@ jobs:
timeout-minutes: 30
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
# Try to use sccache, but disable if it fails
if command -v sccache &> /dev/null; then
echo "Testing sccache availability..."
@@ -201,7 +201,7 @@ jobs:
with:
name: tokenizer-results-${{ github.sha }}
path: |
sgl-router/target/criterion/tokenizer*/
sgl-model-gateway/target/criterion/tokenizer*/
retention-days: 30
benchmark-tool-parser:
@@ -231,7 +231,7 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: sgl-router
workspaces: sgl-model-gateway
# Share cache across all benchmark jobs
shared-key: "rust-cache"
cache-all-crates: true
@@ -243,7 +243,7 @@ jobs:
timeout-minutes: 30
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
# Try to use sccache, but disable if it fails
if command -v sccache &> /dev/null; then
echo "Testing sccache availability..."
@@ -268,7 +268,7 @@ jobs:
with:
name: tool-parser-results-${{ github.sha }}
path: |
sgl-router/target/criterion/tool_parser*/
sgl-model-gateway/target/criterion/tool_parser*/
retention-days: 30
- name: Show sccache stats

View File

@@ -6,14 +6,14 @@ on:
paths:
- 'python/sglang/srt/disaggregation/**'
- 'scripts/ci/ci_start_disaggregation_servers.sh'
- 'sgl-router/**'
- 'sgl-model-gateway/**'
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened, labeled]
paths:
- 'python/sglang/srt/disaggregation/**'
- 'scripts/ci/ci_start_disaggregation_servers.sh'
- 'sgl-router/**'
- 'sgl-model-gateway/**'
workflow_dispatch:
concurrency:
@@ -58,8 +58,8 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
sgl-router/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('sgl-router/Cargo.lock') }}
sgl-model-gateway/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('sgl-model-gateway/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
@@ -147,11 +147,11 @@ jobs:
python3 -m pip --no-cache-dir install mooncake-transfer-engine==0.3.7.post2
python3 -m pip --no-cache-dir install --user --force-reinstall genai-bench==0.0.2
- name: Build and install sgl-router
- name: Build and install sgl-model-gateway
run: |
source "$HOME/.cargo/env"
echo "Building sgl-router..."
cd sgl-router/bindings/python
echo "Building sgl-model-gateway..."
cd sgl-model-gateway/bindings/python
pip install maturin
maturin build --release --out dist --features vendored-openssl
pip install --force-reinstall dist/*.whl

View File

@@ -4,12 +4,12 @@ on:
push:
branches: [ main ]
paths:
- "sgl-router/**"
- "sgl-model-gateway/**"
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened, labeled]
paths:
- "sgl-router/**"
- "sgl-model-gateway/**"
workflow_dispatch:
concurrency:
@@ -32,9 +32,9 @@ jobs:
with:
path: sglang-repo
- name: Move sgl-router folder to root
- name: Move sgl-model-gateway folder to root
run: |
mv sglang-repo/sgl-router/* .
mv sglang-repo/sgl-model-gateway/* .
rm -rf sglang-repo
- name: Set up Python
@@ -96,21 +96,21 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: sgl-router
workspaces: sgl-model-gateway
cache-all-crates: true
cache-on-failure: true
- name: Run lint
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
rustup component add clippy
cargo clippy --all-targets --all-features -- -D warnings
- name: Run fmt
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt
rustup toolchain install nightly --profile minimal
cargo +nightly fmt -- --check
@@ -118,28 +118,30 @@ jobs:
- name: Generate vision golden fixtures
run: |
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
pip install transformers pillow numpy scipy
cd sgl-router/
pip install transformers pillow numpy
cd sgl-model-gateway/
python scripts/generate_vision_golden.py
- name: Run Rust tests
timeout-minutes: 20
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
cargo test
- name: Check benchmark compilation
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
cargo check --benches
- name: Quick benchmark sanity check
timeout-minutes: 15
run: |
source "$HOME/.cargo/env"
cd sgl-router/
cd sgl-model-gateway/
# Run quick benchmarks to ensure they work using Python script
python3 scripts/run_benchmarks.py --quick
@@ -170,7 +172,7 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: sgl-router
workspaces: sgl-model-gateway
cache-all-crates: true
cache-on-failure: true
@@ -182,7 +184,7 @@ jobs:
run: |
source "$HOME/.cargo/env"
export RUSTC_WRAPPER=sccache
cd sgl-router/bindings/python
cd sgl-model-gateway/bindings/python
python3 -m pip install --upgrade pip maturin
pip uninstall -y sglang-router
maturin build --profile ci --features vendored-openssl --out dist
@@ -190,14 +192,14 @@ jobs:
- name: Run Python unit tests
run: |
cd sgl-router
cd sgl-model-gateway
source "$HOME/.cargo/env"
python3 -m pip install pytest pytest-cov pytest-xdist
pytest -q py_test/unit --cov=sglang_router --cov-config=bindings/python/.coveragerc --cov-report=term-missing --cov-fail-under=80
- name: Run Python integration tests
run: |
cd sgl-router
cd sgl-model-gateway
source "$HOME/.cargo/env"
# Integration tests use FastAPI/uvicorn for mock workers
python3 -m pip install fastapi uvicorn orjson
@@ -206,7 +208,7 @@ jobs:
- name: Run Python E2E tests
run: |
bash scripts/killall_sglang.sh "nuk_gpus"
cd sgl-router
cd sgl-model-gateway
source "$HOME/.cargo/env"
python3 -m pip --no-cache-dir install --upgrade --ignore-installed blinker
python3 -m pip --no-cache-dir install --upgrade genai-bench==0.0.2
@@ -217,7 +219,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: genai-bench-results-all-policies
path: sgl-router/benchmark_**/
path: sgl-model-gateway/benchmark_**/
router-grpc-response-api-tests:
if: |
@@ -242,7 +244,7 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: sgl-router
workspaces: sgl-model-gateway
cache-all-crates: true
cache-on-failure: true
@@ -294,7 +296,7 @@ jobs:
run: |
source "$HOME/.cargo/env"
export RUSTC_WRAPPER=sccache
cd sgl-router/bindings/python
cd sgl-model-gateway/bindings/python
python3 -m pip install --upgrade pip maturin
pip uninstall -y sglang-router
maturin build --profile ci --features vendored-openssl --out dist
@@ -304,14 +306,14 @@ jobs:
run: |
python3 -m pip install pytest-rerunfailures
bash scripts/killall_sglang.sh "nuk_gpus"
cd sgl-router
cd sgl-model-gateway
source "$HOME/.cargo/env"
SHOW_ROUTER_LOGS=1 pytest --reruns 3 --reruns-delay 2 py_test/e2e_response_api -s -vv -o log_cli=true --log-cli-level=INFO
- name: Run Python E2E gRPC tests
run: |
bash scripts/killall_sglang.sh "nuk_gpus"
cd sgl-router
cd sgl-model-gateway
source "$HOME/.cargo/env"
SHOW_ROUTER_LOGS=1 ROUTER_LOCAL_MODEL_PATH="/home/ubuntu/models" pytest py_test/e2e_grpc -s -vv -o log_cli=true --log-cli-level=INFO

View File

@@ -4,7 +4,7 @@ on:
branches:
- main
paths:
- "sgl-router/bindings/python/sglang_router/version.py"
- "sgl-model-gateway/bindings/python/sglang_router/version.py"
workflow_dispatch:
jobs:
@@ -23,7 +23,7 @@ jobs:
- name: Build and Push
run: |
version=$(cat sgl-router/bindings/python/sglang_router/version.py | cut -d'"' -f2)
version=$(cat sgl-model-gateway/bindings/python/sglang_router/version.py | cut -d'"' -f2)
tag=v${version}
docker build . -f docker/gateway.Dockerfile -t lmsysorg/sglang-router:${tag} --no-cache

View File

@@ -5,7 +5,7 @@ on:
branches:
- main
paths:
- sgl-router/bindings/python/pyproject.toml
- sgl-model-gateway/bindings/python/pyproject.toml
workflow_dispatch:
jobs:
@@ -50,9 +50,9 @@ jobs:
with:
path: sglang-repo
- name: Move sgl-router folder to root and delete sglang-repo
- name: Move sgl-model-gateway folder to root and delete sglang-repo
run: |
mv sglang-repo/sgl-router/* .
mv sglang-repo/sgl-model-gateway/* .
rm -rf sglang-repo
ls -alt
shell: bash
@@ -123,9 +123,9 @@ jobs:
with:
path: sglang-repo
- name: Move sgl-router folder to root and delete sglang-repo
- name: Move sgl-model-gateway folder to root and delete sglang-repo
run: |
mv sglang-repo/sgl-router/* .
mv sglang-repo/sgl-model-gateway/* .
rm -rf sglang-repo
ls -alt

View File

@@ -31,7 +31,7 @@ repos:
args:
- --select=F401,F821
- --fix
files: ^(benchmark/|docs/|examples/|python/sglang/|sgl-router/py_*|test/)
files: ^(benchmark/|docs/|examples/|python/sglang/|sgl-model-gateway/py_*|test/)
exclude: |
(?x)^(
.*/__init__\.py$|
@@ -60,7 +60,7 @@ repos:
python/sglang/srt/grpc/.*_pb2_grpc\.py|
python/sglang/srt/grpc/.*_pb2\.pyi|
python/sglang/srt/grpc/.*_pb2_grpc\.pyi|
sgl-router/src/tokenizer/chat_template\.rs
sgl-model-gateway/src/tokenizer/chat_template\.rs
)$
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8

View File

@@ -281,16 +281,16 @@ RUN --mount=type=cache,target=/root/.cache/pip \
nixl \
py-spy
# Build and install sgl-router (install Rust, build, then remove to save space)
# Build and install sgl-model-gateway (install Rust, build, then remove to save space)
RUN --mount=type=cache,target=/root/.cache/pip \
curl --proto '=https' --tlsv1.2 --retry 3 --retry-delay 2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& export PATH="/root/.cargo/bin:${PATH}" \
&& rustc --version && cargo --version \
&& python3 -m pip install maturin \
&& cd /sgl-workspace/sglang/sgl-router/bindings/python \
&& cd /sgl-workspace/sglang/sgl-model-gateway/bindings/python \
&& ulimit -n 65536 && maturin build --release --features vendored-openssl --out dist \
&& python3 -m pip install --force-reinstall dist/*.whl \
&& cd /sgl-workspace/sglang/sgl-router \
&& cd /sgl-workspace/sglang/sgl-model-gateway \
&& cargo build --release --bin sglang-router --features vendored-openssl \
&& cp target/release/sglang-router /usr/local/bin/sglang-router \
&& rm -rf /root/.cargo /root/.rustup target dist ~/.cargo \

View File

@@ -52,7 +52,7 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
COPY --from=local_src /src /opt/sglang
# working directory
WORKDIR /opt/sglang/sgl-router
WORKDIR /opt/sglang/sgl-model-gateway
# install maturin and build the wheel with vendored OpenSSL
RUN uv pip install maturin \
@@ -66,7 +66,7 @@ RUN uv pip install maturin \
FROM base AS router-image
# Copy the built package from the build image
COPY --from=build-image /opt/sglang/sgl-router/bindings/python/dist/*.whl dist/
COPY --from=build-image /opt/sglang/sgl-model-gateway/bindings/python/dist/*.whl dist/
# Build the package and install
RUN uv pip install --force-reinstall dist/*.whl

View File

@@ -145,7 +145,7 @@ Error response format:
The classification API is implemented using:
1. **Rust Router**: Handles routing and request/response models in `sgl-router/src/protocols/spec.rs`
1. **Rust Model Gateway**: Handles routing and request/response models in `sgl-model-gateway/src/protocols/spec.rs`
2. **Python HTTP Server**: Implements the actual endpoint in `python/sglang/srt/entrypoints/http_server.py`
3. **Classification Service**: Handles the classification logic in `python/sglang/srt/entrypoints/openai/serving_classify.py`

View File

@@ -611,7 +611,7 @@ cargo test
cd bindings/python && maturin develop
# Run Python tests
cd ../.. # Back to sgl-router root
cd ../.. # Back to sgl-model-gateway root
pytest py_test/
```
For production builds, use `maturin build --release --out dist` from the `bindings/python/` directory to create optimized wheels. During development, `maturin develop` rebuilds and installs instantly without creating wheel files. Use `python -m sglang_router.launch_server` to co-launch router and SGLang workers in small clusters for local validation.
@@ -665,7 +665,7 @@ make release-notes PREV=gateway-v0.2.2 CURR=gateway-v1.0.0 CREATE_RELEASE=1 DRAF
### Filtered Paths
Release notes only include commits touching:
- `sgl-router/` - Router codebase
- `sgl-model-gateway/` - Router codebase
- `python/sglang/srt/grpc/` - gRPC protocol
- `python/sglang/srt/entrypoints/grpc_server.py` - gRPC server

View File

@@ -2,7 +2,7 @@
A high-level Go SDK for interacting with SGLang gRPC API, designed with an OpenAI-style API for familiarity and ease of use.
**Location**: `sgl-router/bindings/golang/`
**Location**: `sgl-model-gateway/bindings/golang/`
## Table of Contents
@@ -501,8 +501,8 @@ bindings/golang/
**Error**: `library 'sglang_router_rs' not found`
**Solution**:
1. Rebuild Rust library: `cd sgl-router/bindings/golang && make build`
2. Or manually with cargo: `cd sgl-router/bindings/golang && cargo build --release`
1. Rebuild Rust library: `cd sgl-model-gateway/bindings/golang && make build`
2. Or manually with cargo: `cd sgl-model-gateway/bindings/golang && cargo build --release`
3. Set `CARGO_BUILD_DIR` if using non-standard build location
4. Ensure Rust toolchain is installed: `rustup toolchain list`

View File

@@ -1,4 +1,4 @@
//! FFI module for exposing sgl-router preprocessing and postprocessing functions
//! FFI module for exposing sgl-model-gateway preprocessing and postprocessing functions
//! to C-compatible languages (e.g., Golang via cgo)
//!
//! This module provides C-compatible function signatures for:

View File

@@ -33,7 +33,7 @@ bindings/python/
pip install maturin
# Build and install in development mode
cd sgl-router/bindings/python
cd sgl-model-gateway/bindings/python
maturin develop --features vendored-openssl
```
@@ -41,7 +41,7 @@ maturin develop --features vendored-openssl
```bash
# Build wheel
cd sgl-router/bindings/python
cd sgl-model-gateway/bindings/python
maturin build --release --out dist --features vendored-openssl
# Install the built wheel
@@ -52,7 +52,7 @@ pip install dist/sglang_router-*.whl
```bash
# Run Python tests
cd sgl-router
cd sgl-model-gateway
pytest py_test/
```

Some files were not shown because too many files have changed in this diff Show More