Skip to content

feat(kv-router): router hints from the selection service - #16

Closed
ishandhanani wants to merge 1 commit into
idhanani/p0-selection-remote-indexerfrom
idhanani/p0-selection-router-hint
Closed

ishandhanani wants to merge 1 commit into
idhanani/p0-selection-remote-indexerfrom
idhanani/p0-selection-router-hint

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Phase 0 (selection-core parity), item 2c: the router-hint chain (core/mod.rs:772-773 on main hardcoded router_hint_candidates: None, retain_router_hint_chain: false). Stacked on #15. This completes the Phase 0 list from the roadmap.

Summary

  • Catalog schema (contract 4 surface): router_hint_worker_type: Option<String> and router_hint_source_control_endpoints: HashMap<u32, String> on WorkerRequest, WorkerPatchRequest, WorkerCatalogRecord, and SelectionWorkerConfig. SelectionWorkerConfig implements WorkerConfigLike::router_hint_metadata_for_dp_rank from them, which is what ModelRuntimeConfig derives from runtime_data (router_hint capability flag + router_hint_worker_type + router_hint_source_control_endpoints, lib/llm/src/local_model/runtime_config.rs:451). Presence of a non-empty worker type is the capability.
  • Indexer: Indexer::find_tiered_matches_with_options(sequence, LowerTierQueryOptions); find_tiered_matches delegates. Retention is honored only when supports_router_hint_chain_retention() (local event-driven primary, no side indexer, not remote), same rule as the frontend Indexer::supports_router_hint_chain_retention.
  • Core: retain_router_hint_chain = book && indexer.supports_router_hint_chain_retention() && catalog.has_router_hint_capable_workers(key); candidates flow through ScheduleRequest and back via SchedulingResponse.router_hint_candidates; router_hint_for_selection is a port of KvRouter::router_hint_for_selection (lib/llm/src/kv_router.rs:1022) over SelectionWorkerConfig, including the cache-owner branch through RouterHintRootCandidates.routing_snapshot. Result lands on SelectResponse.router_hint: Option<RouterHint> (serde RouterHint from router_hint.rs).
  • Not ported: the frontend also excludes sources with kv_event_source_mode == "state_agent_v2"; the catalog has no such field yet. Noted in the commit.
  • Docs: registration fields and the router_hint response field in standalone-selection.md.

Validation

  • cargo test -p dynamo-kv-router --features standalone-selection --lib: 1069 passed. New: booked_selection_attaches_router_hint_from_a_better_source (event-driven indexer, two hint-capable workers, worker 1 holds a 2-block prefix; a booking pinned to worker 2 gets source_control_endpoint == tcp://worker-1:9000 and 2 block hashes; a booking on worker 1 and a query-only select get none), router_hint_needs_capable_workers.
  • cargo clippy --features standalone-selection --all-targets: only the pre-existing registry.rs dead-code warning. cargo fmt and docs_lint.py clean.
  • Python bindings pass worker records as JSON (new fields are serde(default)), so no bindings change.

Port the frontend KvRouter router-hint chain into the selection service so a
booked selection can tell the chosen worker which same-role peer holds a
longer cached prefix and where to fetch it from.

- Catalog records carry router_hint_worker_type and per-global-DP-rank
  router_hint_source_control_endpoints (WorkerRequest, WorkerPatchRequest,
  WorkerCatalogRecord, SelectionWorkerConfig), and SelectionWorkerConfig
  implements WorkerConfigLike::router_hint_metadata_for_dp_rank on them. The
  frontend derives the same two facts from the runtime_data capability flag,
  worker type key, and endpoints map.
- Indexer::find_tiered_matches_with_options honors
  LowerTierQueryOptions::retain_router_hint_chain on a local event-driven
  primary and ignores it elsewhere (approximate writes and remote primaries
  cannot retain the matched chain).
- SelectionCore retains the chain for bookings when the partition has a
  hint-capable schedulable worker, passes router_hint_candidates to the
  scheduler, and builds SelectResponse::router_hint with a port of
  router_hint_for_selection: a same-role source (worker or cache owner) that
  beats the target's own cached prefix and advertises a control endpoint.
  Query-only selections never carry a hint.

Not ported: the frontend's exclusion of kv_event_source_mode=state_agent_v2
sources; the catalog record has no such field yet.

Tests: two hint-capable workers, a booking on the cold worker receives a hint
naming the warm worker's endpoint and both block hashes; a booking on the warm
worker and a query-only select do not; workers without hint metadata never
produce one.

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
@ishandhanani

Copy link
Copy Markdown
Owner Author

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

This branch had an error being deployed

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