Skip to content
Merged
Changes from all commits
Commits
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
21 changes: 12 additions & 9 deletions tests/kernels/moe/test_deepep_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from vllm.model_executor.layers.quantization.utils.fp8_utils import (
per_token_group_quant_fp8,
)
from vllm.platforms import current_platform
from vllm.utils.import_utils import has_deep_ep
from vllm.utils.torch_utils import set_random_seed
from vllm.v1.worker.workspace import init_workspace_manager
Expand Down Expand Up @@ -64,7 +65,7 @@ def make_weights(
return w1, w2, None, None

# per-out-channel weight quantization
assert dtype == torch.float8_e4m3fn
assert dtype == current_platform.fp8_dtype()
w1 = torch.empty((e, 2 * n, k), device="cuda", dtype=torch.float16)
w2 = torch.empty((e, k, n), device="cuda", dtype=torch.float16)

Expand Down Expand Up @@ -105,9 +106,11 @@ class TestTensors:
@staticmethod
def make(config: TestConfig, low_latency_mode: bool) -> "TestTensors":
# TODO (varun) - check that float16 works ?
assert config.dtype in [torch.bfloat16, torch.float8_e4m3fn]
assert config.dtype in [torch.bfloat16, current_platform.fp8_dtype()]
token_dtype = (
torch.bfloat16 if config.dtype == torch.float8_e4m3fn else config.dtype
torch.bfloat16
if config.dtype == current_platform.fp8_dtype()
else config.dtype
)
rank_tokens = (
torch.randn((config.m, config.k), device="cuda", dtype=token_dtype) / 10
Expand Down Expand Up @@ -216,10 +219,10 @@ def build_expert_map():
return expert_map.to(device=device, dtype=torch.int32)

hidden_size = test_tensors.rank_tokens.size(1)
is_quantized = w1.dtype == torch.float8_e4m3fn
is_quantized = w1.dtype == current_platform.fp8_dtype()
q_dtype = None
if is_quantized:
q_dtype = torch.float8_e4m3fn
q_dtype = current_platform.fp8_dtype()

out_hidden_states = torch.empty_like(test_tensors.rank_tokens)
total_num_tokens = test_tensors.rank_tokens.size(0)
Expand Down Expand Up @@ -318,7 +321,7 @@ def torch_moe_impl(
.to(a.dtype)
)

is_quantized = w1.dtype == torch.float8_e4m3fn
is_quantized = w1.dtype == current_platform.fp8_dtype()
a_dtype = a.dtype
if is_quantized:
w1 = w1.to(dtype=torch.float32) * w1_scale
Expand Down Expand Up @@ -367,7 +370,7 @@ def _deep_ep_moe(
"FP8 dispatch interface is available only in low-latency mode"
)

is_quantized = w1.dtype == torch.float8_e4m3fn
is_quantized = w1.dtype == current_platform.fp8_dtype()
device_idx = torch.accelerator.current_device_index()
w1 = w1.to(device=device_idx)
w2 = w2.to(device=device_idx)
Expand Down Expand Up @@ -441,7 +444,7 @@ def _deep_ep_moe(
(222, 1024, 2048),
]

DTYPES = [torch.bfloat16, torch.float8_e4m3fn]
DTYPES = [torch.bfloat16, current_platform.fp8_dtype()]


@pytest.mark.parametrize("dtype", DTYPES)
Expand Down Expand Up @@ -496,7 +499,7 @@ def test_deep_ep_moe(
(64, 1024, 2560),
(222, 1024, 2560),
]
DTYPES = [torch.float8_e4m3fn, torch.bfloat16]
DTYPES = [current_platform.fp8_dtype(), torch.bfloat16]
USE_FP8_DISPATCH = [True, False]


Expand Down
Loading