-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[Bugfix / Core] Prefix Caching Guards (merged with main) #4846
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
56680e7
added guards for prefix-caching. added ability to disable sliding window
robertgshaw2-neuralmagic 64aac2e
format.sh
robertgshaw2-neuralmagic 28ae0cc
added tests
robertgshaw2-neuralmagic 2a01ae6
Merge remote-tracking branch 'upstream/main' into prefix-caching-guards
robertgshaw2-neuralmagic cd0f666
merge
robertgshaw2-neuralmagic f30c3de
removed images
robertgshaw2-neuralmagic da5a982
fixed bad merge
robertgshaw2-neuralmagic 8502b6a
./format
robertgshaw2-neuralmagic 1bef541
validated that prefix caching working on turing with recent update
robertgshaw2-neuralmagic 6620e53
Merge branch 'main' into prefix-caching-guards
zhuohan123 8efc774
Merge branch 'main' into prefix-caching-guards-new
robertgshaw2-neuralmagic 033c2c5
updated to remove sliding window usage in models
robertgshaw2-neuralmagic 0638960
removed spurious changes
robertgshaw2-neuralmagic 63c0097
revert change to make PR easier to read
robertgshaw2-neuralmagic 4a3630c
more cleanup
robertgshaw2-neuralmagic 3f73426
more cleanup
robertgshaw2-neuralmagic 6f754c3
stash
robertgshaw2-neuralmagic a497b7b
cleanup prints and comments to match current for easier review
robertgshaw2-neuralmagic 9fd64fe
more cleanup for PR readibility
robertgshaw2-neuralmagic 1126c5a
more cleanup for PR readibility
robertgshaw2-neuralmagic 8a53180
more cleanup for PR readibility
robertgshaw2-neuralmagic 034bbde
removed from mixtral, need to fix qwen
robertgshaw2-neuralmagic b56352b
updated models to remove sliding window. Big update to qwen to preven…
robertgshaw2-neuralmagic 8225c3f
format
robertgshaw2-neuralmagic 13797c1
added test and fixed requirements dev
robertgshaw2-neuralmagic 37efe98
added test
robertgshaw2-neuralmagic 7b186c2
format
robertgshaw2-neuralmagic 93bce37
updated comment
robertgshaw2-neuralmagic 7c8a9d0
updated test
robertgshaw2-neuralmagic 4285763
format
robertgshaw2-neuralmagic 84253fd
fixed logging
robertgshaw2-neuralmagic 7a61f51
Update test_disable_sliding_window.py
robertgshaw2-neuralmagic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Compare the with and without prefix caching. | ||
|
||
Run `pytest tests/prefix_caching/test_prefix_caching.py`. | ||
""" | ||
import pytest | ||
|
||
from tests.conftest import cleanup | ||
from vllm import LLM | ||
|
||
MODEL_LEN_LEN = [ | ||
# Example models with sliding window. | ||
("bigcode/starcoder2-3b", 4096, 16384), | ||
# ("mistralai/Mistral-7B-v0.1", 4096, 32768), << OOM in CI | ||
|
||
# Confirm model with sliding window works. | ||
# config has "use_sliding_window": false | ||
("Qwen/Qwen1.5-0.5B-Chat", 32768, 32768), | ||
# config has no sliding window attribute. | ||
("TinyLlama/TinyLlama-1.1B-Chat-v1.0", 2048, 2048), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("model_len_len", MODEL_LEN_LEN) | ||
def test_disable_sliding_window(model_len_len, ): | ||
model, sliding_len, full_len = model_len_len | ||
vllm_disabled_model = LLM(model, disable_sliding_window=True) | ||
vllm_disabled_model.generate("Hi my name is") | ||
model_config = vllm_disabled_model.llm_engine.model_config | ||
assert model_config.max_model_len == sliding_len, ( | ||
"Max len expected to equal sliding_len of %s, but got %s", sliding_len, | ||
model_config.max_model_len) | ||
|
||
del vllm_disabled_model | ||
cleanup() | ||
|
||
vllm_enabled_model = LLM(model, disable_sliding_window=False) | ||
vllm_enabled_model.generate("Hi my name is") | ||
model_config = vllm_enabled_model.llm_engine.model_config | ||
assert model_config.max_model_len == full_len, ( | ||
"Max len expected to equal full_len of %s, but got %s", full_len, | ||
model_config.max_model_len) | ||
|
||
del vllm_enabled_model | ||
cleanup() |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
How does it work for the model that already has sliding window like mistral?
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.
Im not sure what you mean?
If the user does not specify
--disable-sliding-window
then we use sliding window if the model supports itThere 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.
oh maybe it is a dumb question, but my question is for models that has slinding window by default https://huggingface.co/mistralai/Mistral-7B-v0.1/blob/26bca36bde8333b5d7f72e9ed20ccda6a618af24/config.json#L18, if we use --disable-sliding-window, does it work properly?
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.
Yes, specifically what this does is handle a case like Mistral.
--disable-sliding-window
means we turn off sliding window and setmax_model_len=sliding_window
So in the case of Mistral, we then would treat the model as a 4096 ctx-len model with no sliding window.
The reason for this feature is that if we want to use features that are incompatible with sliding window (e.g. APC or chunked prefill), then there is a pathway to disable sliding window
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.
I see. that makes sense! Thanks for the explanation