fix(router): seed clean peers under cache-owner pressure - #63
Merged
Conversation
Signed-off-by: David <12414531+DavidBellamy@users.noreply.github.com>
Signed-off-by: David <12414531+DavidBellamy@users.noreply.github.com>
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.
Description
Problem
Cache-aware routing can concentrate a shared-prefix workload on one cached owner while healthy workers retain capacity. In the observed Kimi K3 incident, one public worker held 38 running and 64-102 waiting requests while almost every peer was idle. Aggregate engine-feedback admission then rejected new work before worker selection, so the fleet could not seed a clean peer and recover.
Solution
Add a default-off, partition-allowlisted distribution-headroom path that remains subordinate to fair-share scheduling. A request may seed one exact clean worker only after claiming the redeemed capacity credit's one-shot scheduler admission proof. Selection is bound to the worker identity and revision, reverified before dispatch, capped at one in-flight seed per partition, and fails closed on stale or incomplete telemetry.
Cache-aware routing continues to prefer an authoritative owner with headroom. Only when every eligible owner is full may it select one clean peer. Provisional ownership is serialized by prefix and is never published as committed ownership before a successful non-streaming backend response. Failures quarantine matching descendants for the configured cooldown; success enters a cooldown that prevents another concurrent expansion.
This PR stacks on the merged work-conserving capacity-credit contract from #60 and the worker-activation capacity fix from #57.
This first release is limited to the regular gRPC worker-selection pipeline and assumes one active SMG process. HTTP routing, PD/EPD routing, streaming requests, and backend fanout do not use distribution seeding and retain their existing behavior or fail closed.
Closes #61
Changes
Test Plan
Reproduce the recovery scenario with two cache-aware workers: make worker A the authoritative prefix owner and fill it to its feedback limit while worker B remains clean and has headroom. Redeem one fair-share capacity credit for the exact request/model/partition, then verify that one request seeds B, a second seed is rejected at the cap, and ordinary requests cannot join B until terminal success commits ownership. Repeat with incomplete/stale telemetry, a replaced worker revision, a replayed proof, streaming/fanout input, backend failure after an early KV event, and concurrent ordinary-spill/seed acquisition; each must fail closed or preserve one-winner serialization.
Validation run on exact PR head:
The broader
cargo test --offline --workspacegate reaches eight pre-existing compile errors in unchanged protocol-builder tests (ChatChoice,ChatCompletionMessage,ChatMessageDelta, andChatStreamChoiceinitializers omit the existingotherfield). This PR changes no protocol or workspace manifest file. The changed SMG library and Python binding suites above are green. Full-tree Ruff formatting likewise reports one unchanged prod issue intest_router_config.py; both Python files changed by this PR pass Ruff formatting individually.GitHub CodeQL for Actions, Go, Python, and Rust, plus title/commit-message validation, pass on exact head
aa51d482c9ca8af8c09967f98378260545c214cc.Checklist
cargo +nightly fmtpassescargo clippy --all-targets --all-features -- -D warningsis blocked by documented pre-existing prod lints and the local OpenCV dependency; the changed package passes strict lib Clippy and all-target Clippy with only unchanged-prod lint categories allowed