-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Feature] Sage Attention Support Varlen & write kv cache BF16/FP16 #10360
Draft
l1cacheDell
wants to merge
49
commits into
PaddlePaddle:develop
Choose a base branch
from
l1cacheDell:write_kv16_varlen
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,240
−440
Conversation
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
Thanks for your contribution! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #10360 +/- ##
===========================================
- Coverage 49.09% 49.05% -0.05%
===========================================
Files 763 764 +1
Lines 125659 125767 +108
===========================================
+ Hits 61688 61689 +1
- Misses 63971 64078 +107 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
PR types
New features
PR changes
APIs
Description
1. write kv cache (BF16/FP16) with RoPE integration
This PR add new feature with Sage Attention and integrating with write kv cache kernels, offering flexible cpp operator API like append attention, easy to use.
2. Varlen support, allow different seqlens in a single batch!
This PR also add varlen support for different sequence length in a single batch processing. The key solution is to enlarge the
gridDim
(The amount of blocks when launching) to[max_seqlen, num_heads, bsz]
, wheremax_seqlen
is the longest sequence length in this batch.In kernel implementation, we allow the rest threads in the same blocks (processing the edge of a sequence) executing to avoid accuracy loss (which will introduce a bit extra latency, but it's necessary). Return and end up the kernel processing when the
thread_base_token
exceeds the current sequence length.Due to the Sage Attention kernel implementation, we need to support varlen feature not only for attn forward kernels, but also for quantization kernels (quant qk, quant_transpose_permute v kernels), which takes extra developing & debugging time more than estimated.