Files
vllm/tests/kernels/moe/test_moe_kernel_oracle.py
Qiuyang YueGitHubmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
9bfd878a48 [MoE] [MoE Refactor] Add moe kernel oracle abc 37753 (#43461)
Signed-off-by: Qiuyang Yue <[email protected]>
Signed-off-by: qyYue1389 <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2026-06-25 09:34:03 -04:00

52 lines
1.8 KiB
Python

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Tests for the MoEKernelOracle ABC introduced in PR series for #37753.
This file contains a single canonical demonstration that
`UnquantizedMoEKernelOracle` methods delegate one-to-one to the
existing module-level functions in `oracle/unquantized.py`. Each method
on `UnquantizedMoEKernelOracle` follows the same `return module_fn(args)`
pattern, so verifying delegation for one method (`make_kernel`) gives
high confidence in the rest.
"""
from unittest.mock import patch
from vllm.model_executor.layers.fused_moe.experts.triton_moe import TritonExperts
from vllm.model_executor.layers.fused_moe.oracle import UnquantizedMoEKernelOracle
from vllm.model_executor.layers.fused_moe.oracle.unquantized import (
UnquantizedMoeBackend,
)
class TestUnquantizedDelegation:
"""UnquantizedMoEKernelOracle methods must delegate to the existing
module-level functions; behaviour is bit-identical."""
def test_make_kernel_delegates(self) -> None:
quant_config = object()
moe_config = object()
experts_cls = TritonExperts
sentinel_kernel = object()
with patch(
"vllm.model_executor.layers.fused_moe.oracle.unquantized."
"make_unquantized_moe_kernel",
return_value=sentinel_kernel,
) as mocked:
out = UnquantizedMoEKernelOracle().make_kernel(
quant_config,
moe_config,
UnquantizedMoeBackend.TRITON,
experts_cls,
)
mocked.assert_called_once_with(
quant_config,
moe_config,
UnquantizedMoeBackend.TRITON,
experts_cls,
None, # routing_tables default
)
assert out is sentinel_kernel