-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
[ROCm] Enable Triton ScaledMM fallback + kernel selection fix #26668
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
ProExpertProg
merged 6 commits into
vllm-project:main
from
shivampr:rocm-triton-fallback
Dec 12, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a55f7d4
feat(rocm): enable TritonScaledMM fallback on ROCm; add CUDA fallback…
shivampr c8b0b83
Refactor: Make is_supported() abstract and move platform checks
shivampr 7b4224e
Fix CPU tests: add AiterScaledMMLinearKernel test, handle Mantis deco…
shivampr 7336d3f
Fix YAML: quote Mantis install command with || operator in CPU test
shivampr 689659f
Fix ruff : split long comment in test file
shivampr 824fbea
Merge branch 'main' into rocm-triton-fallback
shivampr 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
Some comments aren't visible on the classic Files Changed page.
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
91 changes: 91 additions & 0 deletions
91
tests/kernels/quantization/test_scaled_mm_kernel_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,91 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| """Tests for ScaledMM kernel selection logic (CPU-only) | ||
|
|
||
| Run `pytest tests/kernels/quantization/test_scaled_mm_kernel_selection.py`. | ||
| """ | ||
|
|
||
| import inspect | ||
| from abc import ABC | ||
|
|
||
| import pytest | ||
|
|
||
| from vllm.model_executor.layers.quantization.kernels.scaled_mm import ( | ||
| ScaledMMLinearLayerConfig, | ||
| ) | ||
| from vllm.model_executor.layers.quantization.kernels.scaled_mm.aiter import ( | ||
| AiterScaledMMLinearKernel, | ||
| ) | ||
| from vllm.model_executor.layers.quantization.kernels.scaled_mm.cpu import ( | ||
| CPUScaledMMLinearKernel, | ||
| ) | ||
| from vllm.model_executor.layers.quantization.kernels.scaled_mm.ScaledMMLinearKernel import ( # noqa: E501 | ||
| ScaledMMLinearKernel, | ||
| ) | ||
|
|
||
| pytestmark = pytest.mark.cpu_test | ||
|
|
||
|
|
||
| def test_is_supported_is_abstract(): | ||
| """Test that is_supported() is properly defined as abstract.""" | ||
| assert issubclass(ScaledMMLinearKernel, ABC) | ||
| assert hasattr(ScaledMMLinearKernel, "is_supported") | ||
|
|
||
|
|
||
| def test_cpu_kernel_implements_is_supported(): | ||
| """Test that CPUScaledMMLinearKernel implements is_supported() method.""" | ||
| assert hasattr(CPUScaledMMLinearKernel, "is_supported"), ( | ||
| "CPUScaledMMLinearKernel missing is_supported() method" | ||
| ) | ||
| # Verify it's a classmethod by checking if it can be called with the class | ||
| # and by checking the method type | ||
| assert inspect.ismethod(CPUScaledMMLinearKernel.is_supported) or inspect.isfunction( | ||
| CPUScaledMMLinearKernel.is_supported | ||
| ), "CPUScaledMMLinearKernel.is_supported() should be a classmethod" | ||
| # Verify it can be called as a classmethod | ||
| result, reason = CPUScaledMMLinearKernel.is_supported() | ||
| assert isinstance(result, bool), "is_supported() should return a bool" | ||
| assert reason is None or isinstance(reason, str), "reason should be str or None" | ||
|
|
||
|
|
||
| def test_aiter_kernel_implements_is_supported(): | ||
| """Test that AiterScaledMMLinearKernel implements is_supported() method.""" | ||
| assert hasattr(AiterScaledMMLinearKernel, "is_supported"), ( | ||
| "AiterScaledMMLinearKernel missing is_supported() method" | ||
| ) | ||
| # Verify it's a classmethod by checking if it can be called with the class | ||
| # and by checking the method type | ||
| assert inspect.ismethod( | ||
| AiterScaledMMLinearKernel.is_supported | ||
| ) or inspect.isfunction(AiterScaledMMLinearKernel.is_supported), ( | ||
| "AiterScaledMMLinearKernel.is_supported() should be a classmethod" | ||
| ) | ||
| # Verify it can be called as a classmethod | ||
| # (will return False on CPU, which is expected) | ||
| result, reason = AiterScaledMMLinearKernel.is_supported() | ||
| assert isinstance(result, bool), "is_supported() should return a bool" | ||
| assert reason is None or isinstance(reason, str), "reason should be str or None" | ||
| # On CPU, it should return False with a reason about requiring ROCm | ||
| # This validates the method works correctly even on non-ROCm platforms | ||
|
|
||
|
|
||
| def test_cpu_kernel_accepts_all_configs(): | ||
| """Test that CPUScaledMMLinearKernel accepts all config combinations.""" | ||
| configs = [ | ||
| ScaledMMLinearLayerConfig( | ||
| is_channelwise=False, | ||
| is_static_input_scheme=True, | ||
| input_symmetric=True, | ||
| ), | ||
| ScaledMMLinearLayerConfig( | ||
| is_channelwise=True, | ||
| is_static_input_scheme=False, | ||
| input_symmetric=False, | ||
| ), | ||
| ] | ||
|
|
||
| for config in configs: | ||
| can_impl, reason = CPUScaledMMLinearKernel.can_implement(config) | ||
| assert can_impl, ( | ||
| f"CPUScaledMMLinearKernel should accept config {config}: {reason}" | ||
| ) |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.