[Feat][Router] Add load-balanced KV-aware routing strategy#884
[Feat][Router] Add load-balanced KV-aware routing strategy#884notTyche wants to merge 2 commits intovllm-project:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a sophisticated Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new load_balanced_kvaware routing strategy, which is a great addition for improving load distribution. The implementation correctly adds a load-balancing tier before falling back to the existing KV-aware logic. The new --imbalanced-threshold argument is well-documented and provides good control over the routing behavior. The unit tests are comprehensive and cover many edge cases.
My main feedback is on the significant code duplication between the new LoadBalancedKvawareRouter and the existing KvawareRouter. Refactoring this to use inheritance would greatly improve the code's maintainability and reduce redundancy. I've also included a suggestion to simplify one of the helper methods for better readability.
f9334a7 to
8bdb482
Compare
Signed-off-by: Matteo Perfidio <perfidiomatteo7@gmail.com>
8bdb482 to
0e74e54
Compare
|
Documentation for this new routing strategy can be added in a follow-up PR. Happy to create a tutorial similar to 17-kv-aware-routing.md |
ruizhang0101
left a comment
There was a problem hiding this comment.
Could you provide some benchmarking compare to the kv-aware routing?
Add
load_balanced_kvawarerouting strategyThe existing
kvawarerouter always routes based on KV cache locality (via LMCache), which can cause uneven load distribution when some replicas accumulate a large backlog while others sit idle. This PR introduces a newload_balanced_kvawarerouting strategy that adds a load-balance check as a first tier before the KV-aware lookup, ensuring that heavily overloaded replicas are relieved before cache locality is considered.How it works
LoadBalancedKvawareRouterinherits fromKvawareRouterand operates in three tiers:queue_length = num_running_requests + num_queuing_requestsfor each replica. Ifmax(queue_lengths) - min(queue_lengths) >= imbalanced_threshold, route immediately to the least-loaded replica.KvawareRouter.route_request()which performs the standard LMCache prefix lookup.The default value for
--imbalanced-thresholdisinfinity, which means the router behaves identically tokvawareunless the threshold is explicitly set.New CLI argument
--imbalanced-thresholdfloatinfExample usage
Helm values
Files changed
src/vllm_router/routers/routing_logic.pyLoadBalancedKvawareRouterclass inheriting fromKvawareRouter. Adds a load-balance tier and delegates KV-aware logic to the parent implementation. Registered ininitialize_routing_logic,get_routing_logic, andcleanup_routing_logic.src/vllm_router/parsers/parser.pyload_balanced_kvawareto--routing-logicchoices and introduced the--imbalanced-thresholdargument.src/vllm_router/app.pyimbalanced_thresholdduring router initialization.src/vllm_router/services/request_service/request.pyLoadBalancedKvawareRouterto the async routing and failover retryisinstancechecks.src/tests/test_load_balanced_kvaware_router.py_get_queue_length,_is_load_balanced,_route_to_least_loaded, and end-to-endroute_requestbehavior for load balancing and KV-aware fallback paths.