Skip to content

refactor(router): selection policy source, SelectionHost, and dead-flag removal - #49

Closed
ishandhanani wants to merge 5 commits into
idhanani/up-4-delete-kvschedulerfrom
idhanani/up-5-policy-source
Closed

ishandhanani wants to merge 5 commits into
idhanani/up-4-delete-kvschedulerfrom
idhanani/up-5-policy-source

Conversation

@ishandhanani

@ishandhanani ishandhanani commented Sep 4, 2026 •

Copy link
Copy Markdown
Owner

PR 5 of 9 implementing ai-dynamo#14310 (one SelectionCore for the frontend, the standalone selection service, and the EPP). Base: idhanani/up-4-delete-kvscheduler (PR 4 of this stack).

Fork staging copy of the upstream PR, rebased onto ai-dynamo/main. Replaces fork #37, which stay open for review history.

Summary

Replaces the frontend router's selector type parameter with an explicit SelectionPolicySource and groups host inputs into SelectionHost. This removes the temporary compatibility interfaces left after deleting the runtime scheduler.

Implementation

  • Removes the ignored embedded-selection flag from Rust configuration, environment handling, Python bindings and the frontend configuration reference.
  • Uses SelectionPolicySource::Registry or Factory instead of threading <Sel> through router, discovery and request-lifecycle types.
  • Removes DelegatedWorkerSelector, ErasedWorkerConfig and their now-unused policy state.
  • Groups host inputs into load, cache, eligibility, telemetry and replication fields.
  • Updates main's current entrypoint, request-guard and custom-policy call sites after type erasure.
Walkthrough
flowchart LR
  Config[Configured policy name] --> Registry[Registry source]
  Caller[Explicit policy factory] --> Factory[Factory source]
  Registry --> Router[Frontend router]
  Factory --> Router
  Router --> Host[SelectionHost]
  Host --> Partition[Selection partition]
Loading

Policy resolution

The registry source resolves a linked policy named by configuration, falling back to Dynamo's default policy when no linked policy is selected. The factory source supplies an explicit policy factory. Construction inspects policy worker inputs to preserve indexer and shared-cache gating; this is construction work, not a per-request policy instantiation.

Custom-policy bindings retain the caller's typed worker role and display name. Tests inject public picker/filter policies instead of fake router selector types. Scheduler error mapping continues to cover overload behavior separately from policy filtering.

Host boundary

SelectionHost groups existing inputs without moving runtime transport into the core. Availability and overload remain host inputs because discovery and slot state do not contain every transport or backend health signal. The removed embedded-selection flag was a temporary stack interface; it no longer chooses a second scheduler.

#51 makes the cache group's index source explicit. #53 documents and validates the final affinity and request-lifecycle ownership.

Validation

Current stack boundary: 9cb836bccd906ed51d90ab525273fcc7efea2805; the series is based on Dynamo main ab58558c2dff28f4ff1ea4e219030eac5da3f48f.

  • Passed cargo check -p dynamo-kv-router -p dynamo-llm -p dynamo-ext-proc --no-default-features --features dynamo-kv-router/standalone-selection,dynamo-kv-router/standalone-slot-tracker --all-targets for this stack boundary.
  • Python bindings passed cargo check --manifest-path lib/bindings/python/Cargo.toml --features select-service --all-targets at this boundary.
  • The complete series was tested at feat(kv-router): session affinity for the standalone service and EPP #53; its description records the Rust/Python suites, aggregated GPU correctness probes and paired main/final benchmarks. Those end-to-end results apply to the final stack, not to a separate deployment of this intermediate PR.

GitHub CI is not green across this series. Recurring failures are the missing fork Fastchecker runner group, helm-tester image and approval-bot token, plus published-docs composition and an unchanged external documentation link. The local compilation and final-stack validation above are recorded separately from those CI failures.

Stack

# Branch Title Fork PRs it replaces
1 idhanani/up-1-host-hooks feat(kv-router): host-supplied inputs for SelectionService parity with the frontend scheduler #8 to #12
2 idhanani/up-2-core-indexing feat(kv-router): approximate, remote, and hint-aware indexing in SelectionService #14 to #16
3 idhanani/up-3-embed-core feat(router): re-host KvRouter scheduling on an embedded selection partition #18, #35
4 idhanani/up-4-delete-kvscheduler refactor(router): delete the runtime-bound KV router scheduler #36
5 (this PR) idhanani/up-5-policy-source refactor(router): selection policy source, SelectionHost, and dead-flag removal #37
6 idhanani/up-6-membership feat(kv-router): one worker-membership path for frontend and EPP #38
7 idhanani/up-7-kv-index-source refactor(kv-router): one Indexer type and one KV-event ingress for every selection host #39, #41, #43
8 idhanani/up-8-affinity-table refactor(kv-router): one session-affinity implementation for every selection host #42
9 idhanani/up-9-epp-affinity feat(kv-router): session affinity for the standalone service and EPP #44

The embedded selection partition is the only scheduler, so the flag has
been a no-op since the runtime scheduler was deleted. It never shipped in a
release, so no wire compatibility shim is needed: drop it from
KvRouterConfig (Rust and serde), the DYN_ROUTER_EMBEDDED_SELECTION
environment override, the Python argument group, the bindings signature,
and the frontend configuration reference.

Signed-off-by: Ishan Dhanani <[email protected]>
…router

KvRouter, RoutingHost, RoutePlan, RequestGuard, PrefillRouter, ManagedKvRouter,
ModelWatcher, and PreprocessedRouting were generic over a caller-injected
WorkerSelector type that only ever named the policy the embedded partition
would run. Replace the parameter with SelectionPolicySource: Registry (the
linked policy the router config names, else Dynamo's default) or Factory (an
explicit WorkerSelectionPolicyFactory). The router resolves it once at
construction and instantiates one policy to learn the worker inputs it needs,
so shared-cache and indexer gating are unchanged.

ModelManager constructors take the policy source in place of a selector
(kv_chooser_for_with_policy[_and_client], managed_kv_router_for_with_policy);
HttpFrontend, ModelWatcher, and PrefillRouter carry it instead of a
per-model selector factory. The bindings' custom-policy feature no longer
needs a separate router type. The delegating-selector adapter in the
embedded backend is removed with its only caller. Unit tests that injected
fake selectors now inject picker or filter policies through the public
worker-selection API; the overload test becomes a filtered-workers test
because a policy cannot report overload directly.

Signed-off-by: Ishan Dhanani <[email protected]>
DelegatedWorkerSelector, ErasedWorkerConfig, and the Delegated policy state
existed only so the frontend could run an arbitrary caller-injected
WorkerSelector type on a partition. That path is gone with the selector type
parameter; custom policies use WorkerSelectionPolicy's filter, scorer, and
picker API like every other host.

Signed-off-by: Ishan Dhanani <[email protected]>
…ionHost

SelectionHostHooks was a flat bag of eight optional fields. Regroup it by
purpose as SelectionHost { load, cache, eligibility, telemetry, replication },
each group defaulting to the standalone service's behavior so a host sets only
the groups it owns. The builder method becomes SelectionServiceBuilder::host.
No behavior change; the frontend's embedded partition sets the same values.

Signed-off-by: Ishan Dhanani <[email protected]>

This branch had an error being deployed

1 failed deployment
external_collaborator — 9cb836bc Deployed Sep 9, 2026 by ishandhanani via ok-to-test #138
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 refactor router

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant