[Perf] Overlap NSA-CP key all-gather with query computation for DeepSeek-V3.2 (#20438)
Co-authored-by: Shurui Jia <18817781975@163.com> Co-authored-by: Baidu-AIAK <baiduaiak~123>
This commit is contained in:
co-authored by
Shurui Jia
Baidu-AIAK
parent
d6ce1b8dce
commit
6491728797
@@ -329,6 +329,25 @@ class Indexer(MultiPlatformOp):
|
||||
with torch.cuda.stream(self.alt_stream):
|
||||
key = rotate_activation(key)
|
||||
current_stream.wait_stream(self.alt_stream)
|
||||
elif (
|
||||
self.alt_stream is not None
|
||||
and forward_batch.nsa_cp_metadata is not None
|
||||
and self.nsa_enable_prefill_cp
|
||||
):
|
||||
key = rotate_activation(key)
|
||||
current_stream = torch.cuda.current_stream()
|
||||
self.alt_stream.wait_stream(current_stream)
|
||||
query = rotate_activation(query)
|
||||
|
||||
with torch.cuda.stream(self.alt_stream):
|
||||
key = cp_all_gather_rerange_output(
|
||||
key.contiguous(),
|
||||
self.cp_size,
|
||||
forward_batch,
|
||||
torch.cuda.current_stream(),
|
||||
)
|
||||
current_stream.wait_stream(self.alt_stream)
|
||||
return query, key
|
||||
else:
|
||||
query = rotate_activation(query)
|
||||
key = rotate_activation(key)
|
||||
|
||||
Reference in New Issue
Block a user