-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
[v1][core] Support for attention free models #20811
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
Merged
heheda12345
merged 10 commits into
vllm-project:main
from
christian-pinto:attention_free_models_support
Jul 15, 2025
+33
−3
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b764c9d
Support for attention free models
christian-pinto 5825ba4
is_kv_cache_type_attention_free: return False if not attention free
christian-pinto fc86350
some minor edits after first review round
christian-pinto 97c11e6
Rebase to current master
christian-pinto 673aeb0
Make pre-commits pass
christian-pinto fb3ecfb
Disable chunk prefill and prefix caching when model is attention free
christian-pinto 8e5dbee
reworked to allow for models like mamba to use the kv_cache for state…
christian-pinto 2ee7087
cleanup config.py
christian-pinto 19a7d70
cleanup gpu_worker.py
christian-pinto b8f355e
Edits after review
christian-pinto 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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ def __init__( | |
self.prefix_cache_stats = PrefixCacheStats() if log_stats else None | ||
|
||
self.block_size: Optional[int] = None | ||
if self.enable_caching: | ||
if self.enable_caching and len(kv_cache_config.kv_cache_groups) > 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above. Don’t need if enable_caching is false for attention free models. |
||
assert len( | ||
set(g.kv_cache_spec.block_size | ||
for g in kv_cache_config.kv_cache_groups) | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,6 +209,9 @@ def determine_available_memory(self) -> int: | |
You may limit the usage of GPU memory | ||
by adjusting the `gpu_memory_utilization` parameter. | ||
""" | ||
if self.vllm_config.model_config.is_attention_free: | ||
return 0 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this? |
||
torch.cuda.empty_cache() | ||
torch.cuda.reset_peak_memory_stats() | ||
GiB = lambda b: b / GiB_bytes | ||
|
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.
Do we need this given prefix caching is disabled here for models that don’t use last pooling method?
https://github.com/maxdebayser/vllm/blob/221f013922c0c118b682d294755e69990b2c43ed/vllm/config.py#L4505
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.
Without this check though you would not be able to disable attention for models that are not of the pooling type as prefix caching is enabled by default for all models except pooling ones.
See below:
vllm/vllm/engine/arg_utils.py
Lines 1620 to 1630 in 38efa28
Uh oh!
There was an error while loading. Please reload this page.
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.
Perhaps the safest thing to do is to disable prefix-caching in
VllmConfig.__post_init__
right away for any attention free models and then yes, we could just rely onenable_caching
as you suggest.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.
remove this comment?