Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eb7d677
remove DP chunking
bnellnm Apr 6, 2026
56bc29a
fix test
bnellnm Apr 6, 2026
01688fe
remove unused bits of DPMetadata
bnellnm Apr 6, 2026
0b960ac
Merge branch 'main' into remove-dp-chunking
robertgshaw2-redhat Apr 6, 2026
6c9951e
set default max_num_batched_tokens based off all2all backend
bnellnm Apr 6, 2026
a81d633
Merge remote-tracking branch 'nm-vllm/remove-dp-chunking' into remove…
bnellnm Apr 6, 2026
9f26dac
fix typo
bnellnm Apr 6, 2026
f3ab098
Merge remote-tracking branch 'origin/main' into remove-dp-chunking
bnellnm Apr 7, 2026
7f21104
add directories for layer test
bnellnm Apr 7, 2026
855f275
Merge branch 'main' into remove-dp-chunking
bnellnm Apr 7, 2026
43619c1
make sure env dict is None
bnellnm Apr 7, 2026
7b992af
Merge remote-tracking branch 'origin/main' into remove-dp-chunking
bnellnm Apr 7, 2026
14cb0a1
Merge remote-tracking branch 'nm-vllm/remove-dp-chunking' into remove…
bnellnm Apr 7, 2026
000711e
Merge branch 'main' into remove-dp-chunking
bnellnm Apr 7, 2026
f0c0be2
remove optional flag
bnellnm Apr 7, 2026
453a425
Merge remote-tracking branch 'nm-vllm/remove-dp-chunking' into remove…
bnellnm Apr 7, 2026
ec9f6fc
Merge branch 'main' into remove-dp-chunking
bnellnm Apr 9, 2026
cce840c
Merge branch 'main' into remove-dp-chunking
robertgshaw2-redhat Apr 9, 2026
85299e4
remove chunking_moe_runner.py
bnellnm Apr 9, 2026
8506ce8
Merge remote-tracking branch 'nm-vllm/remove-dp-chunking' into remove…
bnellnm Apr 9, 2026
ec338ba
revert test data changes + deepep ll does not work with non-blocked fp8
bnellnm Apr 10, 2026
8f99d26
Merge remote-tracking branch 'origin/main' into remove-dp-chunking
bnellnm Apr 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions tests/kernels/moe/modular_kernel_tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
has_deep_gemm,
has_mori,
)
from vllm.utils.math_utils import next_power_of_2

