Skip to content

feat(kv-router): approximate, remote, and hint-aware indexing in SelectionService - #46

Closed
ishandhanani wants to merge 3 commits into
idhanani/up-1-host-hooksfrom
idhanani/up-2-core-indexing
Closed

ishandhanani wants to merge 3 commits into
idhanani/up-1-host-hooksfrom
idhanani/up-2-core-indexing

Conversation

@ishandhanani

@ishandhanani ishandhanani commented Sep 4, 2026 •

Copy link
Copy Markdown
Owner

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

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

Summary

Adds approximate, remote and hint-aware KV indexing to the standalone selection core. Booked requests can contribute cache knowledge when worker events are disabled, while remote-index and transfer-hint paths use the current typed protocols.

Implementation

  • IndexerPolicy chooses an event-driven primary, an event-driven primary with a prediction side index, or an approximate TTL primary from router configuration.
  • Successful bookings record routing decisions into the approximate index; query-only selection records nothing.
  • An HTTP remote primary exposes tiered overlap through POST /query_tiered_by_hash and replaces local KV-event subscriptions.
  • Worker metadata exposes backend role and per-rank control endpoints; booked responses carry a typed kv_hint when a usable source has a longer prefix than the selected worker.
  • Python selection-service bindings accept remote_indexer_url, including the feature-gated lifecycle-test constructor at this boundary.
Walkthrough
flowchart LR
  Config[Router configuration] --> Policy[IndexerPolicy]
  Policy --> Index[Local or remote primary]
  Request[Request and worker metadata] --> Core[SelectionCore]
  Index --> Core
  Core --> Booking[Booking and optional KV hint]
  Booking --> Recording[Approximate decision recording]
Loading

Index selection and writes

When use_kv_events=false, the primary is populated from admitted routing decisions instead of remaining empty. select_and_reserve, cached booking replay and explicit reservations carrying tokens or hashes record their decisions. Recording happens after booking, so a recording error is logged rather than reported as a failed booking.

A remote primary needs neither worker KV-event endpoints nor local listeners or peer recovery. It is rejected with events disabled because the remote service has no routing-decision write API. Capacity-bounded approximate retention still falls back to TTL at this boundary until request-lease support is shared in #51.

Transfer hints and boundaries

The core retains matched chains only when the partition can consume hints. Source selection checks the backend role, control endpoint, cached-prefix advantage and the current transfer constraints; the response field is SelectResponse::kv_hint, not the prototype router_hint field. Query-only selection emits no transfer hint.

This adds indexing and selection metadata. It does not add the separate DisaggCoordinator piece or claim a disaggregated end-to-end test.

Validation

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

…ctionService

Second half of input parity: the standalone core indexes the way the frontend
KvRouter does.

- IndexerPolicy::from_router_config resolves the frontend's shape rules:
  event-driven primary, event-driven plus a short-TTL predict-on-route side
  indexer when router_predicted_ttl_secs is set, approximate TTL primary when
  use_kv_events=false. Bookings (select_and_reserve, cached replay, explicit
  reservations with tokens or hashes) are recorded into the approximate
  indexer; query-only selects record nothing. Previously a service with
  use_kv_events=false had an empty index and no cache awareness.
- Indexer::Remote serves the primary index from a standalone indexer over
  HTTP (POST /query_tiered_by_hash returns lossless TieredMatchDetails). With a
  remote primary the core requires no kv_events endpoints and registers no ZMQ
  listeners. Exposed as SelectionServiceBuilder::remote_indexer,
  --remote-indexer-url, and remote_indexer_url= on the Python constructor.
- Router hints: catalog records carry router_hint_worker_type and per-rank
  source control endpoints; a booking retains the matched chain when the
  partition has a hint-capable worker and SelectResponse::router_hint names a
  same-role source that beats the target's own cached prefix.

Tests: backend policy matrix; approximate primary and side-indexer merge for 1
and 2 threads; bookings credited through all three paths; /query_tiered_by_hash
round trip; remote indexer against a live standalone indexer including offline
mapping; hint produced for a cold-worker booking and absent for warm-worker and
query-only selections.

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
@ishandhanani
ishandhanani force-pushed the idhanani/up-2-core-indexing branch from 56b3f2d to e7ef305 Compare September 9, 2026 18:30
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>

This branch had an error being deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant