[Bugfix][Spec Decode][MoE] Avoid uninitialized EPLB state in DeepSeek V4.1 DSpark drafter (#56387)
Signed-off-by: zack <51604064+luoyuctl@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||||
|
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
from vllm.v1.worker.gpu.spec_decode.dspark.utils import _get_dspark_parallel_config
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class _FakeEPLBConfig:
|
||||||
|
num_redundant_experts: int = 0
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class _FakeParallelConfig:
|
||||||
|
pipeline_parallel_size: int = 2
|
||||||
|
tensor_parallel_size: int = 8
|
||||||
|
enable_eplb: bool = True
|
||||||
|
eplb_config: _FakeEPLBConfig = field(
|
||||||
|
default_factory=lambda: _FakeEPLBConfig(num_redundant_experts=32)
|
||||||
|
)
|
||||||
|
enable_elastic_ep: bool = True
|
||||||
|
|
||||||
|
def __post_init__(self) -> None:
|
||||||
|
if not self.enable_eplb and self.eplb_config.num_redundant_experts:
|
||||||
|
raise ValueError("redundant experts require EPLB")
|
||||||
|
if self.enable_elastic_ep and not self.enable_eplb:
|
||||||
|
raise ValueError("elastic EP requires EPLB")
|
||||||
|
|
||||||
|
|
||||||
|
def test_dspark_parallel_config_disables_eplb_atomically():
|
||||||
|
target_config = _FakeParallelConfig()
|
||||||
|
|
||||||
|
draft_config = _get_dspark_parallel_config(
|
||||||
|
target_config,
|
||||||
|
tensor_parallel_size=4,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert target_config.pipeline_parallel_size == 2
|
||||||
|
assert target_config.tensor_parallel_size == 8
|
||||||
|
assert target_config.enable_eplb
|
||||||
|
assert target_config.eplb_config.num_redundant_experts == 32
|
||||||
|
assert target_config.enable_elastic_ep
|
||||||
|
|
||||||
|
assert draft_config is not target_config
|
||||||
|
assert draft_config.pipeline_parallel_size == 1
|
||||||
|
assert draft_config.tensor_parallel_size == 4
|
||||||
|
assert not draft_config.enable_eplb
|
||||||
|
assert draft_config.eplb_config.num_redundant_experts == 0
|
||||||
|
assert not draft_config.enable_elastic_ep
|
||||||
|
assert draft_config.eplb_config is not target_config.eplb_config
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
|
||||||
from vllm.config import ModelConfig, VllmConfig, replace
|
from vllm.config import ModelConfig, ParallelConfig, VllmConfig, replace
|
||||||
from vllm.logger import init_logger
|
from vllm.logger import init_logger
|
||||||
from vllm.v1.attention.backends.registry import AttentionBackendEnum
|
from vllm.v1.attention.backends.registry import AttentionBackendEnum
|
||||||
from vllm.v1.worker.gpu.spec_decode.utils import get_pp_safe_draft_load_config
|
from vllm.v1.worker.gpu.spec_decode.utils import get_pp_safe_draft_load_config
|
||||||
@@ -31,6 +31,29 @@ def _resolve_dspark_attention_backend(
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _get_dspark_parallel_config(
|
||||||
|
parallel_config: ParallelConfig,
|
||||||
|
tensor_parallel_size: int,
|
||||||
|
) -> ParallelConfig:
|
||||||
|
if parallel_config.enable_eplb:
|
||||||
|
logger.warning_once(
|
||||||
|
"EPLB is disabled for the DSpark draft model. EPLB remains enabled "
|
||||||
|
"for the target model."
|
||||||
|
)
|
||||||
|
|
||||||
|
return replace(
|
||||||
|
parallel_config,
|
||||||
|
pipeline_parallel_size=1,
|
||||||
|
tensor_parallel_size=tensor_parallel_size,
|
||||||
|
enable_eplb=False,
|
||||||
|
eplb_config=replace(
|
||||||
|
parallel_config.eplb_config,
|
||||||
|
num_redundant_experts=0,
|
||||||
|
),
|
||||||
|
enable_elastic_ep=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def load_dspark_model(target_model: nn.Module, vllm_config: VllmConfig) -> nn.Module:
|
def load_dspark_model(target_model: nn.Module, vllm_config: VllmConfig) -> nn.Module:
|
||||||
speculative_config = vllm_config.speculative_config
|
speculative_config = vllm_config.speculative_config
|
||||||
assert speculative_config is not None
|
assert speculative_config is not None
|
||||||
@@ -54,12 +77,9 @@ def load_dspark_model(target_model: nn.Module, vllm_config: VllmConfig) -> nn.Mo
|
|||||||
|
|
||||||
draft_vllm_config = replace(
|
draft_vllm_config = replace(
|
||||||
vllm_config,
|
vllm_config,
|
||||||
parallel_config=replace(
|
parallel_config=_get_dspark_parallel_config(
|
||||||
vllm_config.parallel_config,
|
vllm_config.parallel_config,
|
||||||
pipeline_parallel_size=1,
|
speculative_config.draft_parallel_config.tensor_parallel_size,
|
||||||
tensor_parallel_size=(
|
|
||||||
speculative_config.draft_parallel_config.tensor_parallel_size
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
attention_config=replace(
|
attention_config=replace(
|
||||||
vllm_config.attention_config,
|
vllm_config.attention_config,
|
||||||
|
|||||||
Reference in New Issue
Block a user