from .mk_objects import (
TestMoEQuantConfig,
Expand Down Expand Up @@ -604,13 +605,6 @@ def make_modular_kernel(
vllm_config: VllmConfig,
quant_config: FusedMoEQuantConfig,
) -> mk.FusedMoEKernel:
def next_power_of_2(x):
import math

if x == 0:
return 1
return 2 ** math.ceil(math.log2(x))

# make moe config
moe_parallel_config: FusedMoEParallelConfig = FusedMoEParallelConfig.make(
tp_size_=get_tensor_model_parallel_world_size(),
Expand Down
9 changes: 1 addition & 8 deletions tests/kernels/moe/test_deepep_deepgemm_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
is_deep_gemm_supported,
)
from vllm.utils.import_utils import has_deep_ep, has_deep_gemm
from vllm.utils.math_utils import next_power_of_2
from vllm.utils.torch_utils import set_random_seed
from vllm.v1.worker.workspace import init_workspace_manager

Expand Down Expand Up @@ -82,14 +83,6 @@ def with_dp_metadata(M: int, world_size: int):
yield


def next_power_of_2(x):
import math

if x == 0:
return 1
return 2 ** math.ceil(math.log2(x))


def make_block_quant_fp8_weights(
e: int,
n: int,
Expand Down
3 changes: 3 additions & 0 deletions tests/kernels/moe/test_flashinfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from vllm.model_executor.layers.quantization.utils.fp8_utils import input_to_float8
from vllm.model_executor.models.llama4 import Llama4MoE
from vllm.platforms import current_platform
from vllm.utils.math_utils import next_power_of_2
from vllm.utils.torch_utils import set_random_seed

try:
Expand Down Expand Up @@ -174,6 +175,7 @@ def make_moe_tensors_8bit(
routing_method=layer.routing_method_type,
activation=activation,
device=w13_quantized.device,
max_num_tokens=next_power_of_2(m),
)

return TestData(
Expand Down Expand Up @@ -348,6 +350,7 @@ def get_fused_moe_quant_config(n: torch.nn.Module) -> FusedMoEQuantConfig:
in_dtype=torch.bfloat16,
is_act_and_mul=activation.is_gated,
routing_method=RoutingMethodType.TopK,
max_num_tokens=next_power_of_2(m),
)

kernel = mk.FusedMoEKernel(
Expand Down
2 changes: 2 additions & 0 deletions tests/kernels/moe/test_flashinfer_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from vllm.model_executor.layers.fused_moe.modular_kernel import FusedMoEKernel
from vllm.platforms import current_platform
from vllm.utils.flashinfer import has_flashinfer_cutlass_fused_moe
from vllm.utils.math_utils import next_power_of_2
from vllm.utils.torch_utils import set_random_seed

if not has_flashinfer_cutlass_fused_moe() or not current_platform.has_device_capability(
Expand Down Expand Up @@ -105,6 +106,7 @@ def test_flashinfer_fp4_moe_no_graph(
in_dtype=dtype,
is_act_and_mul=is_gated_act,
routing_method=RoutingMethodType.TopK,
max_num_tokens=next_power_of_2(m),
)

flashinfer_experts = FusedMoEKernel(
Expand Down
3 changes: 2 additions & 1 deletion tests/kernels/moe/test_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
from vllm.model_executor.models.mixtral import MixtralMoE
from vllm.platforms import current_platform
from vllm.scalar_type import ScalarType, scalar_types
from vllm.utils.math_utils import next_power_of_2
from vllm.utils.torch_utils import set_random_seed
from vllm.v1.worker.workspace import init_workspace_manager

Expand Down Expand Up @@ -1676,7 +1677,7 @@ def test_unquantized_bf16_flashinfer_trtllm_backend(
in_dtype=dtype,
is_act_and_mul=True,
routing_method=RoutingMethodType.Renormalize,
max_num_tokens=m,
max_num_tokens=next_power_of_2(m),
)

with set_current_vllm_config(vllm_config):
Expand Down
15 changes: 9 additions & 6 deletions tests/kernels/moe/test_moe_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from vllm.config import (
CompilationConfig,
ParallelConfig,
SchedulerConfig,
VllmConfig,
set_current_vllm_config,
)
Expand Down Expand Up @@ -53,7 +54,7 @@
has_flashinfer_nvlink_two_sided,
)
from vllm.utils.import_utils import has_deep_ep, has_mori, has_nixl_ep
from vllm.utils.math_utils import cdiv
from vllm.utils.math_utils import cdiv, next_power_of_2
from vllm.utils.torch_utils import set_random_seed
from vllm.v1.worker.workspace import (
init_workspace_manager,
Expand All @@ -67,6 +68,7 @@
(32, 1024, 512),
(222, 2048, 2048), # should be big enough to exercise DP chunking
]
MAX_M = max([x[0] for x in SHAPE_COMBOS])

NUM_EXPERTS = [8, 64]
TOP_KS = [2, 6]
Expand Down Expand Up @@ -1663,9 +1665,6 @@ def test_moe_layer(

verbosity = pytestconfig.getoption("verbose")

test_env = dict()
test_env["VLLM_MOE_DP_CHUNK_SIZE"] = "128"
monkeypatch.setenv("VLLM_MOE_DP_CHUNK_SIZE", "128")
if os.environ.get("VLLM_LOGGING_LEVEL") is None:
monkeypatch.setenv("VLLM_LOGGING_LEVEL", "ERROR")

Expand All @@ -1690,7 +1689,11 @@ def test_moe_layer(
compilation_config.pass_config.fuse_allreduce_rms = False # for now

vllm_config = VllmConfig(
parallel_config=parallel_config, compilation_config=compilation_config
parallel_config=parallel_config,
compilation_config=compilation_config,
scheduler_config=SchedulerConfig.default_factory(
max_num_batched_tokens=next_power_of_2(MAX_M)
),
)

test_configs = generate_valid_test_configs(
Expand Down Expand Up @@ -1718,7 +1721,7 @@ def test_moe_layer(
world_size,
_parallel_worker,
vllm_config,
test_env,
dict(),
test_configs,
verbosity,
)
Expand Down
1 change: 1 addition & 0 deletions tests/kernels/moe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def make_dummy_moe_config(
in_dtype=in_dtype,
device="cuda",
routing_method=RoutingMethodType.TopK,
max_num_tokens=512,
)


Expand Down
11 changes: 0 additions & 11 deletions vllm/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@
VLLM_ENABLE_PREGRAD_PASSES: bool = False
VLLM_DP_MASTER_IP: str = ""
VLLM_DP_MASTER_PORT: int = 0
VLLM_MOE_DP_CHUNK_SIZE: int = 256
VLLM_ENABLE_MOE_DP_CHUNK: bool = True
VLLM_RANDOMIZE_DP_DUMMY_INPUTS: bool = False
VLLM_RAY_DP_PACK_STRATEGY: Literal["strict", "fill", "span"] = "strict"
VLLM_RAY_EXTRA_ENV_VAR_PREFIXES_TO_COPY: str = ""
Expand Down Expand Up @@ -1133,15 +1131,6 @@ def _get_or_set_default() -> str:
"VLLM_DP_MASTER_IP": lambda: os.getenv("VLLM_DP_MASTER_IP", "127.0.0.1"),
# Port of the master node in the data parallel setting
"VLLM_DP_MASTER_PORT": lambda: int(os.getenv("VLLM_DP_MASTER_PORT", "0")),
# In the context of executing MoE models with Data-Parallel, Expert-Parallel
# and Batched All-to-All dispatch/combine kernels, VLLM_MOE_DP_CHUNK_SIZE
# dictates the quantum of tokens that can be dispatched from a DP
# rank. All DP ranks process the activations in VLLM_MOE_DP_CHUNK_SIZE
# units.
"VLLM_MOE_DP_CHUNK_SIZE": lambda: int(os.getenv("VLLM_MOE_DP_CHUNK_SIZE", "256")),
"VLLM_ENABLE_MOE_DP_CHUNK": lambda: bool(
int(os.getenv("VLLM_ENABLE_MOE_DP_CHUNK", "1"))
),
# Randomize inputs during dummy runs when using Data Parallel
"VLLM_RANDOMIZE_DP_DUMMY_INPUTS": lambda: os.environ.get(
"VLLM_RANDOMIZE_DP_DUMMY_INPUTS", "0"
Expand Down
12 changes: 1 addition & 11 deletions vllm/model_executor/layers/fused_moe/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import torch

import vllm.envs as envs
from vllm.config import ParallelConfig
from vllm.distributed import get_dp_group, get_pcp_group, get_tensor_model_parallel_rank
from vllm.logger import init_logger
Expand Down Expand Up @@ -937,15 +936,6 @@ class FusedMoEParallelConfig:
all2all_backend: str # all2all backend for MoE communication
enable_eplb: bool # whether to enable expert load balancing

@property
def use_dp_chunking(self) -> bool:
return (
self.use_deepep_ll_kernels
or self.use_mori_kernels
or self.use_fi_nvl_two_sided_kernels
or self.use_nixl_ep_kernels
) and envs.VLLM_ENABLE_MOE_DP_CHUNK

@property
def is_sequence_parallel(self) -> bool:
return self.sp_size > 1
Expand Down Expand Up @@ -1184,7 +1174,7 @@ class FusedMoEConfig:
intermediate_size_per_partition_unpadded: int | None = None

moe_backend: str = "auto"
max_num_tokens: int = envs.VLLM_MOE_DP_CHUNK_SIZE
max_num_tokens: int = 0
Comment thread
bnellnm marked this conversation as resolved.
Outdated
has_bias: bool = False
is_act_and_mul: bool = True
is_lora_enabled: bool = False
Expand Down
3 changes: 1 addition & 2 deletions vllm/model_executor/layers/fused_moe/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import torch
from torch.nn.parameter import UninitializedParameter

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.parallel import ExpertPlacementStrategy
Expand Down Expand Up @@ -479,7 +478,7 @@ def __init__(
in_dtype=moe_in_dtype,
moe_backend=vllm_config.kernel_config.moe_backend,
router_logits_dtype=router_logits_dtype,
max_num_tokens=envs.VLLM_MOE_DP_CHUNK_SIZE,
max_num_tokens=vllm_config.scheduler_config.max_num_batched_tokens,
has_bias=has_bias,
is_act_and_mul=is_act_and_mul,
is_lora_enabled=vllm_config.lora_config is not None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from vllm.model_executor.layers.fused_moe.router.fused_moe_router import (
FusedMoERouter,
)
from vllm.model_executor.layers.fused_moe.runner.chunking_moe_runner import (
ChunkingMoERunner,
)
from vllm.model_executor.layers.fused_moe.runner.default_moe_runner import (
DefaultMoERunner,
)
Expand All @@ -35,7 +32,7 @@ def create_moe_runner(
reduce_results: bool,
enable_dbo: bool,
) -> MoERunner:
runner = DefaultMoERunner(
return DefaultMoERunner(
layer_name,
moe_config,
router,
Expand All @@ -46,6 +43,3 @@ def create_moe_runner(
reduce_results,
enable_dbo,
)
if moe_config.moe_parallel_config.use_dp_chunking:
return ChunkingMoERunner(runner)
return runner
16 changes: 0 additions & 16 deletions vllm/model_executor/layers/fused_moe/runner/shared_experts.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def __init__(
self._moe_config = moe_config
self._quant_method = quant_method
self._reduce_results = reduce_results
self._use_dp_chunking = moe_config.moe_parallel_config.use_dp_chunking

# Allow disabling of the separate shared experts stream for
# debug purposes.
Expand All @@ -87,20 +86,6 @@ def __init__(
"Enabled separate cuda stream for MoE shared_experts", scope="local"
)

@property
def _use_external_experts(self) -> bool:
if self._use_dp_chunking:
return False

# Disable shared expert overlap if:
# - we are using eplb with non-default backend, because of correctness issues
# - we are using flashinfer with DP, since there nothing to gain
backend = self._moe_config.moe_parallel_config.all2all_backend
return (
self._moe_config.moe_parallel_config.enable_eplb
and backend != "allgather_reducescatter"
) or self._moe_config.moe_parallel_config.use_fi_nvl_two_sided_kernels

def _determine_shared_experts_order(
self,
hidden_states: torch.Tensor,
Expand All @@ -110,7 +95,6 @@ def _determine_shared_experts_order(

should_run_shared_in_aux_stream = (
current_platform.is_cuda()
and not self._use_dp_chunking
and self._stream is not None
and hidden_states.shape[0]
<= envs.VLLM_SHARED_EXPERTS_STREAM_TOKEN_THRESHOLD
Expand Down
4 changes: 2 additions & 2 deletions vllm/model_executor/layers/quantization/quark/quark_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,9 +1220,9 @@ def process_weights_after_loading(self, layer):
layer.w2_bias = torch.nn.Parameter(w2_bias, requires_grad=False)

# FIXME warp need to be adjusted based on batch size
# only apply to batched mode
# only apply to batched mode
if self.moe.use_ep:
num_warps = 4 if envs.VLLM_MOE_DP_CHUNK_SIZE <= 512 else 8
num_warps = 4 if self.moe.max_num_tokens <= 512 else 8
else:
num_warps = 8

Expand Down
Loading