[ROCm][Perf] Enable DPA+ETP prefill compute/comm dual-batch-overlap for DeepSeek-V4 (#57773)

Signed-off-by: Shanshan Shen <87969357+shen-shanshan@users.noreply.github.com>
Signed-off-by: shen-shanshan <467638484@qq.com>
This commit is contained in:
Shanshan Shen
2026-10-15 11:16:48 +08:00
committed by GitHub
parent 5d5c3d7c43
commit f46021a7fa
9 changed files with 319 additions and 28 deletions
+15
View File
@@ -32,6 +32,7 @@ class UBatchContext:
gpu_comm_done_event: torch.Event,
gpu_compute_done_event: torch.Event,
schedule: str = "default",
token_offset: int = 0,
):
self.id = id
self.comm_stream = comm_stream
@@ -44,6 +45,7 @@ class UBatchContext:
self.gpu_comm_done_event = gpu_comm_done_event
self.gpu_compute_done_event = gpu_compute_done_event
self.schedule = schedule
self.token_offset = token_offset
self.recv_hook = None
def __enter__(self):
@@ -155,6 +157,17 @@ def dbo_current_ubatch_id() -> int:
return _THREAD_ID_TO_CONTEXT[threading.get_ident()]
def dbo_current_ubatch_token_offset() -> int:
"""Row offset of the calling ubatch inside the parent batch.
Returns 0 when no DBO context is active on this thread.
"""
if len(_THREAD_ID_TO_CONTEXT) == 0:
return 0
ctx = _CURRENT_CONTEXTS[_THREAD_ID_TO_CONTEXT[threading.get_ident()]]
return ctx.token_offset
def _register_ubatch_function(func):
def wrapper(*args, **kwargs):
if len(_THREAD_ID_TO_CONTEXT) > 0:
@@ -204,6 +217,7 @@ def make_ubatch_contexts(
forward_contexts: list[ForwardContext],
ready_barrier: threading.Barrier,
schedule: str = "default",
token_offsets: list[int] | None = None,
) -> list[UBatchContext]:
global _NUM_UBATCHES, _CURRENT_CONTEXTS
assert num_micro_batches > 1, "num_micro_batches must be greater than 1"
@@ -233,6 +247,7 @@ def make_ubatch_contexts(
gpu_comm_done_event=gpu_comm_done_events[i],
gpu_compute_done_event=gpu_compute_done_events[i],
schedule=schedule,
token_offset=token_offsets[i] if token_offsets else 0,
)
ctxs.append(ctx)