[AMD] Enable dual-stream MoE on ROCm (#24005)
Signed-off-by: inkcherry <mingzhi.liu@amd.com>
This commit is contained in:
@@ -115,6 +115,7 @@ SGLang supports various environment variables that can be used to configure its
|
||||
| Environment Variable | Description | Default Value |
|
||||
| --- | --- | --- |
|
||||
| `SGLANG_USE_AITER` | Use AITER optimize implementation | `false` |
|
||||
| `SGLANG_ROCM_USE_MULTI_STREAM` | Allocate alt CUDA/HIP stream on ROCm/AITER to overlap shared and routed experts in DeepseekV2 MoE. Requires the HIP env `GPU_MAX_HW_QUEUES>=5` (default `4`, the cap on HSA/ROCr HW queues HIP creates) so the alt stream gets its own queue instead of serializing with the main stream. Best paired with `--deepep-mode low_latency` so Mori's AsyncLL kernel offloads dispatch/combine to copy engines and frees CUs. | `false` |
|
||||
| `SGLANG_MOE_PADDING` | Enable MoE padding (sets padding size to 128 if value is `1`, often set to `1` in Docker builds) | `false` |
|
||||
| `SGLANG_CUTLASS_MOE` (deprecated) | Use Cutlass FP8 MoE kernel on Blackwell GPUs (deprecated, use --moe-runner-backend=cutlass) | `false` |
|
||||
|
||||
|
||||
@@ -325,6 +325,9 @@ class Envs:
|
||||
SGLANG_ROCM_FUSED_DECODE_MLA = EnvBool(False)
|
||||
SGLANG_ROCM_DISABLE_LINEARQUANT = EnvBool(False)
|
||||
SGLANG_MORI_NUM_MAX_DISPATCH_TOKENS_PER_RANK = EnvInt(4096)
|
||||
# Enable dual-stream MoE (shared experts vs routed experts) on the
|
||||
# ROCm/AITER path. Requires GPU_MAX_HW_QUEUES>=5 to avoid HW-queue serialization.
|
||||
SGLANG_ROCM_USE_MULTI_STREAM = EnvBool(False)
|
||||
|
||||
# MPS (Apple Silicon)
|
||||
SGLANG_USE_MLX = EnvBool(False)
|
||||
|
||||
@@ -932,6 +932,18 @@ class MoriEPDispatcher(BaseDispatcher):
|
||||
|
||||
self.deepep_mode = deepep_mode
|
||||
|
||||
async_mode = self.deepep_mode.enable_low_latency()
|
||||
if get_bool_env_var("SGLANG_ROCM_USE_MULTI_STREAM") and not async_mode:
|
||||
logger.warning_once(
|
||||
"SGLANG_ROCM_USE_MULTI_STREAM=1 is set but Mori AsyncLL is "
|
||||
"not enabled (--deepep-mode=%s). The alt-stream overlap only "
|
||||
"frees up CUs when dispatch/combine runs on the AsyncLL "
|
||||
"copy-engine kernel; otherwise it stays on CUs and competes "
|
||||
"with the alt-stream work. Pass --deepep-mode low_latency "
|
||||
"(or auto) to enable the AsyncLL kernel.",
|
||||
self.deepep_mode.value,
|
||||
)
|
||||
|
||||
common_kwargs = dict(
|
||||
group=group,
|
||||
router_topk=router_topk,
|
||||
|
||||
@@ -1921,7 +1921,12 @@ class DeepseekV2Model(nn.Module):
|
||||
|
||||
self.alt_stream = (
|
||||
torch.cuda.Stream()
|
||||
if _is_cuda or _is_musa or envs.SGLANG_NPU_USE_MULTI_STREAM.get()
|
||||
if (
|
||||
_is_cuda
|
||||
or _is_musa
|
||||
or envs.SGLANG_NPU_USE_MULTI_STREAM.get()
|
||||
or envs.SGLANG_ROCM_USE_MULTI_STREAM.get()
|
||||
)
|
||||
else None
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user