-
Notifications
You must be signed in to change notification settings - Fork 209
【WIP】feat: onerec xattn npu multistream. #1453
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
Draft
DragonFive
wants to merge
6
commits into
jd-opensource:main
Choose a base branch
from
DragonFive:feat/onerec-xattn-npu-multistream
base: main
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.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e757d97
feat: add npu onerec xattention multistream pipeline.
DragonFive 3dc61f3
feat: support onerec xattention npu scheduler multistream.
DragonFive 7f8a839
bugfix: address onerec multistream review comments.
DragonFive a9ce548
perf: add onerec xattention lock experiment switch.
DragonFive b41ffe2
perf: split onerec xattention host lock switches.
DragonFive 3a05cf4
perf: improve onerec xattention multistream parity.
DragonFive File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Submodule xllm_atb_layers
updated
from 49e2cf to 3555e2
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ limitations under the License. | |
| #include <c10/core/Device.h> | ||
| #include <glog/logging.h> | ||
| #include <torch/torch.h> | ||
| #include <torch_npu/csrc/core/npu/NPUCachingAllocator.h> | ||
| #include <torch_npu/csrc/libs/init_npu.h> | ||
| #include <torch_npu/torch_npu.h> | ||
|
|
||
|
|
@@ -178,7 +179,8 @@ void beam_search_rec(const torch::Tensor& logprobs, | |
| aclTensor* out_beam_count_prefix_sums_ids = nullptr; | ||
| aclTensor* out_sequence_ids = nullptr; | ||
| int32_t device_id = logprobs.device().index(); | ||
| aclrtStream stream = c10_npu::getCurrentNPUStream(device_id).stream(); | ||
| c10_npu::NPUStream npu_stream = c10_npu::getCurrentNPUStream(device_id); | ||
| aclrtStream stream = npu_stream.stream(); | ||
|
|
||
| create_acltensor(&logprobs_ids, logprobs); | ||
| create_acltensor(&top_tokens_ids, top_tokens); | ||
|
|
@@ -209,17 +211,18 @@ void beam_search_rec(const torch::Tensor& logprobs, | |
| &executor), | ||
| "beam_search_rec: failed to get workspace size for REC beam search"); | ||
| void* workspace_addr = nullptr; | ||
| torch::Tensor workspace_tensor; | ||
| if (workspace_size > 0) { | ||
| CHECK_ACL_SUCCESS( | ||
| aclrtMalloc(&workspace_addr, workspace_size, ACL_MEM_MALLOC_HUGE_FIRST), | ||
| "beam_search_rec: failed to allocate workspace for REC beam search"); | ||
| workspace_tensor = torch::empty( | ||
| {static_cast<int64_t>(workspace_size)}, | ||
| torch::TensorOptions().dtype(torch::kUInt8).device(logprobs.device())); | ||
| workspace_addr = workspace_tensor.data_ptr(); | ||
| c10_npu::NPUCachingAllocator::recordStream( | ||
| workspace_tensor.storage().data_ptr(), npu_stream); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's this means for workspace_tensor and npu_stream in recordstream? |
||
| } | ||
| CHECK_ACL_SUCCESS( | ||
| aclnnBeamSearchGroup(workspace_addr, workspace_size, executor, stream), | ||
| "beam_search_rec: failed to execute REC beam search"); | ||
| CHECK_ACL_SUCCESS( | ||
| aclrtSynchronizeStream(stream), | ||
| "beam_search_rec: failed to synchronize stream for REC beam search"); | ||
| aclDestroyTensor(logprobs_ids); | ||
| aclDestroyTensor(top_tokens_ids); | ||
| aclDestroyTensor(top_logprobs_ids); | ||
|
|
@@ -229,11 +232,6 @@ void beam_search_rec(const torch::Tensor& logprobs, | |
| aclDestroyTensor(out_log_probs_ids); | ||
| aclDestroyTensor(out_beam_count_prefix_sums_ids); | ||
| aclDestroyTensor(out_sequence_ids); | ||
| if (workspace_size > 0) { | ||
| CHECK_ACL_SUCCESS( | ||
| aclrtFree(workspace_addr), | ||
| "beam_search_rec: failed to free workspace for REC beam search"); | ||
| } | ||
| } | ||
|
|
||
| void beam_search_rec(const torch::Tensor& logprobs, | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
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.
why you delete below aclrtSynchronizeStream and only add recordStream?