A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 5, 01:00 UTC
Remove outdated tests test_mixtral_moe and test_duplicated_ignored_sequence_group (#40175)
Signed-off-by: mgoin <mgoin64@gmail.com>
Michael Goin committed
Apr 17, 2026 at 19:49 UTC
1f45e83756b99aa730c927102ca4708ffbaba2aa
2 files changed
-146
tests/kernels/moe/test_moe.py
-130
@@ -14,8 +14,6 @@ import pytest
14
import torch
15
from torch.nn import Parameter
16
from torch.nn import functional as F
17
-from transformers import MixtralConfig
18
-from transformers.models.mixtral.modeling_mixtral import MixtralSparseMoeBlock
17
18
import vllm.model_executor.layers.fused_moe # noqa
19
from tests.kernels.moe.utils import (
@@ -24,10 +22,7 @@ from tests.kernels.moe.utils import (
22
modular_triton_fused_moe,
23
)
24
from tests.kernels.utils import opcheck, stack_and_dev, torch_experts, torch_moe
27
-from vllm._aiter_ops import rocm_aiter_ops
25
from vllm.config import VllmConfig, set_current_vllm_config
29
-from vllm.distributed.parallel_state import init_distributed_environment
30
-from vllm.forward_context import get_forward_context, set_forward_context
26
from vllm.model_executor.layers.fused_moe import (
27
MoEActivation,
28
fused_topk,
@@ -56,12 +51,10 @@ from vllm.model_executor.layers.quantization.utils.marlin_utils_test import (
51
marlin_quantize,
52
)
53
from vllm.model_executor.layers.quantization.utils.quant_utils import quantize_weights
59
-from vllm.model_executor.models.mixtral import MixtralMoE
54
from vllm.platforms import current_platform
55
from vllm.scalar_type import ScalarType, scalar_types
56
from vllm.utils.math_utils import next_power_of_2
57
from vllm.utils.torch_utils import set_random_seed
64
-from vllm.v1.worker.workspace import init_workspace_manager
58
59
60
def iterative_moe(
@@ -681,129 +674,6 @@ def test_fused_moe_wn16(
674
torch.testing.assert_close(triton_output, torch_output, atol=2e-2, rtol=0)
675
676
684
-@pytest.mark.parametrize("dtype", [torch.bfloat16])
685
-@pytest.mark.parametrize("padding", [True, False])
686
-@pytest.mark.parametrize(
687
- "use_rocm_aiter", [True, False] if current_platform.is_rocm() else [False]
688
-)
689
-@torch.inference_mode()
690
-def test_mixtral_moe(
691
- default_vllm_config,
692
- dist_init,
693
- dtype: torch.dtype,
694
- padding: bool,
695
- use_rocm_aiter: bool,
696
- monkeypatch,
697
-):
698
- """Make sure our Mixtral MoE implementation agrees with the one from
699
- huggingface."""
700
-
701
- # Explicitly set AITER env var based on test parameter to ensure
702
- # consistent behavior regardless of external environment
703
- monkeypatch.setenv("VLLM_ROCM_USE_AITER", "1" if use_rocm_aiter else "0")
704
- rocm_aiter_ops.refresh_env_variables()
705
-
706
- if use_rocm_aiter and dtype == torch.float32:
707
- pytest.skip("AITER ROCm test skip for float32")
708
-
709
- monkeypatch.setenv("RANK", "0")
710
- monkeypatch.setenv("LOCAL_RANK", "0")
711
- monkeypatch.setenv("WORLD_SIZE", "1")
712
- monkeypatch.setenv("MASTER_ADDR", "localhost")
713
- monkeypatch.setenv("MASTER_PORT", "12345")
714
- init_distributed_environment()
715
- init_workspace_manager(torch.accelerator.current_device_index())
716
-
717
- # Instantiate our and huggingface's MoE blocks
718
- vllm_config.compilation_config.static_forward_context = dict()
719
- with set_current_vllm_config(vllm_config), set_forward_context(None, vllm_config):
720
- config = MixtralConfig()
721
- hf_moe = MixtralSparseMoeBlock(config).to(dtype).to("cuda")
722
- vllm_moe = MixtralMoE(
723
- num_experts=config.num_local_experts,
724
- top_k=config.num_experts_per_tok,
725
- hidden_size=config.hidden_size,
726
- intermediate_size=config.intermediate_size,
727
- params_dtype=dtype,
728
- tp_size=1,
729
- dp_size=1,
730
- ).cuda()
731
-
732
- # Load the weights
733
- vllm_moe.gate.weight.data[:] = hf_moe.gate.weight.data
734
- if isinstance(hf_moe.experts, torch.nn.ModuleList):
735
- # Transformers v4
736
- for i in range(config.num_local_experts):
737
- weights = (
738
- hf_moe.experts[i].w1.weight.data,
739
- hf_moe.experts[i].w3.weight.data,
740
- )
741
- vllm_moe.experts.w13_weight[i][:] = torch.cat(weights, dim=0)
742
- vllm_moe.experts.w2_weight[i][:] = hf_moe.experts[i].w2.weight.data
743
- else:
744
- # Transformers v5
745
- vllm_moe.experts.w13_weight.data[:] = hf_moe.experts.gate_up_proj.data
746
- vllm_moe.experts.w2_weight.data[:] = hf_moe.experts.down_proj.data
747
- # TODO: remove this line after https://github.com/huggingface/transformers/pull/43622
748
- hf_moe.experts.config._experts_implementation = "eager"
749
-
750
- # Generate input batch of dimensions [batch_size, seq_len, hidden_dim]
751
- hf_inputs = torch.randn((1, 64, config.hidden_size)).to(dtype).to("cuda")
752
- # vLLM uses 1D query [num_tokens, hidden_dim]
753
- vllm_inputs = hf_inputs.flatten(0, 1)
754
-
755
- # Pad the weight if moe padding is enabled
756
- if padding:
757
- vllm_moe.experts.w13_weight = Parameter(
758
- F.pad(vllm_moe.experts.w13_weight, (0, 128), "constant", 0)[
759
- ..., 0:-128
760
- ],
761
- requires_grad=False,
762
- )
763
- vllm_moe.experts.w2_weight = Parameter(
764
- F.pad(vllm_moe.experts.w2_weight, (0, 128), "constant", 0)[..., 0:-128],
765
- requires_grad=False,
766
- )
767
- torch.accelerator.synchronize()
768
- torch.accelerator.empty_cache()
769
-
770
- # FIXME (zyongye) fix this after we move self.kernel
771
- # assignment in FusedMoE.__init__
772
-
773
- vllm_moe.experts.quant_method.process_weights_after_loading(vllm_moe.experts)
774
-
775
- # need to override the forward context for unittests, otherwise it assumes
776
- # we're running the model forward pass (the model specified in vllm_config)
777
- get_forward_context().all_moe_layers = None
778
-
779
- # Run forward passes for both MoE blocks
780
- hf_states = hf_moe.forward(hf_inputs)
781
- if isinstance(hf_states, tuple):
782
- # Transformers v4
783
- hf_states = hf_states[0]
784
- vllm_states = vllm_moe.forward(vllm_inputs)
785
-
786
- mixtral_moe_tol = {
787
- torch.float32: 1e-3,
788
- torch.float16: 1e-3,
789
- torch.bfloat16: 1e-2,
790
- }
791
-
792
- if use_rocm_aiter:
793
- # The values of rtol and atol are set based on the tests in ROCM AITER package.
794
- # https://github.com/ROCm/aiter/blob/dfed377f4be7da96ca2d75ac0761f569676f7240/op_tests/test_moe.py#L174
795
- torch.testing.assert_close(
796
- hf_states.flatten(0, 1), vllm_states, rtol=0.01, atol=100
797
- )
798
- else:
799
- torch.testing.assert_close(
800
- hf_states.flatten(0, 1),
801
- vllm_states,
802
- rtol=mixtral_moe_tol[dtype],
803
- atol=mixtral_moe_tol[dtype],
804
- )
805
-
806
-
677
def marlin_moe_generate_valid_test_cases():
678
import itertools
679
tests/test_regression.py
-16
@@ -17,22 +17,6 @@ from vllm import LLM, SamplingParams
17
from vllm.platforms import current_platform
18
19
20
-@pytest.mark.skip(reason="In V1, we reject tokens > max_seq_len")
21
-def test_duplicated_ignored_sequence_group():
22
- """https://github.com/vllm-project/vllm/issues/1655"""
23
-
24
- sampling_params = SamplingParams(temperature=0.01, top_p=0.1, max_tokens=256)
25
- llm = LLM(
26
- model="distilbert/distilgpt2",
27
- max_num_batched_tokens=4096,
28
- tensor_parallel_size=1,
29
- )
30
- prompts = ["This is a short prompt", "This is a very long prompt " * 1000]
31
- outputs = llm.generate(prompts, sampling_params=sampling_params)
32
-
33
- assert len(prompts) == len(outputs)
34
-
35
-
20
@pytest.mark.parametrize(
21
"model",
22
[