Skip to content

feat(kv-router): one worker-membership path (WorkerCatalogSource) for frontend and EPP - #38

Closed
ishandhanani wants to merge 4 commits into
idhanani/s1a-api-cleanupfrom
idhanani/s1b-membership
Closed

ishandhanani wants to merge 4 commits into
idhanani/s1a-api-cleanupfrom
idhanani/s1b-membership

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Stack 1, group B (membership) of the unification DEP (#33, "Stack 1 DEP r2" comment). Stacked on #37.

Summary

One membership path for every host of SelectionCore. Four logical commits:

  1. feat(epp): data-parallel worker registration in the standalone reflector — feat(epp): data-parallel worker registration in the standalone reflector #22 folded in unchanged: strided KV-event ports per data-parallel rank (DYN_EPP_DATA_PARALLEL_SIZE, DYN_EPP_KV_EVENT_PORT_STRIDE).
  2. feat(kv-router): WorkerCatalogSource and CatalogReconciler for worker membership — a runtime-free trait yielding complete desired snapshots, and the reconciler that applies them: upsert new or changed records, retry records the core reported not schedulable, delete workers that left (including never-converged ones), reject duplicate ids before mutating, CatalogObserver for host metrics. SelectionService::core() exposes the core to hosts that drive its catalog.
  3. refactor(router): feed the embedded partition's catalog through CatalogReconciler — the runtime-config watch becomes RuntimeDiscoverySource; the router-local CatalogFeeder is deleted; the router_worker_registered gauge is kept through an observer.
  4. refactor(epp): expose the pod reflector as a WorkerCatalogSource — PodReflectorSource replaces Selector::reconcile, WorkerRegistration, and the EPP-local reconcile state (net -185 lines in ext-proc); the reconcile tests moved to dynamo-kv-router.

lib/kv-router still never imports dynamo-runtime; the runtime-flavored source lives in lib/llm, the Kubernetes one in ext-proc.

Behavior notes

  • Frontend: a worker the core reports not schedulable is now retried on every membership snapshot rather than only when its runtime config changes. Otherwise unchanged.
  • EPP: unchanged, including fail-closed on reflector loss (the source yields one empty snapshot before closing).
  • A closed source no longer implies clearing the catalog inside the reconciler; that policy belongs to the source. This was found by the routing-host unit tests, which drop the watch sender right after construction.

Validation

  • cargo test -p dynamo-kv-router --features standalone-selection --lib: passes (membership tests: retry-and-delete, converge-and-reupsert, duplicate rejection).
  • cargo test -p dynamo-llm --lib -- kv_router::: 325 passed.
  • cargo test -p dynamo-ext-proc: 141 passed (includes channel_close_clears_selector_topology through the new source).
  • cargo clippy on all three crates: clean.

Review notes (graham-code-review pass)

  • WorkerCatalogSource uses async_trait so it can be a Box<dyn> later; both crates already depend on it.
  • Snapshots are Vec<WorkerRequest> and the reconciler clones a request only when it upserts. WorkerRequest gained Clone + PartialEq for the converged cache; it is a control-plane record, not hot-path state.
  • run takes the source by value and spawns nothing itself; each host decides where the loop runs.

Phase 4 of the runtime-optional frontend roadmap: the EPP pod reflector is the
Kubernetes catalog feeder, and it registered every pod as a single
data-parallel rank (the hardcoded data_parallel_size: 1 in selector.rs).

- EppStandaloneConfig gains DYN_EPP_DATA_PARALLEL_SIZE (default 1) and
  DYN_EPP_KV_EVENT_PORT_STRIDE (default 1). Rank r publishes KV events on
  kv_event_port + r * stride; the reflector emits one KV-event endpoint per
  rank (RawWorker.kv_events_endpoints) and the registration carries
  data_parallel_size, which the selector passes through with
  data_parallel_start_rank 0.
- Adds the session_context field the EPP's booking request was missing since
  the structured session context landed in the selection service, so the
  ext-proc crate builds again on this stack.

Tests: strided per-rank endpoints for a 3-rank pod; existing reflector,
adapter, and selector tests updated to the per-rank shape (144 pass).

Signed-off-by: Ishan Dhanani <[email protected]>
(cherry picked from commit bb2af62)
… membership

A host owns discovery and exposes it as a WorkerCatalogSource: a stream of
complete desired membership snapshots. CatalogReconciler applies each snapshot
to a SelectionCore: it upserts new or changed records, retries records the core
reported not schedulable, deletes workers that left (including ones that never
converged), rejects duplicate ids before mutating anything, and clears the
catalog when the source closes so selection fails closed. A CatalogObserver
lets a host keep per-worker metrics in step.

This is the reconcile loop the EPP standalone selector and the frontend's
embedded partition each carried; both switch to it in the next commits.
SelectionService exposes its core for hosts that drive the catalog directly.

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

The runtime-config watch becomes a WorkerCatalogSource (RuntimeDiscoverySource)
and the partition's catalog is driven by the shared CatalogReconciler instead of
the router-local CatalogFeeder. The per-worker router_worker_registered gauge is
kept through a CatalogObserver. Behavior is unchanged except that a worker the
core reports not schedulable is now retried on every membership snapshot
rather than only when its runtime config changes.

Signed-off-by: Ishan Dhanani <[email protected]>
The standalone EPP's topology adapter yields the reflector's Ready pods as
WorkerRequest snapshots (PodReflectorSource) and lets CatalogReconciler own
the desired-versus-actual diff. Selector::reconcile, WorkerRegistration, and
the EPP-local reconcile state are removed; their tests moved to
dynamo-kv-router with the reconciler. A closed reflector channel still yields
one empty snapshot so selection fails closed, as before.

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

Copy link
Copy Markdown
Owner Author

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

This branch had an error being deployed

1 failed deployment
external_collaborator — decc58a7 Deployed Sep 3, 2026 by ishandhanani via ok-to-test #63
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