Repository navigation
feat(router): re-host KvRouter scheduling on an embedded selection partition - #47
Closed
ishandhanani wants to merge 6 commits into
Closed
ishandhanani wants to merge 6 commits into
ishandhanani wants to merge 6 commits into
Conversation
ishandhanani
had a problem deploying
to
external_collaborator
September 4, 2026 03:18 — with
GitHub Actions
Failure
This was referenced Sep 4, 2026
ishandhanani
force-pushed
the
idhanani/up-3-embed-core
branch
from
September 4, 2026 04:00
1cf73f6 to
9865f28
Compare
ishandhanani
had a problem deploying
to
external_collaborator
September 4, 2026 04:00 — with
GitHub Actions
Failure
ishandhanani
had a problem deploying
to
external_collaborator
September 4, 2026 04:00 — with
GitHub Actions
Failure
ishandhanani
force-pushed
the
idhanani/up-3-embed-core
branch
from
September 9, 2026 18:30
9865f28 to
3cced08
Compare
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 18:30 — with
GitHub Actions
Failure
…rtition Phase 1a of the runtime-optional frontend roadmap. Behind KvRouterConfig::router_embedded_selection (--router-embedded-selection / DYN_ROUTER_EMBEDDED_SELECTION, default off), the frontend KvRouter runs its scheduling and active-sequence accounting on one partition of an in-process SelectionService instead of the runtime-bound KvScheduler: - RouterScheduler enum in KvRouter dispatches statically to either backend; every router method (admitted and advisory scheduling, bookings, lifecycle, potential loads) goes through it. Request leases fence with the partition scheduler's booking_cleanup exactly as with KvScheduler. - kv_router/embedded.rs builds the service with the registry-resolved policy (or Dynamo's default scorer/picker under the router's metric label), the router's overload/availability providers and prefill estimator as host hooks, and the router's own indexer as the dequeue-time overlap refresh source. A catalog feeder mirrors the runtime-config watch into the partition's worker catalog (dp layout, capacities, taints, topology, KV-transfer, router-hint metadata). - The router keeps its indexer and request transport: it computes overlap against its indexer and hands the partition a fully formed ScheduleRequest. Selection-service additions used by the host: SelectionPartition handle, ensure_partition (create the scheduler before workers register), external_kv_events (host feeds KV state; no ZMQ listeners), a policy-factory override on the builder, and OverlapRefreshSource (partition indexer, external, or disabled). Not carried over in embedded mode: NATS active-sequence replica sync (router_replica_sync warns), per-class queue metrics, and scheduler load publication to the routing-load monitor. Tests: routing_host::embedded_selection_books_and_releases_like_the_runtime_scheduler mirrors the runtime preview/plan/abort/track/free flow on the embedded path; embedded::worker_request_mirrors_runtime_config covers the catalog mapping. All existing kv_router tests pass on the runtime path. Signed-off-by: Ishan Dhanani <[email protected]>
KvWorkerMonitor's prefill-token overload detection reads the scheduler's own load snapshots through SchedulerLoadSender. The embedded selection partition never published them, so --active-prefill-tokens-threshold could not trigger 529 under --router-embedded-selection (tests/router test_mocker_kv_router_overload_529[prefill-tokens] failed only on that path; decode-blocks worked because it uses worker-published metrics). Add SelectionHostHooks.scheduler_load_sink (a SchedulerLoadSink) that the partition's ScopedSequencePublisher forwards publish_scheduler_load(_batch) into; the embedded host bridges it to the router's SchedulerLoadSender. tests/router overload_529 (agg + disagg, prefill-tokens + decode-blocks) now pass on the embedded path. Signed-off-by: Ishan Dhanani <[email protected]> (cherry picked from commit beb6ddc)
Phase 1 exit gates now pass: the frontend A/B benchmark (+6% req/s, lower p50/p99), offline KV replay byte-parity against main on four rows, and tests/router e2e green on both scheduler paths. Flip router_embedded_selection to default true (serde default/skip updated, PyO3 constructor, .pyi, --router-embedded-selection default, docs). The runtime-bound KvScheduler path stays reachable through --no-router-embedded-selection for one release as a rollback and logs a deprecation warning at startup; deleting it is the follow-up. A caller-injected custom WorkerSelector type (not DefaultWorkerSelector) cannot run on the partition, so KvRouter::new keeps the runtime scheduler for it with a warning instead of silently changing selection semantics. Signed-off-by: Ishan Dhanani <[email protected]> (cherry picked from commit 568d06c)
--router-replica-sync previously logged that it was not carried over to the embedded partition. Add SelectionHostHooks.replica_sync, a per-partition factory returning HostReplicaChannels (outbound events, inbound peer events, this replica's id); when the service runs no ZMQ peer mesh the partition's publisher forwards to the host's outbound channel and its replica consumer reads the host's inbound channel. The embedded host builds those channels over the runtime event plane (ACTIVE_SEQUENCES_SUBJECT, same wire formats and subscriber as the runtime scheduler used), so multi-replica frontends keep active-sequence sync on the default scheduler path. Signed-off-by: Ishan Dhanani <[email protected]> (cherry picked from commit d586893)
…d partition Install the process-wide WorkerSelectionPolicyRegistry (the linked custom policy catalog the Python bindings register under --features custom-policy) through dynamo_llm::kv_router::install_worker_selection_policy_registry; embedded partitions and the static frontend resolve KvRouterConfig policy instances against it instead of the built-in default registry. A KvRouter built with Sel = WorkerSelectionPolicy therefore runs on the embedded partition too; only an arbitrary caller-injected WorkerSelector type (unit test fakes) still selects the runtime scheduler. Signed-off-by: Ishan Dhanani <[email protected]> (cherry picked from commit fc22bac)
…tion Signed-off-by: Ishan Dhanani <[email protected]>
ishandhanani
force-pushed
the
idhanani/up-3-embed-core
branch
from
September 9, 2026 19:06
3cced08 to
b2644f8
Compare
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 19:06 — with
GitHub Actions
Failure
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 19:06 — with
GitHub Actions
Failure
This was referenced Sep 10, 2026
Closed
This branch had an error being deployed
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.
PR 3 of 9 implementing ai-dynamo#14310 (one
SelectionCorefor the frontend, the standalone selection service, and the EPP). Base:idhanani/up-2-core-indexing(PR 2 of this stack).Summary
Makes the frontend
KvRouterschedule and account for active sequences through an embedded selection partition. This connects the frontend to the standalone core while retaining its runtime discovery, transport and cache-recovery integrations.Implementation
EmbeddedSelectioncreates the partition before discovery supplies workers and maps runtime worker metadata into its catalog.KvWorkerMonitor, preserving overload feedback.Walkthrough
Scheduling and lifecycle
The router supplies the same policy inputs to the partition that it supplied to
KvScheduler. Request admission, booking and release use the partition handle; request transport and the frontend index remain owned by the runtime host at this boundary. Discovery projection includes DP layout, capacities, taints, topology and the current KV-transfer metadata.Scheduler load is forwarded through the host sink so the worker monitor can still apply prefill overload feedback. Replica tasks use bounded channels and the router's cancellation token. A one-shot channel factory is sufficient here because a frontend router owns one partition.
Transitional interfaces
The embedded flag is enabled by default. Non-default selector types can still use the legacy scheduler in this PR; #48 removes that scheduler and #49 removes the flag, selector generic and temporary adapter. The full series' replica request-lease and expiry ownership corrections are included in #53.
Validation
Current stack boundary:
b2644f824d7d81b8928b81bdcb1b81551df065e6; the series is based on Dynamo mainab58558c2dff28f4ff1ea4e219030eac5da3f48f.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-targetsfor this stack boundary.cargo check --manifest-path lib/bindings/python/Cargo.toml --features select-service --all-targetsat this boundary.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.
Historical prototype benchmark
dynamo.frontend --router-mode kvpinned to 4 cores, 4dynamo.mockerworkers plus aiperf on the other 12, block size 64, closed loop at concurrency 128, 1024 requests after 256 warmup, arms interleaved with teardown between runs.KvSchedulerThese inherited prototype measurements were not rerun at this rebased PR boundary and do not establish a speedup for the current series. Current aggregated GPU measurements are reported in #53.
Stack
idhanani/up-1-host-hooksidhanani/up-2-core-indexingidhanani/up-3-embed-coreidhanani/up-4-delete-kvscheduleridhanani/up-5-policy-sourceidhanani/up-6-membershipidhanani/up-7-kv-index-sourceidhanani/up-8-affinity-tableidhanani/up-9-epp-affinity