Overlap shared experts with deepep dispatch for single batch overlap on Blackwell (#17289)

This commit is contained in:
Baizhou Zhang
2026-01-21 02:56:55 +08:00
committed by GitHub
parent 16802fb6b2
commit 6ea491e439
4 changed files with 53 additions and 1 deletions

View File

@@ -41,7 +41,11 @@ class SboFlags:
@classmethod
def enable_combine_shared_two_stream_overlap(cls):
return is_sbo_enabled() and not cls.enable_dispatch_shared_one_stream_overlap()
return (
is_sbo_enabled()
and not cls.enable_dispatch_shared_one_stream_overlap()
and not envs.SGLANG_BLACKWELL_OVERLAP_SHARED_EXPERTS_OUTSIDE_SBO.get()
)
@classmethod
def enable_dispatch_shared_one_stream_overlap(cls):

View File

@@ -341,6 +341,7 @@ class Envs:
SGLANG_DEEPEP_BF16_DISPATCH = EnvBool(False)
SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK = EnvInt(128)
SGLANG_DEEPEP_LL_COMBINE_SEND_NUM_SMS = EnvInt(32)
SGLANG_BLACKWELL_OVERLAP_SHARED_EXPERTS_OUTSIDE_SBO = EnvBool(False)
# NSA Backend
SGLANG_NSA_FUSE_TOPK = EnvBool(True)

View File

@@ -882,6 +882,52 @@ class DeepseekV2MoE(nn.Module):
post_combine_hook_handle = (
self.experts.dispatcher.register_post_combine_hook(_post_combine_hook)
)
elif envs.SGLANG_BLACKWELL_OVERLAP_SHARED_EXPERTS_OUTSIDE_SBO.get():
# On GB200: Shared experts overlapped on alt_stream, down gemm overlapped with DeepEP Combine
def _post_dispatch_hook(
dispatcher: BaseDispatcher, dispatch_output: DispatchOutput
):
combine_overlap_args, down_gemm_overlap_args, meta_overlap_args = (
compute_overlap_args(dispatch_output, self.alt_stream)
)
dispatcher.set_overlap_args(
combine_overlap_args=combine_overlap_args,
meta_overlap_args=meta_overlap_args,
)
self.experts.set_overlap_args(
down_gemm_overlap_args=down_gemm_overlap_args,
meta_overlap_args=meta_overlap_args,
)
post_dispatch_hook_handle.remove()
def _pre_combine_hook(
dispatcher: BaseDispatcher, combine_input: CombineInput
):
if (
e := dispatcher.meta_overlap_args.get("record_event_after_down")
) is not None:
e.record()
pre_combine_hook_handle.remove()
def _post_combine_hook(
dispatcher: BaseDispatcher, hidden_states: torch.Tensor
):
dispatcher.clear_overlap_args()
self.experts.clear_overlap_args()
post_combine_hook_handle.remove()
post_dispatch_hook_handle = (
self.experts.dispatcher.register_post_dispatch_hook(_post_dispatch_hook)
)
pre_combine_hook_handle = self.experts.dispatcher.register_pre_combine_hook(
_pre_combine_hook
)
post_combine_hook_handle = (
self.experts.dispatcher.register_post_combine_hook(_post_combine_hook)
)
final_hidden_states = self.experts(
hidden_states=hidden_states,