-
-
Notifications
You must be signed in to change notification settings - Fork 11k
[Bugfix] Flashinfer block size for hybrid ssm models #27843
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
base: main
Are you sure you want to change the base?
[Bugfix] Flashinfer block size for hybrid ssm models #27843
Conversation
Signed-off-by: Chen Zhang <[email protected]>
Signed-off-by: Chen Zhang <[email protected]>
|
This pull request has merge conflicts that must be resolved before it can be |
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.
Code Review
This pull request introduces a temporary fix for hybrid SSM models using the FlashInfer backend by hardcoding the block size to 32. This ensures that the model runner consistently uses the correct block size, addressing an issue where a different, unsupported block size might be used. The changes are consistent across config.py and flashinfer.py, correctly enforcing the block size of 32. My main feedback is a minor but important correction to a comment in flashinfer.py to avoid future confusion.
| self._workspace_buffer = None | ||
| self._prefill_wrapper = None # Wrapper for prefill/append | ||
| self._decode_wrapper = None # Wrapper for decode (general shape) | ||
| block_size = 32 # Note(Chen): Hardcode the block_size as 16 temporarily. |
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.
The comment here states that the block size is hardcoded to 16, but the value is set to 32. This seems to be a typo in the comment. To avoid confusion, the comment should be updated to reflect the actual value.
| block_size = 32 # Note(Chen): Hardcode the block_size as 16 temporarily. | |
| block_size = 32 # Note(Chen): Hardcode the block_size as 32 temporarily. |
…er_block_size Signed-off-by: Chen Zhang <[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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @staticmethod | ||
| def get_supported_kernel_block_size() -> list[int | MultipleOf]: | ||
| # Note: Not sure for all platforms, | ||
| # but on Blackwell, only support a page size of | ||
| # 16, 32, 64 | ||
| return [16, 32, 64] | ||
| # Note(Chen): FlashInfer backend supports other block_sizes. But as | ||
| # the backend doesn't know the block_size selected, we hardcode it as only | ||
| # supports 32 for now. | ||
| return [32] |
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.
Restricting FlashInfer to 32-token blocks breaks default configs
The backend now reports only 32 as a supported block size, but CUDA platforms still initialize cache_config.block_size to 16 by default. When a user runs any non-hybrid model with VLLM_ATTENTION_BACKEND=FLASHINFER, _find_compatible_block_sizes in the GPU model runner queries the backend and fails because 16 is not divisible by 32, raising `ValueError("No compatible block size for 16") before the model starts. This regression removes support for the common 16-token block size that previously worked. Either the backend needs to continue advertising 16 (and 64) or the default cache block size must be bumped to 32 when FlashInfer is selected.
Useful? React with 👍 / 👎.
Signed-off-by: Chen Zhang <[email protected]>
|
What GPU the test run from? |
| self._workspace_buffer = None | ||
| self._prefill_wrapper = None # Wrapper for prefill/append | ||
| self._decode_wrapper = None # Wrapper for decode (general shape) | ||
| block_size = 32 # Note(Chen): Hardcode the block_size as 32 temporarily. |
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 believe #27547 proposes a more universal approach: it reads the actual supported sizes instead of hard-coding them here. Otherwise, if someone changes FlashInferBackend.get_supported_kernel_block_size, they would have no way to know this file needs to be updated as well.
| # Note(Chen): FlashInfer backend supports other block_sizes. But as | ||
| # the backend doesn't know the block_size selected, we hardcode it as only | ||
| # supports 32 for now. | ||
| return [32] |
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 you have any evidence that something wrong with 64?
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.
No problem to 64. But we need to only allow one block_size here. Happy to change it to 64 if it is better.
Signed-off-by: Chen Zhang <[email protected]>
|
It's H100. |
|
let's iterate on #27547 |
Purpose
Hybrid SSM may use a block size that is different with
kv_cache_spec.block_sizewhen kv_cache_spec.block_size doesn't supported by an attention backend. However, we don't know the used block_size now. As a temporary solution, hardcode flashinfer's block_size to one value to make sure model runner always uses this block_size.Test Plan
Test Result
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.