Skip to content

refactor(kv-router): KvIndexSource names where a partition's KV index comes from - #39

Closed
ishandhanani wants to merge 1 commit into
idhanani/s1b-membershipfrom
idhanani/s1c-kv-index-source
Closed

ishandhanani wants to merge 1 commit into
idhanani/s1b-membershipfrom
idhanani/s1c-kv-index-source

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Stack 1, group C (KV index and ingress), first slice. Stacked on #38. DEP #33, "Stack 1 DEP r2" comment.

Summary

One logical change: SelectionHost.cache.index: KvIndexSource replaces three knobs that jointly described where a partition's KV index comes from:

Before After
SelectionServiceBuilder::external_kv_events() + OverlapRefreshSource::External(p) KvIndexSource::External { refresh: Some(p) }
external_kv_events() + OverlapRefreshSource::Disabled KvIndexSource::External { refresh: None }
SelectionServiceBuilder::remote_indexer(url) KvIndexSource::Remote(url)
default (PartitionIndexer) KvIndexSource::Owned (ZMQ direct ingress)

The core derives the KV-event listener decision, the worker schedulability metadata, and the dequeue-time overlap refresh source from this one value. SelectionServiceBuilder::kv_index sets it; SelectionServiceConfig and the Python SelectionService bindings map remote_indexer_url onto Remote. The frontend's embedded partition now declares External { refresh: <its indexer> }. No behavior change.

What remains in group C (not in this PR)

The DEP's second half of group C is moving the frontend's KV index and per-rank recovery state machine into the core so KvIndexSource::Owned carries a KvEventIngress (RuntimeIngress in lib/llm, ZmqDirectIngress in lib/kv-router) and the frontend stops keeping its own index. Inventory from this pass, for the follow-up PR:

  • The two Indexer enums (lib/llm/src/kv_router/indexer/mod.rs and lib/kv-router/src/services/indexer/backend.rs) have identical Single|KvIndexer/Concurrent/Remote shapes. The frontend adds: None, a request-plane RemoteIndexer (core's is HTTP), reset_worker_dp_rank_and_wait (completion barrier the recovery state machine needs), try_apply_event (backpressure-aware admit), residency projection/routing snapshot, approximate-LRU capacity and stats, store_event recording, and find_matches_by_tier[_ref].
  • RecoveryTarget (indexer/recovery/target.rs) already isolates what recovery needs from the index: admit_event, replace_rank, reset_rank. Implementing it for the core's Indexer is the seam for RuntimeIngress.
  • The recovery machinery itself (worker_query.rs, state_agent.rs, subscriber.rs, direct_zmq.rs, broker_zmq.rs, source_health.rs; ~11k lines) is transport-bound (event plane, request plane worker query) and stays in lib/llm as the RuntimeIngress implementation; only the index moves.
  • The deletion gate from the DEP applies: replay byte parity and the router e2e suite before the frontend indexer is removed.

I stopped this PR at the boundary type so the frontend and EPP keep their exact current index behavior while the API already names the three sources.

Validation

  • cargo test -p dynamo-kv-router --features standalone-selection --lib -- services::selection: 81 passed (includes the remote-indexer test: use_kv_events=true with a remote primary starts no listener).
  • cargo test -p dynamo-llm --lib -- kv_router::: 325 passed.
  • cargo clippy for dynamo-kv-router, dynamo-llm, dynamo-ext-proc (tests): clean. Bindings cargo check: clean.

Review notes (graham-code-review pass)

  • IndexerPolicy stays the internal, resolved form; KvIndexSource::Remote is the public input that produces it in build(). The core still receives the resolved policy so SelectionCore::new_inner stays infallible.
  • KvIndexSource::Owned is a unit variant on purpose: there is one ingress today. It grows a payload when RuntimeIngress lands rather than carrying a one-variant enum or a trait object with a single implementation now.

…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]>
@ishandhanani

Copy link
Copy Markdown
Owner Author

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

This branch had an error being deployed

1 failed deployment
external_collaborator — 80abca17 Deployed Sep 3, 2026 by ishandhanani via ok-to-test #64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant