Skip to content

feat(kv-router): LoRA-aware candidate narrowing in SelectionService - #10

Closed
ishandhanani wants to merge 1 commit into
idhanani/p0-selection-shared-cache-sessionfrom
idhanani/p0-selection-lora-filter
Closed

ishandhanani wants to merge 1 commit into
idhanani/p0-selection-shared-cache-sessionfrom
idhanani/p0-selection-lora-filter

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Phase 0 (selection-core parity), item 2b. Stacked on #9.

Summary

  • New scheduling/lora_filter.rs: LoraWorkerFilter trait (host-owned "which workers can serve adapter X") and a pure narrow_allowed_worker_ids_by_lora helper that is a line-for-line port of KvRouter::narrow_allowed_by_lora (lib/llm/src/kv_router.rs:1216-1251): never widens the caller's allowed_worker_ids, retains an in-universe pin even if the filter dropped it, and falls back to the caller's set when the narrowing is empty.
  • SelectionHostHooks::lora_worker_filter: Option<Arc<dyn LoraWorkerFilter>>; schedule_selection applies it before building the ScheduleRequest. The universe when no allow-set is given is the partition's schedulable workers (new WorkerCatalog::schedulable_worker_ids_for_key, avoids cloning configs).
  • Exported as dynamo_kv_router::LoraWorkerFilter so lib/llm's LoraFilter can implement it during the Phase 1 re-host; the frontend can then call the same helper and delete its private copy.
  • No hook: no behavior change.

Validation

  • cargo test -p dynamo-kv-router --features standalone-selection --lib -- services::selection scheduling::lora_filter: 73 passed (4 new pure-helper tests, 1 new core test covering LoRA steering, allow-set preservation, pin retention).
  • cargo clippy -p dynamo-kv-router --all-targets with and without standalone-selection: only the pre-existing registry.rs dead-code warning.
  • cargo check -p dynamo-llm: clean (new crate-root export does not collide).

Port the frontend KvRouter's narrow_allowed_by_lora into a runtime-free
LoraWorkerFilter trait plus a pure narrow_allowed_worker_ids_by_lora helper in
lib/kv-router/src/scheduling, and apply it in SelectionCore::schedule_selection
through a new SelectionHostHooks::lora_worker_filter hook.

Semantics match the frontend exactly: the universe is the caller's
allowed_worker_ids (else every schedulable worker in the partition), the
filter never widens it, a pinned worker inside the universe survives the
filter, and an empty narrowing falls back to the caller's set.

Without an injected filter behavior is unchanged. The frontend's LoraFilter
implements the trait in the Phase 1 re-host.

Tests: pure helper matrix in lora_filter.rs; core test proves the injected
filter steers selection, respects allow-sets, and retains pins.

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

Copy link
Copy Markdown
Owner Author

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

This branch had an error being deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant