Repository navigation
[sgl-router] Serve chat completions through the policies_reorg resolver - #40279
Closed
sherlockwu wants to merge 1 commit into
Closed
sherlockwu wants to merge 1 commit into
sherlockwu wants to merge 1 commit into
Conversation
AppContext builds BucketResolver from ModelConfig over the shared state (affinity store, load table, local or remote prefix source) and the chat handler picks the prefill or plain engine, then the decode engine, through it. The legacy selection ladder (policies/selection.rs, decode.rs) is removed with its tests; the rest of the legacy module stays until the removal PR. Sticky, session and cache metrics keep their legacy names. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Collaborator
Author
|
Closing: the series stops at the power-of-two PR (#40271) for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Sixth PR of the engine-selection redesign, on top of #40277. The server now routes every chat completion through the new resolver. The legacy
policiesmodule stays in the tree (itsPolicytrait, factory and helpers still compile) so this PR is only the switch; the removal and the_reorgrename follow.Modifications
server/app_context.rs:AppContext::with_engine_state(config, tokenizers, proxy, registry, active_load, kv_index, prefix_index)buildsDependencies(affinity store with its sweeper, prefix source from the remote indexer or the local KV index, metrics) andBucketResolverfrombuild_pools.AppContext::newis the four-argument convenience without engine state. The legacypolicies,bucket_selector,prefix_indexandradix_tree_prefix_providerfields are gone.server/routes/chat.rs: classifies the deployment throughPdPoolResolverto choose the first stage, builds onePickRequestwith a sharedLoadViewandPrefixMemo, picks prefill then decode throughctx.buckets, and mapsPickErroronto the existing API errors and selection-failure metrics. Unknown models are 404 before tokenization.main.rsno longer builds the legacy policy registry.buckets_reorg::Poolscarriesneeds_request_tokensandneeds_dispatch_timestamps;Bucketkeeps its pending-prefill budget so the affinity group applies each engine's own bucket budget (PendingPrefillis a per-engine map).AffinityPolicyrecordssgl_router_sticky_totaloutcomes for sticky;CacheAwarePolicyrecords cache admission evaluations and rejections and the cache-aware decision. Decision reasons use the legacy labels (assigned,remap,session_primary,sticky_hit,cache_candidate,no_cache_candidate).policies/selection.rs,policies/decode.rs, their component test,tests/proxy/shared_prefill_admission.rs(it drove the legacy proposal and backup contract directly), the two indexer unit tests inchat.rs, and theCacheCandidatesExhaustedfailure reason.Behavior change worth a look: with buckets, an engine that the affinity group rejected is evaluated again by its own size bucket, so
sgl_router_cache_admission_rejected_totalcan count one request twice; the pending-prefill proxy test now asserts at least one rejection.Checklist
cargo clippy --locked --workspace --all-targets -- -D warningscleancargo test --locked --workspace -- --skip parity_matrixpasses (965 tests)🤖 Generated with Claude Code
CI States
Latest PR Test (Base): 🚫 Run #35411243786
Latest PR Test (Extra): 🚫 Run #35411243644
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.