[1/N] Introduce Mooncake Backend and Mooncake EP to Support Elastic EP (#10423)
Co-authored-by: Hank Han <hanhan7630@outlook.com> Co-authored-by: Shangming Cai <csmthu@gmail.com>
This commit is contained in:
@@ -20,7 +20,10 @@ from sglang.srt.layers.moe import (
|
||||
get_tbo_token_distribution_threshold,
|
||||
is_tbo_enabled,
|
||||
)
|
||||
from sglang.srt.layers.moe.token_dispatcher import DeepEPDispatcher
|
||||
from sglang.srt.layers.moe.token_dispatcher import (
|
||||
DeepEPDispatcher,
|
||||
MooncakeEPDispatcher,
|
||||
)
|
||||
from sglang.srt.layers.quantization import deep_gemm_wrapper
|
||||
from sglang.srt.managers.schedule_batch import ScheduleBatch
|
||||
from sglang.srt.model_executor.forward_batch_info import (
|
||||
@@ -363,7 +366,7 @@ class TboDPAttentionPreparer:
|
||||
):
|
||||
|
||||
deepep_mode = get_deepep_mode()
|
||||
enable_deepep_moe = get_moe_a2a_backend().is_deepep()
|
||||
enable_a2a_moe = not get_moe_a2a_backend().is_none()
|
||||
enable_two_batch_overlap = is_tbo_enabled()
|
||||
|
||||
self.enable_two_batch_overlap = enable_two_batch_overlap
|
||||
@@ -392,7 +395,7 @@ class TboDPAttentionPreparer:
|
||||
local_batch.forward_mode.is_extend()
|
||||
and not local_batch.forward_mode.is_target_verify()
|
||||
)
|
||||
and enable_deepep_moe
|
||||
and enable_a2a_moe
|
||||
and (resolved_deepep_mode.is_low_latency())
|
||||
)
|
||||
else:
|
||||
@@ -968,9 +971,14 @@ def _model_forward_tbo_merge_outputs(output_a, output_b):
|
||||
class MaybeTboDeepEPDispatcher:
|
||||
def __init__(self, **kwargs):
|
||||
num_inner_dispatchers = 2 if is_tbo_enabled() else 1
|
||||
self._inners = [
|
||||
DeepEPDispatcher(**kwargs) for _ in range(num_inner_dispatchers)
|
||||
]
|
||||
if get_moe_a2a_backend().is_deepep():
|
||||
self._inners = [
|
||||
DeepEPDispatcher(**kwargs) for _ in range(num_inner_dispatchers)
|
||||
]
|
||||
elif get_moe_a2a_backend().is_mooncake():
|
||||
self._inners = [
|
||||
MooncakeEPDispatcher(**kwargs) for _ in range(num_inner_dispatchers)
|
||||
]
|
||||
|
||||
def _execute(self, name, tbo_subbatch_index: Optional[int] = None, **kwargs):
|
||||
return getattr(self._inners[tbo_subbatch_index or 0], name)(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user