-
-
Notifications
You must be signed in to change notification settings - Fork 16.1k
[NVIDIA][test] Tests for flashinfer TRTLLM BF16 MoE #33715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
robertgshaw2-redhat
merged 8 commits into
vllm-project:main
from
Linda-Stadter:trtllmgen_bf16_moe_tests
Feb 11, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
673f517
[NVIDIA][test] Tests for flashinfer TRTLLM BF16 MoE
Linda-Stadter ec63db7
Merge branch 'main' into trtllmgen_bf16_moe_tests
Linda-Stadter 33dd8b1
Merge branch 'main' into trtllmgen_bf16_moe_tests
pavanimajety 04bd525
Renaming test configs
Linda-Stadter cee5a12
Merge branch 'main' into trtllmgen_bf16_moe_tests
pavanimajety cd4f3fc
Option for cutlass and use cutlass in E2E tests
Linda-Stadter df4d783
Merge branch 'main' into trtllmgen_bf16_moe_tests
Linda-Stadter 7eda962
Merge branch 'main' into trtllmgen_bf16_moe_tests
Linda-Stadter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
tests/kernels/moe/test_unquantized_backend_selection.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| from unittest.mock import patch | ||
|
|
||
| import pytest | ||
|
|
||
| from tests.kernels.moe.utils import make_dummy_moe_config | ||
| from vllm.model_executor.layers.fused_moe.oracle.unquantized import ( | ||
| UnquantizedMoeBackend, | ||
| select_unquantized_moe_backend, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "platform_method,expected_backend", | ||
| [ | ||
| ("is_cuda", UnquantizedMoeBackend.TRITON), # Default CUDA without FlashInfer | ||
| ("is_rocm", UnquantizedMoeBackend.TRITON), | ||
| ("is_cpu", UnquantizedMoeBackend.CPU), | ||
| ("is_xpu", UnquantizedMoeBackend.XPU), | ||
| ("is_tpu", UnquantizedMoeBackend.TPU), | ||
| ("is_out_of_tree", UnquantizedMoeBackend.OOT), | ||
| ], | ||
| ) | ||
| @patch( | ||
| "vllm.model_executor.layers.fused_moe.oracle.unquantized.has_flashinfer", | ||
| return_value=False, | ||
| ) | ||
| def test_select_default_backend_by_platform( | ||
| mock_has_flashinfer, | ||
| monkeypatch, | ||
| platform_method, | ||
| expected_backend, | ||
| ): | ||
| """Test backend selection for different platforms.""" | ||
| with patch( | ||
| "vllm.model_executor.layers.fused_moe.oracle.unquantized.current_platform" | ||
| ) as mock_platform: | ||
| # Set all platform checks to False | ||
| mock_platform.is_cuda.return_value = False | ||
| mock_platform.is_rocm.return_value = False | ||
| mock_platform.is_cpu.return_value = False | ||
| mock_platform.is_xpu.return_value = False | ||
| mock_platform.is_tpu.return_value = False | ||
| mock_platform.is_out_of_tree.return_value = False | ||
|
|
||
| # Set only the specified platform to True | ||
| getattr(mock_platform, platform_method).return_value = True | ||
|
|
||
| moe_config = make_dummy_moe_config() | ||
| selected_backend = select_unquantized_moe_backend( | ||
| moe_config=moe_config, | ||
| use_ep=False, | ||
| use_dp=False, | ||
| ) | ||
|
|
||
| assert selected_backend == expected_backend | ||
|
|
||
|
|
||
| @patch( | ||
| "vllm.model_executor.layers.fused_moe.oracle.unquantized.has_flashinfer", | ||
| return_value=True, | ||
| ) | ||
| @patch( | ||
| "vllm.model_executor.layers.fused_moe.oracle.unquantized.is_supported_config_trtllm_bf16", | ||
| return_value=(True, None), | ||
| ) | ||
| def test_select_cuda_flashinfer_trtllm_backend( | ||
| mock_has_flashinfer, mock_is_supported_trtllm, monkeypatch | ||
| ): | ||
| """Test CUDA backend selection when FlashInfer TRTLLM is available and enabled.""" | ||
| with patch( | ||
| "vllm.model_executor.layers.fused_moe.oracle.unquantized.current_platform" | ||
| ) as mock_platform: | ||
| # Set as CUDA platform | ||
| mock_platform.is_cuda.return_value = True | ||
| mock_platform.is_rocm.return_value = False | ||
| mock_platform.is_cpu.return_value = False | ||
| mock_platform.is_xpu.return_value = False | ||
| mock_platform.is_tpu.return_value = False | ||
| mock_platform.is_out_of_tree.return_value = False | ||
|
|
||
| monkeypatch.setenv("VLLM_USE_FLASHINFER_MOE_FP16", "1") | ||
|
|
||
| moe_config = make_dummy_moe_config() | ||
|
|
||
| selected_backend = select_unquantized_moe_backend( | ||
| moe_config=moe_config, | ||
| use_ep=True, | ||
| use_dp=False, | ||
| ) | ||
|
|
||
| assert selected_backend == UnquantizedMoeBackend.FLASHINFER_TRTLLM | ||
|
|
||
|
|
||
| @patch( | ||
| "vllm.model_executor.layers.fused_moe.oracle.unquantized.has_flashinfer", | ||
| return_value=True, | ||
| ) | ||
| @patch( | ||
| "vllm.model_executor.layers.fused_moe.oracle.unquantized.is_supported_config_trtllm_bf16", | ||
| return_value=(False, None), | ||
| ) | ||
| def test_select_cuda_flashinfer_cutlass_backend( | ||
| mock_has_flashinfer, mock_is_supported_trtllm, monkeypatch | ||
| ): | ||
| """Test CUDA backend selection when FlashInfer TRTLLM is not available | ||
| and FlashInfer CUTLASS is available.""" | ||
| with patch( | ||
| "vllm.model_executor.layers.fused_moe.oracle.unquantized.current_platform" | ||
| ) as mock_platform: | ||
| # Set as CUDA platform with Hopper capability | ||
| mock_platform.is_cuda.return_value = True | ||
| mock_platform.is_rocm.return_value = False | ||
| mock_platform.is_cpu.return_value = False | ||
| mock_platform.is_xpu.return_value = False | ||
| mock_platform.is_tpu.return_value = False | ||
| mock_platform.is_out_of_tree.return_value = False | ||
| mock_platform.has_device_capability.return_value = True # SM90+ | ||
|
|
||
| # Enable FlashInfer via env var | ||
| monkeypatch.setenv("VLLM_USE_FLASHINFER_MOE_FP16", "1") | ||
|
|
||
| moe_config = make_dummy_moe_config() | ||
|
|
||
| selected_backend = select_unquantized_moe_backend( | ||
| moe_config=moe_config, | ||
| use_ep=True, # CUTLASS requires EP | ||
| use_dp=False, # CUTLASS doesn't support DP | ||
| ) | ||
|
|
||
| assert selected_backend == UnquantizedMoeBackend.FLASHINFER_CUTLASS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't these tolerances a bit large for bf16?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also wondering about this. I got these numbers and the way of checking accuracy from the tests in flashinfer
https://github.com/flashinfer-ai/flashinfer/blob/30bf78e1a05d18aaebd484aa6f3c1db8e4c0b1b4/tests/moe/test_trtllm_gen_fused_moe.py#L1398
and
https://github.com/flashinfer-ai/flashinfer/blob/30bf78e1a05d18aaebd484aa6f3c1db8e4c0b1b4/tests/moe/test_trtllm_gen_fused_moe.py#L1675