forked from Dao-AILab/flash-attention
-
Notifications
You must be signed in to change notification settings - Fork 102
varlen combine scheduler #70
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
Conversation
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
4 tasks
tlrmchlsmth
reviewed
Jun 11, 2025
tlrmchlsmth
reviewed
Jun 11, 2025
tlrmchlsmth
approved these changes
Jun 16, 2025
Member
tlrmchlsmth
left a comment
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 looks good to me. Optimization makes sense. Nice work.
Should we try to push this upstream?
Collaborator
Author
|
Ya I'm going to make an upstream PR |
Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
Co-authored-by: Tyler Michael Smith <tysmith@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com>
604050e to
566d676
Compare
zyongye
pushed a commit
to zyongye/flash-attention
that referenced
this pull request
Aug 7, 2025
* varlen combine scheduler Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * move check Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * standard scheduling algo Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * better heuristic Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * better comments Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * put in a more readable heurisitic Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * Apply suggestions from code review Co-authored-by: Tyler Michael Smith <tysmith@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * FA2 8.0 PTX (vllm-project#69) Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> --------- Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Co-authored-by: Tyler Michael Smith <tysmith@redhat.com>
LucasWilkinson
added a commit
that referenced
this pull request
Aug 7, 2025
* varlen combine scheduler Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * move check Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * standard scheduling algo Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * better heuristic Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * better comments Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * put in a more readable heurisitic Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * Apply suggestions from code review Co-authored-by: Tyler Michael Smith <tysmith@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * FA2 8.0 PTX (#69) Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> --------- Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Co-authored-by: Tyler Michael Smith <tysmith@redhat.com>
jayhshah
pushed a commit
that referenced
this pull request
Aug 8, 2025
* varlen combine scheduler Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * move check Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * standard scheduling algo Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * better heuristic Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * better comments Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * cleanup Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * put in a more readable heurisitic Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * Apply suggestions from code review Co-authored-by: Tyler Michael Smith <tysmith@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> * FA2 8.0 PTX (#69) Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> --------- Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Co-authored-by: Tyler Michael Smith <tysmith@redhat.com> Signed-off-by: Jay Shah <jayhshah@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Improvement to address: vllm-project/vllm#18619 (comment)
When running the combine with large batch that is almost entirely decode with 1 prefill the previous grid was excessively large making the combine kernel take a long time.
Before this PR the grid size for combine would be
cdiv(max_seqlen_q * num_heads, kBlockM) x batch_sizeafter this PR its(cdiv(total_q * num_heads, kBlockM) + batch_size) x 1which scales much better for large batches that are primarily made up of decodes.e.g. if we have a batch of 256 where the q_seqlens are [600] + [1] * 255, (assuming num_heads 8 and kBlockM 8)
before this PR the grid would be:
cdiv(600 * 8, 8) x 256 = 153600after this PR the grid is:
cdiv(855 * 8, 8) + 256 x 1 = 1111