[XPU] decouple split_kv_cache and block_attn#6489
Open
RuohengMa wants to merge 1 commit intoPaddlePaddle:developfrom
Open
[XPU] decouple split_kv_cache and block_attn#6489RuohengMa wants to merge 1 commit intoPaddlePaddle:developfrom
RuohengMa wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6489 +/- ##
==========================================
Coverage ? 68.75%
==========================================
Files ? 391
Lines ? 52809
Branches ? 8225
==========================================
Hits ? 36308
Misses ? 13856
Partials ? 2645
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mayang002
suggested changes
Feb 26, 2026
Comment on lines
+41
to
+55
| template <typename TC, typename TS> | ||
| struct SplitRopeTypeTrait { | ||
| using E_Scale = TS; | ||
| using D_Scale = TS; | ||
| }; | ||
| template <> | ||
| struct SplitRopeTypeTrait<bfloat16, bfloat16> { | ||
| using E_Scale = bfloat16; | ||
| using D_Scale = float; | ||
| }; | ||
| template <> | ||
| struct SplitRopeTypeTrait<int8_t, bfloat16> { | ||
| using E_Scale = bfloat16; | ||
| using D_Scale = bfloat16; | ||
| }; |
| self.rope_3d, | ||
| ) | ||
|
|
||
Comment on lines
+252
to
+281
| ''' | ||
| # q = q * k_scales_inv | ||
| if is_cache_int8 and has_zp: | ||
| if enc_batch > 0 and is_prefix_cache: | ||
| origin_shape = q_enc.shape | ||
| q_enc_reshaped = paddle.view( | ||
| q_enc, | ||
| [total_enc_len, kv_num_heads, num_heads // kv_num_heads, head_dim]) | ||
| q_enc_reshaped = q_enc_reshaped * paddle.view(k_scales_inv, [1, kv_num_heads, 1, head_dim]) | ||
| q_enc = paddle.view(q_enc_reshaped, origin_shape) | ||
|
|
||
| # q_enc_reshaped = paddle.reshape( | ||
| # q_enc, | ||
| # [total_enc_len, kv_num_heads, num_heads // kv_num_heads, head_dim]) | ||
| # q_enc_reshaped = q_enc_reshaped * paddle.reshape(k_scales_inv, [1, kv_num_heads, 1, head_dim]) | ||
| # q_enc = paddle.reshape(q_enc_reshaped, q_enc.shape) | ||
| if dec_batch > 0: | ||
| origin_shape = q_dec.shape | ||
| q_dec_reshaped = paddle.view( | ||
| q_dec, | ||
| [total_dec_len, kv_num_heads, num_heads // kv_num_heads, head_dim]) | ||
| q_dec_reshaped = q_dec_reshaped * paddle.view(k_scales_inv, [1, kv_num_heads, 1, head_dim]) | ||
| q_dec = paddle.view(q_dec_reshaped, origin_shape) | ||
|
|
||
| # q_dec_reshaped = paddle.reshape( | ||
| # q_dec, | ||
| # [total_dec_len, kv_num_heads, num_heads // kv_num_heads, head_dim]) | ||
| # q_dec_reshaped = q_dec_reshaped * paddle.reshape(k_scales_inv, [1, kv_num_heads, 1, head_dim]) | ||
| # q_dec = paddle.reshape(q_dec_reshaped, q_dec.shape) | ||
| ''' |
| # if shift: | ||
| # out[total_enc_len:, :] = out[total_enc_len:, :] + shift | ||
| # if smooth: | ||
| # out[total_enc_len:, :] = out[total_enc_len:, :] * smooth |
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
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.
Motivation
decouple split_kv_cache and block_attn
Modifications
decouple split_kv_cache and block_attn
Usage or Command
decouple split_kv_cache and block_attn
Accuracy Tests
None
Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.