Repository navigation
[ROCm][Perf] gfx950: use FlyDSL fp8 MQA logits kernel for the sparse indexer prefill #59280
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
Closed
amd-sriram
wants to merge
3
commits into
vllm-project:main
from
amd-sriram:rocm/flydsl-prefill-mqa-logits
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
72 changes: 72 additions & 0 deletions
72
tests/v1/attention/test_rocm_flydsl_mqa_logits_dispatch.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,72 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| import sys | ||
| from types import SimpleNamespace | ||
|
|
||
| import pytest | ||
| import torch | ||
|
|
||
| from vllm._aiter_ops import is_aiter_found_and_supported | ||
| from vllm.platforms import current_platform | ||
|
|
||
| if not current_platform.is_rocm() or not is_aiter_found_and_supported(): | ||
| pytest.skip("Requires ROCm with AITER.", allow_module_level=True) | ||
|
|
||
| from vllm._aiter_ops import rocm_aiter_ops | ||
| from vllm.v1.attention.ops import rocm_aiter_mla_sparse as sparse_mod | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "on_gfx942,on_gfx950,aiter_enabled,expected", | ||
| [ | ||
| (True, False, True, "flydsl"), | ||
| (False, True, True, "flydsl"), | ||
| (False, False, True, "triton"), | ||
| (False, True, False, "torch"), | ||
| ], | ||
| ) | ||
| def test_rocm_fp8_mqa_logits_dispatch( | ||
| monkeypatch, on_gfx942, on_gfx950, aiter_enabled, expected | ||
| ): | ||
| called = [] | ||
| out = torch.empty((1, 1)) | ||
|
|
||
| def fake_flydsl(*args, **kwargs): | ||
| called.append("flydsl") | ||
| return out | ||
|
|
||
| def fake_triton(*args, **kwargs): | ||
| called.append("triton") | ||
| return out | ||
|
|
||
| def fake_torch(*args, **kwargs): | ||
| called.append("torch") | ||
| return out | ||
|
|
||
| monkeypatch.setattr(sparse_mod, "_ON_GFX942", on_gfx942) | ||
| monkeypatch.setattr(sparse_mod, "_ON_GFX950", on_gfx950) | ||
| monkeypatch.setattr(rocm_aiter_ops, "is_enabled", lambda: aiter_enabled) | ||
| monkeypatch.setattr(rocm_aiter_ops, "is_rdna_aiter_enabled", lambda: False) | ||
| monkeypatch.setitem( | ||
| sys.modules, | ||
| "aiter.ops.flydsl", | ||
| SimpleNamespace(flydsl_fp8_mqa_logits=fake_flydsl), | ||
| ) | ||
| monkeypatch.setattr( | ||
| sparse_mod, | ||
| "mqa_logits_module", | ||
| lambda: SimpleNamespace(fp8_mqa_logits=fake_triton), | ||
| ) | ||
| monkeypatch.setattr(sparse_mod, "fp8_mqa_logits_torch", fake_torch) | ||
|
|
||
| result = sparse_mod.rocm_fp8_mqa_logits( | ||
| torch.empty((1, 1, 1)), | ||
| (torch.empty((1, 1)), torch.empty((1,))), | ||
| torch.empty((1, 1)), | ||
| torch.zeros((1,), dtype=torch.int32), | ||
| torch.ones((1,), dtype=torch.int32), | ||
| ) | ||
|
|
||
| assert result is out | ||
| assert called == [expected] | ||
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 |
|---|---|---|
|
|
@@ -912,7 +912,7 @@ def rocm_fp8_mqa_logits( | |
|
|
||
| k_fp8, scale = kv | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: can you please check if we break |
||
| if _ON_GFX942 and rocm_aiter_ops.is_enabled(): | ||
| if (_ON_GFX942 or _ON_GFX950) and rocm_aiter_ops.is_enabled(): | ||
| from aiter.ops.flydsl import flydsl_fp8_mqa_logits | ||
|
|
||
| return flydsl_fp8_mqa_logits( | ||
|
|
||
Oops, something went wrong.
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.
Nit: Does this line test anything given we return
outfrom all of the mocked implementations?