[Refactor] sgl-router: Move experimental/sgl-router to top-level sgl-router (#45414)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kan Wu
2026-10-21 11:09:13 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent eb91a41f38
commit aba892fbdf
295 changed files with 92 additions and 129 deletions
@@ -1,4 +1,4 @@
name: Nightly Experimental sgl-router Docker Image name: Nightly sgl-router Docker Image
on: on:
schedule: schedule:
+23 -22
View File
@@ -54,12 +54,13 @@ jobs:
with: with:
filters: | filters: |
sgl_router: sgl_router:
- 'experimental/sgl-router/**' - 'sgl-router/**'
- 'rust/Cargo.toml' - 'rust/Cargo.toml'
- 'rust/sglang-processor/**' - 'rust/sglang-processor/**'
- 'rust/sglang-api-types/**' - 'rust/sglang-api-types/**'
- 'proto/**' - 'proto/**'
- '.github/workflows/pr-test-sgl-router.yml' - '.github/workflows/pr-test-sgl-router.yml'
- 'docker/sgl-router.Dockerfile'
- 'scripts/ci/cuda/ci_install_dependency.sh' - 'scripts/ci/cuda/ci_install_dependency.sh'
- name: Decide - name: Decide
id: decide id: decide
@@ -137,22 +138,22 @@ jobs:
- name: Rust cache - name: Rust cache
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
workspaces: experimental/sgl-router workspaces: sgl-router
shared-key: "sgl-router-cache" shared-key: "sgl-router-cache"
cache-all-crates: true cache-all-crates: true
cache-on-failure: true cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }} save-if: ${{ github.ref == 'refs/heads/main' }}
- name: cargo check - name: cargo check
working-directory: experimental/sgl-router working-directory: sgl-router
run: cargo check --locked --workspace --all-targets run: cargo check --locked --workspace --all-targets
- name: cargo clippy - name: cargo clippy
working-directory: experimental/sgl-router working-directory: sgl-router
run: cargo clippy --locked --workspace --all-targets -- -D warnings run: cargo clippy --locked --workspace --all-targets -- -D warnings
- name: cargo fmt - name: cargo fmt
working-directory: experimental/sgl-router working-directory: sgl-router
run: | run: |
rustup toolchain install nightly --profile minimal --component rustfmt rustup toolchain install nightly --profile minimal --component rustfmt
cargo +nightly fmt --all -- --check cargo +nightly fmt --all -- --check
@@ -162,7 +163,7 @@ jobs:
run: cargo install --locked cargo-deny@0.19.6 run: cargo install --locked cargo-deny@0.19.6
- name: cargo deny check - name: cargo deny check
working-directory: experimental/sgl-router working-directory: sgl-router
run: cargo deny check licenses bans sources advisories run: cargo deny check licenses bans sources advisories
- name: Show sccache stats - name: Show sccache stats
@@ -210,14 +211,14 @@ jobs:
- name: Rust cache - name: Rust cache
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
workspaces: experimental/sgl-router workspaces: sgl-router
shared-key: "sgl-router-cache" shared-key: "sgl-router-cache"
cache-all-crates: true cache-all-crates: true
cache-on-failure: true cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }} save-if: ${{ github.ref == 'refs/heads/main' }}
- name: cargo build (record wall time) - name: cargo build (record wall time)
working-directory: experimental/sgl-router working-directory: sgl-router
run: | run: |
START=$(date +%s) START=$(date +%s)
cargo build --locked --release --all-targets cargo build --locked --release --all-targets
@@ -227,7 +228,7 @@ jobs:
echo "::notice title=Tier-2 build duration::${BUILD_SECONDS}s" echo "::notice title=Tier-2 build duration::${BUILD_SECONDS}s"
- name: cargo test - name: cargo test
working-directory: experimental/sgl-router working-directory: sgl-router
# Skip the tokenizer parity_matrix test here: ubuntu-latest has # Skip the tokenizer parity_matrix test here: ubuntu-latest has
# no HuggingFace cache, so the matrix would hard-fail (see the # no HuggingFace cache, so the matrix would hard-fail (see the
# test docstring). The e2e job runs it after pytest populates # test docstring). The e2e job runs it after pytest populates
@@ -249,13 +250,13 @@ jobs:
# through to a no-diff "pass" when no fixture was actually # through to a no-diff "pass" when no fixture was actually
# regenerated. # regenerated.
- name: kv_events hash parity fixture (drift check) - name: kv_events hash parity fixture (drift check)
working-directory: experimental/sgl-router working-directory: sgl-router
run: | run: |
set -euo pipefail set -euo pipefail
python3 tests/scripts/generate_kv_events_hash_parity.py python3 tests/scripts/generate_kv_events_hash_parity.py
if ! git diff --exit-code -- tests/fixtures/kv_events_hash_parity.json; then if ! git diff --exit-code -- tests/fixtures/kv_events_hash_parity.json; then
echo "::error::kv_events hash parity fixture drifted." \ echo "::error::kv_events hash parity fixture drifted." \
"Re-run experimental/sgl-router/tests/scripts/generate_kv_events_hash_parity.py" \ "Re-run sgl-router/tests/scripts/generate_kv_events_hash_parity.py" \
"and commit the updated tests/fixtures/kv_events_hash_parity.json." "and commit the updated tests/fixtures/kv_events_hash_parity.json."
exit 1 exit 1
fi fi
@@ -307,20 +308,20 @@ jobs:
curl -Lo /tmp/kubectl https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl curl -Lo /tmp/kubectl https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl
chmod +x /tmp/kubectl && sudo mv /tmp/kubectl /usr/local/bin/kubectl chmod +x /tmp/kubectl && sudo mv /tmp/kubectl /usr/local/bin/kubectl
- name: Build router image - name: Build router image
run: docker build -t sgl-router:e2e -f experimental/sgl-router/tests/e2e/k8s_integration/Dockerfile.router . run: docker build -t sgl-router:e2e -f sgl-router/tests/e2e/k8s_integration/Dockerfile.router .
- name: Build fake_worker image - name: Build fake_worker image
run: | run: |
docker build -t sgl-router-fake-worker:e2e \ docker build -t sgl-router-fake-worker:e2e \
-f experimental/sgl-router/tests/e2e/k8s_integration/Dockerfile.fake_worker \ -f sgl-router/tests/e2e/k8s_integration/Dockerfile.fake_worker \
experimental/sgl-router/tests/e2e/k8s_integration/ sgl-router/tests/e2e/k8s_integration/
- name: Bootstrap kind + deploy - name: Bootstrap kind + deploy
run: bash experimental/sgl-router/tests/e2e/k8s_integration/setup.sh run: bash sgl-router/tests/e2e/k8s_integration/setup.sh
- name: Set up Python - name: Set up Python
run: | run: |
python3 -m venv /tmp/e2e-venv python3 -m venv /tmp/e2e-venv
/tmp/e2e-venv/bin/pip install -r experimental/sgl-router/tests/e2e/k8s_integration/requirements.txt /tmp/e2e-venv/bin/pip install -r sgl-router/tests/e2e/k8s_integration/requirements.txt
- name: Run E2E - name: Run E2E
run: /tmp/e2e-venv/bin/pytest experimental/sgl-router/tests/e2e/k8s_integration/ -v --tb=short run: /tmp/e2e-venv/bin/pytest sgl-router/tests/e2e/k8s_integration/ -v --tb=short
- name: Dump cluster + router diagnostics on failure - name: Dump cluster + router diagnostics on failure
if: failure() if: failure()
run: | run: |
@@ -348,10 +349,10 @@ jobs:
- name: Rust cache - name: Rust cache
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
workspaces: experimental/sgl-router workspaces: sgl-router
shared-key: "sgl-router-cache" shared-key: "sgl-router-cache"
- name: cargo build (release) - name: cargo build (release)
working-directory: experimental/sgl-router working-directory: sgl-router
run: | run: |
source "$HOME/.cargo/env" source "$HOME/.cargo/env"
cargo build --locked --release --workspace cargo build --locked --release --workspace
@@ -369,7 +370,7 @@ jobs:
- name: Install e2e test dependencies - name: Install e2e test dependencies
run: | run: |
python3 -m pip install -r experimental/sgl-router/tests/e2e/requirements.txt python3 -m pip install -r sgl-router/tests/e2e/requirements.txt
# IMPORTANT: --ignore=tests/e2e/k8s_integration. The k8s integration # IMPORTANT: --ignore=tests/e2e/k8s_integration. The k8s integration
# suite is owned by the `sgl-router-k8s-integration` job which has # suite is owned by the `sgl-router-k8s-integration` job which has
@@ -380,7 +381,7 @@ jobs:
# image pull) must not surface as e2e failures on H100, and e2e # image pull) must not surface as e2e failures on H100, and e2e
# flakes (model load, HF auth) must not surface as k8s failures. # flakes (model load, HF auth) must not surface as k8s failures.
- name: Run e2e - name: Run e2e
working-directory: experimental/sgl-router working-directory: sgl-router
env: env:
HF_TOKEN: ${{ secrets.HF_TOKEN }} HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: | run: |
@@ -388,7 +389,7 @@ jobs:
--ignore=tests/e2e/k8s_integration --ignore=tests/e2e/k8s_integration
- name: Tokenizer parity matrix (uses HF cache populated by e2e) - name: Tokenizer parity matrix (uses HF cache populated by e2e)
working-directory: experimental/sgl-router working-directory: sgl-router
env: env:
HF_TOKEN: ${{ secrets.HF_TOKEN }} HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: | run: |
+3 -2
View File
@@ -73,7 +73,8 @@ instance/
# PyBuilder # PyBuilder
.pybuilder/ .pybuilder/
target/ # `**/` because .dockerignore links here and Docker anchors bare patterns at the context root.
**/target/
# Jupyter Notebook # Jupyter Notebook
.ipynb_checkpoints .ipynb_checkpoints
@@ -232,7 +233,7 @@ work_dirs/
Cargo.lock Cargo.lock
!rust/Cargo.lock !rust/Cargo.lock
!rust/sglang-radix-tree/Cargo.lock !rust/sglang-radix-tree/Cargo.lock
!experimental/sgl-router/Cargo.lock !sgl-router/Cargo.lock
# Other repos # Other repos
lmms-eval lmms-eval
+3 -7
View File
@@ -11,10 +11,6 @@ repos:
- id: end-of-file-fixer - id: end-of-file-fixer
- id: check-yaml - id: check-yaml
args: [--allow-multiple-documents] args: [--allow-multiple-documents]
# Helm chart templates embed Go template syntax ({{- ... -}})
# that is not valid YAML on its own; the rendered output is
# validated by `helm template` / `helm lint`.
exclude: ^experimental/sgl-router/helm/.*/templates/.*\.(yaml|tpl)$
- id: check-toml - id: check-toml
- id: check-ast - id: check-ast
- id: check-added-large-files - id: check-added-large-files
@@ -134,10 +130,10 @@ repos:
files: ^sgl-model-gateway/.*\.rs$ files: ^sgl-model-gateway/.*\.rs$
pass_filenames: false pass_filenames: false
- id: rustfmt-sgl-router - id: rustfmt-sgl-router
name: rustfmt experimental/sgl-router name: rustfmt sgl-router
entry: bash -c 'cd experimental/sgl-router && cargo fmt --all -- --check' entry: bash -c 'cd sgl-router && cargo fmt --all -- --check'
language: system language: system
files: ^experimental/sgl-router/.*\.rs$ files: ^sgl-router/.*\.rs$
pass_filenames: false pass_filenames: false
- id: clippy-rust-workspace - id: clippy-rust-workspace
name: clippy rust/ workspace (auto-fix) name: clippy rust/ workspace (auto-fix)
+14 -14
View File
@@ -12,7 +12,7 @@
# manifests → cargo fetch → copy src" approach caches only the fetched # manifests → cargo fetch → copy src" approach caches only the fetched
# registry; every source change still recompiles every dep. # registry; every source change still recompiles every dep.
# #
# `experimental/sgl-router/Cargo.lock` is committed, and every cargo step # `sgl-router/Cargo.lock` is committed, and every cargo step
# below runs with `--locked`, so the image ships exactly the dependency # below runs with `--locked`, so the image ships exactly the dependency
# graph CI checked, tested, and license-audited. # graph CI checked, tested, and license-audited.
# #
@@ -32,9 +32,9 @@ ARG DEBIAN_VERSION=bookworm
######################## STAGE 1 — chef recipe ########################## ######################## STAGE 1 — chef recipe ##########################
FROM rust:${RUST_VERSION}-${DEBIAN_VERSION} AS chef FROM rust:${RUST_VERSION}-${DEBIAN_VERSION} AS chef
RUN cargo install cargo-chef --locked --version ^0.1 RUN cargo install cargo-chef --locked --version ^0.1
WORKDIR /work/experimental/sgl-router WORKDIR /work/sgl-router
COPY experimental/sgl-router/Cargo.toml experimental/sgl-router/Cargo.lock ./ COPY sgl-router/Cargo.toml sgl-router/Cargo.lock ./
COPY experimental/sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml COPY sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml
# sglang-processor is a path dependency that inherits from the rust/ workspace manifest. # sglang-processor is a path dependency that inherits from the rust/ workspace manifest.
COPY rust/Cargo.toml /work/rust/Cargo.toml COPY rust/Cargo.toml /work/rust/Cargo.toml
COPY rust/sglang-api-types /work/rust/sglang-api-types COPY rust/sglang-api-types /work/rust/sglang-api-types
@@ -57,7 +57,7 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends protobuf-compiler \ && apt-get install -y --no-install-recommends protobuf-compiler \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& cargo install cargo-chef --locked --version ^0.1 && cargo install cargo-chef --locked --version ^0.1
WORKDIR /work/experimental/sgl-router WORKDIR /work/sgl-router
# `dynamo-tokenizers` pulls in `pcre2-sys`, whose build.rs links the SYSTEM # `dynamo-tokenizers` pulls in `pcre2-sys`, whose build.rs links the SYSTEM
# libpcre2-8 whenever pkg-config finds it (it does here — the rust:bookworm # libpcre2-8 whenever pkg-config finds it (it does here — the rust:bookworm
@@ -67,8 +67,8 @@ WORKDIR /work/experimental/sgl-router
# it statically, keeping the runtime self-contained. # it statically, keeping the runtime self-contained.
ENV PCRE2_SYS_STATIC=1 ENV PCRE2_SYS_STATIC=1
COPY --from=chef /work/experimental/sgl-router/recipe.json ./recipe.json COPY --from=chef /work/sgl-router/recipe.json ./recipe.json
COPY experimental/sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml COPY sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml
# The recipe omits path dependencies outside this workspace, so cook against a # The recipe omits path dependencies outside this workspace, so cook against a
# stub of sglang-processor; its real sources arrive with the router's below. # stub of sglang-processor; its real sources arrive with the router's below.
COPY rust/Cargo.toml /work/rust/Cargo.toml COPY rust/Cargo.toml /work/rust/Cargo.toml
@@ -82,12 +82,12 @@ RUN mkdir -p /work/rust/sglang-processor/src && touch /work/rust/sglang-processo
RUN cargo chef cook --locked --release --recipe-path recipe.json RUN cargo chef cook --locked --release --recipe-path recipe.json
# Now bring in the real sources and the manifests they need. # Now bring in the real sources and the manifests they need.
COPY experimental/sgl-router/Cargo.toml experimental/sgl-router/Cargo.lock ./ COPY sgl-router/Cargo.toml sgl-router/Cargo.lock ./
COPY experimental/sgl-router/src ./src COPY sgl-router/src ./src
COPY experimental/sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml COPY sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml
COPY experimental/sgl-router/sgl-kv-indexer/build.rs sgl-kv-indexer/build.rs COPY sgl-router/sgl-kv-indexer/build.rs sgl-kv-indexer/build.rs
COPY experimental/sgl-router/sgl-kv-indexer/proto sgl-kv-indexer/proto COPY sgl-router/sgl-kv-indexer/proto sgl-kv-indexer/proto
COPY experimental/sgl-router/sgl-kv-indexer/src sgl-kv-indexer/src COPY sgl-router/sgl-kv-indexer/src sgl-kv-indexer/src
COPY rust/sglang-processor/src /work/rust/sglang-processor/src COPY rust/sglang-processor/src /work/rust/sglang-processor/src
RUN touch sgl-kv-indexer/build.rs /work/rust/sglang-processor/src/lib.rs \ RUN touch sgl-kv-indexer/build.rs /work/rust/sglang-processor/src/lib.rs \
@@ -97,7 +97,7 @@ RUN touch sgl-kv-indexer/build.rs /work/rust/sglang-processor/src/lib.rs \
######################## STAGE 3 — runtime ############################## ######################## STAGE 3 — runtime ##############################
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime FROM gcr.io/distroless/cc-debian12:nonroot AS runtime
COPY --from=builder /work/experimental/sgl-router/target/release/sgl-router /usr/local/bin/sgl-router COPY --from=builder /work/sgl-router/target/release/sgl-router /usr/local/bin/sgl-router
# Default config path; mount your own via `-v <host-path>:/etc/sgl-router`. # Default config path; mount your own via `-v <host-path>:/etc/sgl-router`.
ENV SGL_ROUTER_CONFIG=/etc/sgl-router/sgl-router.yaml ENV SGL_ROUTER_CONFIG=/etc/sgl-router/sgl-router.yaml
@@ -1,6 +1,6 @@
# sgl-router microbench harness + SMG comparison # sgl-router microbench harness + SMG comparison
This file pairs with `experimental/sgl-router/benches/` and the SMG This file pairs with `sgl-router/benches/` and the SMG
Criterion harnesses at: Criterion harnesses at:
- `~/smg_workspace/smg/model_gateway/benches/radix_tree_benchmark.rs` - `~/smg_workspace/smg/model_gateway/benches/radix_tree_benchmark.rs`
@@ -19,7 +19,7 @@ this file; it requires a real GPU cluster and is tracked separately.
sgl-router: sgl-router:
```bash ```bash
cd experimental/sgl-router cd sgl-router
cargo bench --bench tree_lookup -- --sample-size 30 --measurement-time 3 cargo bench --bench tree_lookup -- --sample-size 30 --measurement-time 3
cargo bench --bench policy_select -- --sample-size 30 --measurement-time 3 cargo bench --bench policy_select -- --sample-size 30 --measurement-time 3
``` ```
@@ -31,7 +31,7 @@ dynamo-renderer = "=7.1.1"
# `OAIChatLikeRequest` speaks minijinja values. # `OAIChatLikeRequest` speaks minijinja values.
minijinja = "2.24" minijinja = "2.24"
# SGLang chat rendering shared with the Rust server; DeepSeek-V4 renders through it. # SGLang chat rendering shared with the Rust server; DeepSeek-V4 renders through it.
sglang-processor = { path = "../../rust/sglang-processor", default-features = false, features = ["render", "openai"] } sglang-processor = { path = "../rust/sglang-processor", default-features = false, features = ["render", "openai"] }
# Async runtime + http # Async runtime + http
tokio = { version = "1.42", features = ["full"] } tokio = { version = "1.42", features = ["full"] }
@@ -57,7 +57,7 @@ reqwest = { version = "0.12", features = ["stream", "json", "rustls-tls", "http2
hyper = "1" hyper = "1"
sgl-kv-indexer = { path = "sgl-kv-indexer" } sgl-kv-indexer = { path = "sgl-kv-indexer" }
# Native SglangService gRPC types, shared with the engine (proto/sglang/runtime/v1). # Native SglangService gRPC types, shared with the engine (proto/sglang/runtime/v1).
sglang-api-types = { path = "../../rust/sglang-api-types" } sglang-api-types = { path = "../rust/sglang-api-types" }
tonic = { version = "0.14.6", features = ["transport"] } tonic = { version = "0.14.6", features = ["transport"] }
# Serialization # Serialization
@@ -60,7 +60,7 @@ header).
Build: Build:
```bash ```bash
cd experimental/sgl-router cd sgl-router
cargo build --release cargo build --release
``` ```

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

@@ -3,16 +3,16 @@ SPDX-FileCopyrightText: Copyright (c) 2026 The SGLang Authors
SPDX-License-Identifier: Apache-2.0 SPDX-License-Identifier: Apache-2.0
--> -->
# sgl-router (experimental) monitoring # sgl-router monitoring
Grafana dashboard for the experimental router's Prometheus metrics, exposed Grafana dashboard for sgl-router's Prometheus metrics, exposed
on `/metrics` (text/plain, version 0.0.4) on the router's serving port on `/metrics` (text/plain, version 0.0.4) on the router's serving port
(default `30000`). (default `30000`).
## Files ## Files
- `grafana-dashboard.json` — importable Grafana dashboard, **SGLang Router - `grafana-dashboard.json` — importable Grafana dashboard, **SGLang Router**
(experimental)** (uid `sgl-router-experimental`). (uid `sgl-router-experimental`, kept so existing imports update in place).
## Metrics covered ## Metrics covered
@@ -2301,8 +2301,7 @@
"schemaVersion": 39, "schemaVersion": 39,
"tags": [ "tags": [
"sglang", "sglang",
"sgl-router", "sgl-router"
"experimental"
], ],
"templating": { "templating": {
"list": [ "list": [
@@ -2380,7 +2379,7 @@
}, },
"timepicker": {}, "timepicker": {},
"timezone": "", "timezone": "",
"title": "SGLang Router (experimental)", "title": "SGLang Router",
"uid": "sgl-router-experimental", "uid": "sgl-router-experimental",
"version": 1, "version": 1,
"weekStart": "" "weekStart": ""
@@ -67,7 +67,7 @@ whole-block events. `REPORT` replaces the component snapshot for one
## Build ## Build
```bash ```bash
cd experimental/sgl-router cd sgl-router
cargo build --release -p sgl-kv-indexer cargo build --release -p sgl-kv-indexer
``` ```

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