[ROCm][Bugfix] Explicitly reject FSE=1 with DPA+ETP deployment for DeepSeek-V4 (#57919)

Signed-off-by: Shanshan Shen <87969357+shen-shanshan@users.noreply.github.com>
This commit is contained in:
Shanshan Shen
2026-09-22 04:45:53 +00:00
committed by GitHub
parent 639461eda4
commit 42a85a4976
2 changed files with 43 additions and 5 deletions
+22 -1
View File
@@ -7,6 +7,7 @@ import pytest
import torch
from torch import nn
from vllm.config import ParallelConfig
from vllm.model_executor.models.utils import WeightsMapper
from vllm.platforms import current_platform
@@ -100,7 +101,9 @@ def test_rocm_moe_wires_vision_routing_on_hash_and_regular_layers(
n_shared_experts=None,
)
vllm_config = SimpleNamespace(
model_config=SimpleNamespace(hf_config=config), quant_config=None
model_config=SimpleNamespace(hf_config=config),
quant_config=None,
parallel_config=ParallelConfig(),
)
hash_moe = rocm_model.DeepseekV4MoE(vllm_config, prefix="model.layers.0.ffn")
@@ -115,6 +118,24 @@ def test_rocm_moe_wires_vision_routing_on_hash_and_regular_layers(
assert factory_kwargs["image_sentinel_lo"] == IMAGE_SENTINEL_BASE_ID
def test_rocm_fse_rejects_data_parallel_deployment(
monkeypatch: pytest.MonkeyPatch,
) -> None:
from vllm.models.deepseek_v4.amd.model import _fuse_shared_experts_enabled
config = SimpleNamespace(n_shared_experts=1)
monkeypatch.setenv("VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS", "1")
with pytest.raises(ValueError, match="data parallelism"):
_fuse_shared_experts_enabled(config, ParallelConfig(data_parallel_size=2))
# Expert parallelism already disables FSE: no raise, FSE stays off.
assert not _fuse_shared_experts_enabled(
config, ParallelConfig(data_parallel_size=2, enable_expert_parallel=True)
)
assert _fuse_shared_experts_enabled(config, ParallelConfig())
def test_rocm_mtp_forwards_input_ids_for_vision_routing(
monkeypatch: pytest.MonkeyPatch,
) -> None:
+21 -4
View File
@@ -12,7 +12,7 @@ import torch.nn as nn
import vllm.envs as envs
from vllm._aiter_ops import rocm_aiter_ops
from vllm.config import VllmConfig, get_current_vllm_config
from vllm.config import ParallelConfig, VllmConfig
from vllm.distributed import (
get_pp_group,
get_tensor_model_parallel_rank,
@@ -504,11 +504,28 @@ class DeepseekV4HeterogeneousSharedRoutedExperts(RoutedExperts):
return routed + shared_out
def _fuse_shared_experts_enabled(config) -> bool:
def _fuse_shared_experts_enabled(config, parallel_config: ParallelConfig) -> bool:
if (
getattr(config, "n_shared_experts", None)
and envs.VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS
and not parallel_config.enable_expert_parallel
and parallel_config.data_parallel_size > 1
):
# Fused shared experts are not supported under data parallelism:
# the fused path cannot load the FP8 shared expert into the MXFP4
# routed slot, which fails obscurely during weight loading. Fail
# fast with an actionable message instead.
raise ValueError(
"DeepSeek-V4 fused shared experts "
"(VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1) are not supported "
"with data parallelism (data_parallel_size > 1). Set "
"VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0 to run the shared "
"expert as an unfused FP8 MLP."
)
return bool(
getattr(config, "n_shared_experts", None)
and envs.VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS
and not get_current_vllm_config().parallel_config.enable_expert_parallel
and not parallel_config.enable_expert_parallel
)
@@ -586,7 +603,7 @@ class DeepseekV4MoE(nn.Module):
# This should be cleaned up and use `resolve_layer_fused_shared_expert`.
self.fuse_heterogeneous_shared_expert = fuse_heterogeneous_shared_expert
fse_requested = (
_fuse_shared_experts_enabled(config)
_fuse_shared_experts_enabled(config, vllm_config.parallel_config)
and not self.fuse_heterogeneous_shared_expert
)
fse_compatible = False