-
-
Notifications
You must be signed in to change notification settings - Fork 20.3k
[BUGFIX][Mamba][Qwen3.5] Zero freed SSM cache blocks on GPU #35219
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
Merged
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
4ea0189
workaround
vadiklyutiy 152ccc2
zeroing kv-cache block after allocation
vadiklyutiy 27ab3fa
Merge branch 'main' into vadim/issue35138
vadiklyutiy af817b7
optimize
vadiklyutiy 053d305
make a bit better code
vadiklyutiy 3fc05cd
Merge branch 'main' into vadim/issue35138
vadiklyutiy 13271d9
fixes
vadiklyutiy 3654a39
fixes
vadiklyutiy a507809
Merge branch 'main' into vadim/issue35138
vadiklyutiy 59fcf43
zeroing only full attn
vadiklyutiy 0dd399a
Merge branch 'main' into vadim/issue35138
vadiklyutiy 888e947
fix
vadiklyutiy 387cf77
fix
vadiklyutiy 72d4aaf
fix bugs
vadiklyutiy 3115077
fix pin memory
vadiklyutiy 61e6b3c
fix cumem bug
vadiklyutiy 56ae39a
code style
vadiklyutiy 6e91a13
limit to hybrid model only
vadiklyutiy 624fdea
Merge branch 'main' into vadim/issue35138
vadiklyutiy e26d486
pre-commit fix
vadiklyutiy a000a63
Merge branch 'main' into vadim/issue35138
vadiklyutiy 2fea792
Merge branch 'main' into vadim/issue35138
vadiklyutiy 267646a
revert workaround for pre-commit in hermes_tool_parser.py
vadiklyutiy 61feb0c
move finding of block dim to attn backend
vadiklyutiy 9c92ec2
resolve PR comment
vadiklyutiy 145c7fa
move zeroing from vllm/utils/math_utils.py to vllm/v1/worker/utils.py
vadiklyutiy 67fcd34
call _init_kv_zero_meta for model with mamba
vadiklyutiy 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
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
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.
Would it be more efficient to build an index tensor and have one op to zero at all the block id slots?
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 many block ids would we normally see for a typical prefill/decode? Is it very few?
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.
This zeroing takes small amount of time. We do it once per forward step and only for new.
@benchislett Can you say right away does it code works in sync or async part?
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.
It happens always.
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 notice that this is not specific to SSM blocks, and it clears all new KV blocks. Will this have a detrimental effect on prefills for non-mamba deployments where block_size=16?
In this case if we get a prefill of 8k tokens, that will be 512 new blocks, right? I think that would lead to 512 kernel invocations in this implementation. If that is indeed the case, this will not suffice.
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.
right,
I am optimizing it
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.
does it make sense to use torch.tensor for block ids and use a gpu operation to zero the indices in tensors?
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.
See my comment below
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 implemented zeroing as a triton kernel
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.
Pls lets me know if there is a better way to do it