[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:
schedule:
+23 -22
View File
@@ -54,12 +54,13 @@ jobs:
with:
filters: |
sgl_router:
- 'experimental/sgl-router/**'
- 'sgl-router/**'
- 'rust/Cargo.toml'
- 'rust/sglang-processor/**'
- 'rust/sglang-api-types/**'
- 'proto/**'
- '.github/workflows/pr-test-sgl-router.yml'
- 'docker/sgl-router.Dockerfile'
- 'scripts/ci/cuda/ci_install_dependency.sh'
- name: Decide
id: decide
@@ -137,22 +138,22 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: experimental/sgl-router
workspaces: sgl-router
shared-key: "sgl-router-cache"
cache-all-crates: true
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: cargo check
working-directory: experimental/sgl-router
working-directory: sgl-router
run: cargo check --locked --workspace --all-targets
- name: cargo clippy
working-directory: experimental/sgl-router
working-directory: sgl-router
run: cargo clippy --locked --workspace --all-targets -- -D warnings
- name: cargo fmt
working-directory: experimental/sgl-router
working-directory: sgl-router
run: |
rustup toolchain install nightly --profile minimal --component rustfmt
cargo +nightly fmt --all -- --check
@@ -162,7 +163,7 @@ jobs:
run: cargo install --locked cargo-deny@0.19.6
- name: cargo deny check
working-directory: experimental/sgl-router
working-directory: sgl-router
run: cargo deny check licenses bans sources advisories
- name: Show sccache stats
@@ -210,14 +211,14 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: experimental/sgl-router
workspaces: sgl-router
shared-key: "sgl-router-cache"
cache-all-crates: true
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: cargo build (record wall time)
working-directory: experimental/sgl-router
working-directory: sgl-router
run: |
START=$(date +%s)
cargo build --locked --release --all-targets
@@ -227,7 +228,7 @@ jobs:
echo "::notice title=Tier-2 build duration::${BUILD_SECONDS}s"
- name: cargo test
working-directory: experimental/sgl-router
working-directory: sgl-router
# Skip the tokenizer parity_matrix test here: ubuntu-latest has
# no HuggingFace cache, so the matrix would hard-fail (see the
# 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
# regenerated.
- name: kv_events hash parity fixture (drift check)
working-directory: experimental/sgl-router
working-directory: sgl-router
run: |
set -euo pipefail
python3 tests/scripts/generate_kv_events_hash_parity.py
if ! git diff --exit-code -- tests/fixtures/kv_events_hash_parity.json; then
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."
exit 1
fi
@@ -307,20 +308,20 @@ jobs:
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
- 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
run: |
docker build -t sgl-router-fake-worker:e2e \
-f experimental/sgl-router/tests/e2e/k8s_integration/Dockerfile.fake_worker \
experimental/sgl-router/tests/e2e/k8s_integration/
-f sgl-router/tests/e2e/k8s_integration/Dockerfile.fake_worker \
sgl-router/tests/e2e/k8s_integration/
- 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
run: |
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
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
if: failure()
run: |
@@ -348,10 +349,10 @@ jobs:
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: experimental/sgl-router
workspaces: sgl-router
shared-key: "sgl-router-cache"
- name: cargo build (release)
working-directory: experimental/sgl-router
working-directory: sgl-router
run: |
source "$HOME/.cargo/env"
cargo build --locked --release --workspace
@@ -369,7 +370,7 @@ jobs:
- name: Install e2e test dependencies
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
# 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
# flakes (model load, HF auth) must not surface as k8s failures.
- name: Run e2e
working-directory: experimental/sgl-router
working-directory: sgl-router
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
@@ -388,7 +389,7 @@ jobs:
--ignore=tests/e2e/k8s_integration
- name: Tokenizer parity matrix (uses HF cache populated by e2e)
working-directory: experimental/sgl-router
working-directory: sgl-router
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
+3 -2
View File
@@ -73,7 +73,8 @@ instance/
# PyBuilder
.pybuilder/
target/
# `**/` because .dockerignore links here and Docker anchors bare patterns at the context root.
**/target/
# Jupyter Notebook
.ipynb_checkpoints
@@ -232,7 +233,7 @@ work_dirs/
Cargo.lock
!rust/Cargo.lock
!rust/sglang-radix-tree/Cargo.lock
!experimental/sgl-router/Cargo.lock
!sgl-router/Cargo.lock
# Other repos
lmms-eval
+3 -7
View File
@@ -11,10 +11,6 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
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-ast
- id: check-added-large-files
@@ -134,10 +130,10 @@ repos:
files: ^sgl-model-gateway/.*\.rs$
pass_filenames: false
- id: rustfmt-sgl-router
name: rustfmt experimental/sgl-router
entry: bash -c 'cd experimental/sgl-router && cargo fmt --all -- --check'
name: rustfmt sgl-router
entry: bash -c 'cd sgl-router && cargo fmt --all -- --check'
language: system
files: ^experimental/sgl-router/.*\.rs$
files: ^sgl-router/.*\.rs$
pass_filenames: false
- id: clippy-rust-workspace
name: clippy rust/ workspace (auto-fix)
+14 -14
View File
@@ -12,7 +12,7 @@
# manifests → cargo fetch → copy src" approach caches only the fetched
# 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
# graph CI checked, tested, and license-audited.
#
@@ -32,9 +32,9 @@ ARG DEBIAN_VERSION=bookworm
######################## STAGE 1 — chef recipe ##########################
FROM rust:${RUST_VERSION}-${DEBIAN_VERSION} AS chef
RUN cargo install cargo-chef --locked --version ^0.1
WORKDIR /work/experimental/sgl-router
COPY experimental/sgl-router/Cargo.toml experimental/sgl-router/Cargo.lock ./
COPY experimental/sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml
WORKDIR /work/sgl-router
COPY sgl-router/Cargo.toml sgl-router/Cargo.lock ./
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.
COPY rust/Cargo.toml /work/rust/Cargo.toml
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 \
&& rm -rf /var/lib/apt/lists/* \
&& 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
# 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.
ENV PCRE2_SYS_STATIC=1
COPY --from=chef /work/experimental/sgl-router/recipe.json ./recipe.json
COPY experimental/sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml
COPY --from=chef /work/sgl-router/recipe.json ./recipe.json
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
# stub of sglang-processor; its real sources arrive with the router's below.
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
# Now bring in the real sources and the manifests they need.
COPY experimental/sgl-router/Cargo.toml experimental/sgl-router/Cargo.lock ./
COPY experimental/sgl-router/src ./src
COPY experimental/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 experimental/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/Cargo.toml sgl-router/Cargo.lock ./
COPY sgl-router/src ./src
COPY sgl-router/sgl-kv-indexer/Cargo.toml sgl-kv-indexer/Cargo.toml
COPY sgl-router/sgl-kv-indexer/build.rs sgl-kv-indexer/build.rs
COPY sgl-router/sgl-kv-indexer/proto sgl-kv-indexer/proto
COPY sgl-router/sgl-kv-indexer/src sgl-kv-indexer/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 \
@@ -97,7 +97,7 @@ RUN touch sgl-kv-indexer/build.rs /work/rust/sglang-processor/src/lib.rs \
######################## STAGE 3 — 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`.
ENV SGL_ROUTER_CONFIG=/etc/sgl-router/sgl-router.yaml
@@ -1,6 +1,6 @@
# 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:
- `~/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:
```bash
cd experimental/sgl-router
cd sgl-router
cargo bench --bench tree_lookup -- --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.
minijinja = "2.24"
# 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
tokio = { version = "1.42", features = ["full"] }
@@ -57,7 +57,7 @@ reqwest = { version = "0.12", features = ["stream", "json", "rustls-tls", "http2
hyper = "1"
sgl-kv-indexer = { path = "sgl-kv-indexer" }
# 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"] }
# Serialization
@@ -60,7 +60,7 @@ header).
Build:
```bash
cd experimental/sgl-router
cd sgl-router
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
-->
# 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
(default `30000`).
## Files
- `grafana-dashboard.json` — importable Grafana dashboard, **SGLang Router
(experimental)** (uid `sgl-router-experimental`).
- `grafana-dashboard.json` — importable Grafana dashboard, **SGLang Router**
(uid `sgl-router-experimental`, kept so existing imports update in place).
## Metrics covered
@@ -2301,8 +2301,7 @@
"schemaVersion": 39,
"tags": [
"sglang",
"sgl-router",
"experimental"
"sgl-router"
],
"templating": {
"list": [
@@ -2380,7 +2379,7 @@
},
"timepicker": {},
"timezone": "",
"title": "SGLang Router (experimental)",
"title": "SGLang Router",
"uid": "sgl-router-experimental",
"version": 1,
"weekStart": ""
@@ -67,7 +67,7 @@ whole-block events. `REPORT` replaces the component snapshot for one
## Build
```bash
cd experimental/sgl-router
cd sgl-router
cargo build --release -p sgl-kv-indexer
```

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