Repository navigation
feat(kv-router): wire shared-cache hits and full session context into selection - #9
Closed
ishandhanani wants to merge 1 commit into
Conversation
… selection Two frontend scheduler inputs the SelectionService hardcoded away: - shared_cache_hits was always None. SelectionHostHooks gains an optional SharedKvCache; prepare_selection_inputs queries it concurrently with the indexer for prompts that carry raw token_ids and passes the hits into ScheduleRequest, so the built-in scorer's shared-beyond-device credit and custom policies see the same signal the frontend KvRouter provides. Load projection (potential_loads) does not consult it. - session_context only carried session_id. Both select requests accept a structured session_context object (parent_session_id, session_final, kv_hints, input_trigger) mirroring the frontend's AgentContext mapping; the flat session_id remains as the legacy form and loses to the object. Tests: a recording SharedKvCache plus a capturing picker prove the hits and every session field reach worker selection; wire deserialization and legacy fallback are covered in types.rs. Signed-off-by: Ishan Dhanani <[email protected]>
ishandhanani
had a problem deploying
to
external_collaborator
September 3, 2026 06:16 — with
GitHub Actions
Failure
Owner
Author
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 0 (selection-core parity), item 2a. Stacked on #8.
Summary
Closes two of the
ScheduleRequestgaps inSelectionCore::schedule_selectionwhere the frontendKvRoutersupplies a signal and the selection service hardcoded it away:shared_cache_hits: None(core/mod.rs:786on main).SelectionHostHooksgainsshared_cache: Option<Arc<dyn SharedKvCache>>.prepare_selection_inputsruns the shared-cache lookup concurrently with the indexer lookup (same shape aslib/llm/src/kv_router/route_lookup.rs::join_indexer_and_shared_cache), only for prompts that carry rawtoken_ids, and a failed lookup is logged and ignored.potential_loadsdoes not consult it.SessionContext::new(session_id, None, None, None, None)(core/mod.rs:779-780). BothSelectRequestandSelectAndReserveRequestaccept a structuredsession_contextobject (session_id,parent_session_id,session_final,kv_hints.evict_session,input_trigger) that maps 1:1 onto the frontend'sto_worker_selection_session_context(lib/llm/src/kv_router.rs:259). The flatsession_idstays as the legacy form; the object wins when both are present. TheFromimpl destructures exhaustively so a new field fails to compile until mapped.Documented in
standalone-selection.md. Still open from item 2: LoRA narrowing (2b) and the router-hint chain (2c).Validation
cargo test -p dynamo-kv-router --features standalone-selection --lib services::selection: 68 passed. New tests:shared_cache_hits_reach_worker_selection(recordingSharedKvCache+ capturingWorkerPickerasserts the call args, thatshared_beyond_device_blocks == 1reaches the policy, thatpotential_loadsand hash-only prompts do not query it),session_context_reaches_worker_selection(all five fields observed by the picker, legacysession_idfallback), and two wire-deserialization tests intypes.rs.cargo clippy --features standalone-selection --all-targets: only the pre-existingregistry.rsdead-code warning.cargo fmtclean.python3 docs/fern/scripts/docs_lint.pyclean.