Skip to content

[sgl-router] refactor - generalized admission policy definitions - #40271

Merged
ShangmingCai merged 1 commit into
mainfrom
router/policies-reorg-2-load
Sep 21, 2026
Merged

ShangmingCai merged 1 commit into
mainfrom
router/policies-reorg-2-load

Conversation

@sherlockwu

@sherlockwu sherlockwu commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Stack: main → #40272 (shared state) → #40241 (bucket routing and power-of-two) → #40379 (session-aware) → #40366 (cache-aware) → #40271 (admission) → #40292 (SLO ordering).

Design

  • AdmissionLimits has one optional cap per metric: max_running_requests, max_waiting_requests, max_kv_tokens, max_pending_prefill_tokens, max_inflight_requests. An unset cap is not checked; the default admits everything. Serde-shaped (deny_unknown_fields) so CLI/config can map to it 1:1.
  • EngineMetrics::observe(engine, snapshot) reads the selected engine's measurements from the load snapshot selection already captured, plus the live router in-flight counter. Reported metrics are None without a fresh, complete report, never zero.
  • EngineAdmission::check(engine, &metrics) admits while every capped metric is below its cap and rejects with the cap's name. Unknown reported metrics fail open. Request size is not an admission input: buckets already select by input length and context capacity, and admission observes load without reserving it.
  • Policies keep admission: Arc<dyn EngineAdmission> and decide where to check (power-of-two on its pick, session-aware on binding reuse/assignment, cache-aware per candidate and on its fallback winner). Rejection advances to the next bucket as before.

Production CLI/config construction of resolvers and their admission limits remains separate work.

Validation after rebase

Rebased the stack onto main (b3e4d198af) after #39867 merged. All 31 commit patches and each PR's router tree are unchanged. The rebased stack tip (#40292) passes formatting, Clippy, and workspace tests: 1,100 passed, with two Hugging Face cache-dependent parity tests excluded.

PR-specific validation from the unchanged router trees:

  • cargo +nightly fmt --all -- --check
  • cargo +1.92 clippy --locked --workspace --all-targets -- -D warnings
  • cargo +1.92 test --locked --test component --test proxy -- --skip parity_matrix: 106 component and 137 proxy tests passed. Two Hugging Face cache-dependent parity tests excluded.

CI States

Latest PR Test (Base): ✅ Run #35566292682
Latest PR Test (Extra): ❌ Run #35566292519
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.

@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 35d4008 to 85dae09 Compare September 19, 2026 00:35
@sherlockwu sherlockwu changed the title [sgl-router] policies_reorg: load-based policies and admission checks [sgl-router] policies_reorg: power-of-two and admission checks Sep 19, 2026
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 85dae09 to 4c349b2 Compare September 19, 2026 01:08
@sherlockwu
sherlockwu added this pull request to stack #40280 September 19, 2026 01:09
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 4c349b2 to fcb5845 Compare September 19, 2026 04:29
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 19, 2026
@sherlockwu sherlockwu changed the title [sgl-router] policies_reorg: power-of-two and admission checks [sgl-router] Add admission checks to bucket-first routing Sep 19, 2026
@sherlockwu sherlockwu changed the title [sgl-router] Add admission checks to bucket-first routing [sgl-router] refactor - admission checks Sep 19, 2026
@sherlockwu
sherlockwu removed this pull request from stack #40280 September 19, 2026 17:34
@sherlockwu
sherlockwu changed the base branch from codex/policies-reorg-skeleton to codex/policies-reorg-cache-aware September 19, 2026 17:34
@sherlockwu
sherlockwu added this pull request to stack #40368 September 19, 2026 17:34
@sherlockwu
sherlockwu removed this pull request from stack #40368 September 19, 2026 20:40
@sherlockwu
sherlockwu added this pull request to stack #40380 September 19, 2026 20:40
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 07fbd4f to 37acb03 Compare September 19, 2026 23:29
@sherlockwu sherlockwu changed the title [sgl-router] refactor - admission checks [sgl-router] Add metric-limit admission to bucket engine groups Sep 19, 2026
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 37acb03 to 6d27855 Compare September 19, 2026 23:51
@sherlockwu
sherlockwu marked this pull request as ready for review September 19, 2026 23:55
@sherlockwu sherlockwu changed the title [sgl-router] Add metric-limit admission to bucket engine groups [sgl-router] refactor - generalized admission policy definitions Sep 20, 2026
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 6d27855 to 225c94e Compare September 20, 2026 00:05
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 225c94e to 1e0b6ec Compare September 20, 2026 17:28
@sherlockwu
sherlockwu removed this pull request from stack #40380 September 20, 2026 17:28
@sherlockwu
sherlockwu added this pull request to stack #40484 September 20, 2026 17:28
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 1e0b6ec to 092d76e Compare September 20, 2026 22:23
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 092d76e to 6cb9f56 Compare September 20, 2026 23:49
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 6cb9f56 to 0a10b5c Compare September 20, 2026 23:57
@sherlockwu
sherlockwu force-pushed the router/policies-reorg-2-load branch from 0a10b5c to 53d5a01 Compare September 21, 2026 00:22
Base automatically changed from codex/policies-reorg-cache-aware to main September 21, 2026 05:53
An admission policy is a set of per-engine caps. `AdmissionLimits` holds one
optional cap per metric (running, waiting, KV tokens, pending prefill tokens,
router-local in-flight); unset caps are not checked and the default admits
everything. Policies read the selected engine's `EngineMetrics` from the
selection snapshot plus the live in-flight counter and admit while every
capped metric is below its cap. Request size stays a bucket concern; unknown
reported metrics fail open; the rejection reason is the cap's name.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ShangmingCai
ShangmingCai force-pushed the router/policies-reorg-2-load branch from 53d5a01 to 8deda3e Compare September 21, 2026 05:54
ShangmingCai added a commit to ShangmingCai/sglang that referenced this pull request Sep 21, 2026
The previous commit renamed `AllowAll` but also reworded the prose around
it ("default limits", "unless limits are configured"), editing text sgl-project#40271
wrote instead of aligning to it. It also spelled the concept two different
ways.

Use the name sgl-project#40271 established itself, `AdmissionLimits::default()`, in
all four places and restore every other word. Normalizing whitespace on
sgl-project#40271's POLICY_DESIGN.md and applying that one rename now reproduces this
file exactly; lines are rewrapped only where the longer name no longer
fits the paragraph.

No behavior change; documentation and one comment only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@ShangmingCai ShangmingCai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Will fix some minor issues (test compile, doc) in #40537

@ShangmingCai

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Sep 21, 2026
@ShangmingCai
ShangmingCai merged commit a987101 into main Sep 21, 2026
110 of 125 checks passed
@ShangmingCai
ShangmingCai deleted the router/policies-reorg-2-load branch September 21, 2026 08:26
ShangmingCai added a commit to ShangmingCai/sglang that referenced this pull request Sep 21, 2026
sgl-project#40271 was squash-merged as a987101, so this branch's copy of its
commit (8deda3e) is not in main's history and every file they both
touch conflicts textually despite identical content.

Resolve by taking the tree of this branch rebased onto main: the sgl-project#40271
content comes from main's squash commit, plus this PR's two changes
(the BucketResolver::new unwrap and the AllowAll rename). All three
files are byte-identical to the previously verified branch tip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants