Skip to content

refactor(kv-router): one Indexer type and one KV-event ingress for every selection host - #51

Closed
ishandhanani wants to merge 5 commits into
idhanani/up-6-membershipfrom
idhanani/up-7-kv-index-source
Closed

ishandhanani wants to merge 5 commits into
idhanani/up-6-membershipfrom
idhanani/up-7-kv-index-source

Conversation

@ishandhanani

@ishandhanani ishandhanani commented Sep 4, 2026 •

Copy link
Copy Markdown
Owner

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

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

Summary

Makes the frontend and selection core share one Indexer implementation and an explicit KV-event ingress interface. Selection, dequeue-time refresh and routing-decision recording then use the same partition index.

Implementation

  • KvIndexSource replaces the separate external-events, refresh-provider and remote-indexer configuration knobs.
  • Moves common lookup, recording and approximate request-lease behavior into dynamo-kv-router::services::indexer.
  • Uses RemotePrimary to support both HTTP standalone clients and the frontend's request-plane client.
  • KvEventIngress opens a partition index and owns its metadata requirements and worker attach/detach behavior.
  • ZmqDirectIngress supplies standalone event subscriptions; RuntimeIngress supplies frontend subscriptions, recovery and the served-indexer endpoint.
Walkthrough
flowchart LR
  Runtime[RuntimeIngress] --> Index[Partition Indexer]
  Zmq[ZmqDirectIngress] --> Index
  Remote[RemotePrimary] --> Index
  Index --> Selection[Selection and overlap refresh]
  Booking[Routing decisions and request leases] --> Index
Loading

One index and its producer

KvIndexSource::Owned asks its ingress to open and feed the index; Remote reads a standalone primary without local worker subscriptions. The temporary externally provided index variant is removed. Shared lookup and recording code retains tiered match information, capability-gated retention and the approximate request-lease API.

The frontend prepares its runtime subscription before partition initialization and returns the same index handle from open. Its ingress owns the subscription guard and drains it at shutdown. Recovery still runs in lib/llm through the ingress boundary; this PR does not move the recovery state machine into the core.

Worker lifecycle

Standalone ingress checks required per-rank endpoints, attaches listeners and removes their state when a worker leaves. Frontend membership and rank resets remain managed by runtime recovery, so its catalog attach/detach hooks are no-ops. Both hosts use the shared index methods rather than parallel enum implementations.

#53 removes the remaining single-variant refresh wrapper and fixes empty-partition index retention and metadata-update reconciliation. Those corrections are part of the tested final stack, not this intermediate boundary.

Validation

Current stack boundary: 9aa0971d66a30ffb6ef9f71b44dc94dbb56b7178; 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 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 (this PR) 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

…ex comes from

Replace three knobs that together described the same thing (the builder's
external_kv_events() and remote_indexer(), and SelectionHost's
OverlapRefreshSource) with one KvIndexSource on HostCache:

- Owned: the core owns the index and subscribes to worker KV events over ZMQ
  (the standalone default; workers need KV-event endpoints).
- External { refresh }: the host owns and feeds the index; workers need no
  KV-event metadata; refresh optionally lets the core re-score queued
  requests against the host's index (the frontend's embedded partition).
- Remote(url): a standalone indexer serves the primary index.

The listener decision, schedulability metadata, and dequeue-time refresh all
derive from this one value. SelectionServiceBuilder::kv_index sets it;
SelectionServiceConfig and the Python bindings map remote_indexer_url onto
Remote. No behavior change.

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

lib/llm and lib/kv-router each carried an Indexer enum with the same
Single/Concurrent/Remote shape (primary, lower tiers, predict-on-route side
overlay, primary_records_routing_decisions) and diverging method sets. Fold
the frontend's richer implementation into dynamo_kv_router::services::indexer:

- lookup.rs: the borrowed/owned HashInput lookup pipeline (primary, lower tiers
  seeded from confirmed primary matches, side overlay merged by per-worker
  max), find_matches_by_tier[_ref][_with_options], find_primary_*.
- recording.rs: routing-decision recording targets (side overlay, approximate
  primary, remote primary) and the per-request ApproximateRequestLease.
- backend.rs: the merged enum gains None, residency projection setters,
  try_apply_event (the backpressure-aware admit with a completion barrier on
  Cleared that recovery relies on), reset_worker_dp_rank_and_wait, and the
  approximate-LRU capacity and stats API. apply_event_routed and
  remove_worker[_dp_rank] stay as the standalone listener's path. Remote
  primaries go behind RemotePrimary so the HTTP standalone client here and the
  request-plane RemoteIndexer in lib/llm plug into the same enum. dump_events
  returns KvRouterError like the rest of the surface.
- The frontend keeps only construction (indexer::build from KvRouterConfig
  with component metrics and the request-plane remote), the served-indexer
  service, and recovery. Its 16 indexer tests move with the code.

No behavior change: both hosts run the exact code they ran before for their
own paths; TieredMatchProvider keeps the capability-gated variant.

Signed-off-by: Ishan Dhanani <[email protected]>
KvIndexSource::External { refresh } gave the core only a refresh handle onto
an index the host kept elsewhere. Replace it with Provided(Arc<Indexer>): the
host builds and feeds the index, and the core holds it as every partition's
index, reading it for selection and dequeue-time refresh (when the index
supports refresh) and never writing to it. The frontend's embedded partition
now shares the KvRouter's Indexer object instead of a TieredMatchProvider
view of it. RefreshProvider loses its External variant.

Signed-off-by: Ishan Dhanani <[email protected]>
KvIndexSource::Owned carries the ingress that feeds the core-built index.
The trait decides what metadata a worker needs to be schedulable, attaches
its ranks when the worker becomes schedulable, and detaches them when it
leaves. ZmqDirectIngress is the existing standalone behavior moved out of
SelectionCore: endpoint validation, one ZMQ listener per rank on the
registry, replay endpoint, deregistration on delete. The core keeps the
lifecycle decisions (when to attach, how to mark Incomplete) and no longer
knows about ZMQ endpoints.

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

KvEventIngress now builds the partition's index (open) as well as feeding it,
so KvIndexSource::Owned covers both hosts and Provided goes away:

- ZmqDirectIngress opens the registry's index and, on detach, deregisters the
  worker's listeners or, when there are none (events off or a remote primary),
  drops the worker from the index: the two behaviors SelectionCore used to
  branch on itself.
- RuntimeIngress (lib/llm/src/kv_router/indexer/ingress.rs) builds the
  frontend's index from the router config, starts the event-plane subscription
  with per-rank recovery and the served-indexer endpoint, and hands the index
  to the partition. Its per-worker hooks are no-ops because membership comes
  from the KV-source watch. KvRouter::new shrinks to constructing it; task
  guard and shutdown go through it.

The core no longer special-cases a host-fed index anywhere: every Owned index
is opened by and detached through its ingress.

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

This branch had an error being deployed

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