Overlap shared experts with deepep dispatch for single batch overlap on Blackwell (#17289)
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user