Skip to content

feat(router): embedded selection partition parity with the runtime scheduler - #35

Closed
ishandhanani wants to merge 4 commits into
idhanani/p1-kv-router-embedded-selectionfrom
idhanani/s1a-embedded-parity
Closed

ishandhanani wants to merge 4 commits into
idhanani/p1-kv-router-embedded-selectionfrom
idhanani/s1a-embedded-parity

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Stack 1, group A, step 1 of the unification DEP (#33, "Stack 1 DEP r2" comment). Stacked on #18.

Summary

Brings the embedded selection partition to functional parity with the runtime-bound KvScheduler so the next step can delete the latter. Four logical commits, each independently reviewable:

  1. fix(router): feed scheduler load from the embedded selection partition — new SelectionHostHooks.scheduler_load_sink (SchedulerLoadSink); the partition's ScopedSequencePublisher forwards publish_scheduler_load(_batch) into it and the embedded host bridges it to the router's SchedulerLoadSender, so KvWorkerMonitor prefill-token overload (529) works on the embedded path.
  2. feat(router): make embedded selection the default scheduler — router_embedded_selection defaults to true in Rust, the Python arg group, and the bindings; --no-router-embedded-selection logs a deprecation warning.
  3. feat(router): replica sync for the embedded selection partition — new SelectionHostHooks.replica_sync (HostReplicaSyncFactory -> HostReplicaChannels). lib/llm supplies channels carried over the runtime event plane on ACTIVE_SEQUENCES_SUBJECT, the same subject and wire format as the runtime scheduler, so mixed fleets interoperate. lib/kv-router still never imports dynamo-runtime.
  4. feat(router): resolve linked worker-selection policies on the embedded partition — a process-wide policy registry installed by the bindings (install_worker_selection_policy_registry); the partition resolves router_prefill_policy/router_decode_policy against it, so WorkerSelectionPolicy callers no longer fall back to the runtime scheduler.

These are the same commits as #30's scheduler-parity subset, re-based onto #18 without the direct-dispatch, decode-first, and static-frontend material. #30 will be closed pointing here.

Validation

Review notes (graham-code-review pass)

  • embedded.rs: the replica_sync factory hands its channels to the first partition only (one-shot Mutex<Option<_>>). The router owns exactly one partition, so this is correct today; the API-cleanup step (SelectionHost.replication) removes the factory shape.
  • kv_router.rs: the TypeId check that routes arbitrary Sel types to the runtime scheduler is transitional and goes away with the Sel generic in the API-cleanup step.
  • No unwrap/expect in non-test code; spawned tasks in host_replica_channels observe the router's cancellation token; channels are bounded (REPLICA_EVENT_CHANNEL_CAPACITY).

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 <ishandhanani@gmail.com>
(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 <ishandhanani@gmail.com>

(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 <ishandhanani@gmail.com>
(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 <ishandhanani@gmail.com>
(cherry picked from commit fc22bac)
@github-actions github-actions Bot added feat documentation Improvements or additions to documentation router labels Sep 3, 2026
@ishandhanani

Copy link
Copy Markdown
Owner Author

Superseded by the upstream-shaped staging stack: continued as #47 (rebased onto ai-dynamo/main, see #33).

This branch had an error being deployed

1 failed deployment
external_collaborator — 20d725d7 Deployed Sep 3, 2026 by ishandhanani via ok-to-test #60
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 feat router

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant