-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Router][Feat] Add semantic cache to the vLLM router #202
Conversation
The demo is here. In this demo, the backend is ollama running phi4 model. In the console, the top pane is vllm_router, the bottom pane is the test program (included in this PR). One the first run, the test time used 15s, the 2nd run took less than 1s. @YuhanLiu11 @Hanchenli @ApostaC PTAL, thanks |
src/vllm_router/router.py
Outdated
@@ -354,101 +397,17 @@ async def route_cancel_batch(batch_id: str): | |||
) | |||
|
|||
|
|||
@app.post("/v1/batches") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to the complete file here
production-stack/src/vllm_router/router.py
Line 307 in b9b4134
@app.post("/v1/batches") |
These functions are not deleted, the diff is very weird.
987e57a
to
18547f2
Compare
Signed-off-by: Huamin Chen <[email protected]>
@YuhanLiu11 fixed the pre-commit issue, can you run the CI again? Thanks |
Thanks! Rerunning it now |
Signed-off-by: Huamin Chen <[email protected]>
@YuhanLiu11 @ApostaC router.py changes reverted in this PR. The complete change can be found in another branch |
Signed-off-by: Huamin Chen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the contribution!
[Router][Feat] Add semantic cache to the vLLM router
This PR adds a semantic caching feature to the vLLM router, allowing it to cache LLM responses based on the semantic similarity of requests. When a new request comes in, the cache checks if there's a semantically similar request already in the cache. If a match is found, the cached response is returned instead of routing the request to a backend LLM service.
The semantic cache is implemented as an experimental feature under a feature gate, so it's disabled by default and must be explicitly enabled.
Features:
Usage:
To enable the semantic cache:
Clients can control caching behavior with these parameters:
skip_cache
: Set totrue
to bypass the cache for a specific requestcache_similarity_threshold
: Override the default similarity threshold for a specific requestMake sure the code changes pass the pre-commit checks.
Sign-off your commit by using
-s
when doinggit commit
Try to classify PRs for easy understanding of the type of changes, such as
[Bugfix]
,[Feat]
, and[CI]
.Detailed Checklist (Click to Expand)
Thank you for your contribution to production-stack! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Feat]
for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).[Router]
for changes to thevllm_router
(e.g., routing algorithm, router observability, etc.).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
pre-commit
to format your code. SeeREADME.md
for installation.DCO and Signed-off-by
When contributing changes to this project, you must agree to the DCO. Commits must include a
Signed-off-by:
header which certifies agreement with the terms of the DCO.Using
-s
withgit commit
will automatically add this header.What to Expect for the Reviews
We aim to address all PRs in a timely manner. If no one reviews your PR within 5 days, please @-mention one of YuhanLiu11
, Shaoting-Feng or ApostaC.