-
Notifications
You must be signed in to change notification settings - Fork 660
[Optimization] Skip memcpy(DtoH) capture in get_block_shape_and_split_kv_block #4988
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
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
|
Thanks for your contribution! |
zhoutianzi666
approved these changes
Nov 13, 2025
Comment on lines
+291
to
+296
| // Note (sunxin): Skip capturing the DtoH copy (it's time-consuming); CPU data | ||
| // is only for branching in attention. | ||
| if (!phi::backends::gpu::IsCUDAGraphCapturing()) { | ||
| max_len_tensor_cpu.copy_( | ||
| max_len_tensor_gpu, max_len_tensor_cpu.place(), false); | ||
| } |
Collaborator
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.
这个工作会生效吗
Collaborator
Author
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.
5 tasks
StareAtYou
added a commit
to StareAtYou/FastDeploy
that referenced
this pull request
Nov 13, 2025
5 tasks
Sunny-bot1
added a commit
to Sunny-bot1/FastDeploy
that referenced
this pull request
Nov 14, 2025
This reverts commit 5b24013.
yuanlehome
pushed a commit
that referenced
this pull request
Nov 14, 2025
StareAtYou
added a commit
to StareAtYou/FastDeploy
that referenced
this pull request
Nov 14, 2025
Jiang-Jia-Jun
pushed a commit
that referenced
this pull request
Nov 18, 2025
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
Memcpy (DtoH) is time-consuming. The CPU data in get_block_shape_and_split_kv_block's outputs is only used for branching in attention, which is not executed in the CUDA graph. Therefore, we skip capturing memcpy ops to avoid executing them in the CUDA graph.
Modifications
execute
copy_only ifphi::backends::gpu::IsCUDAGraphCapturing()is false in get_block_shape_and_split_kv_block decoder branch.Usage or Command
pass
Accuracy Tests
pass
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.