Skip to content

[ROCm] [Perf] Optimize rocm aiter sparse mla indexer - #46172

Open
tjtanaa wants to merge 5 commits into
vllm-project:mainfrom
EmbeddedLLM:opttopkaiter0115
Open

tjtanaa wants to merge 5 commits into
vllm-project:mainfrom
EmbeddedLLM:opttopkaiter0115

Conversation

@tjtanaa

@tjtanaa tjtanaa commented Jun 19, 2026

Copy link
Copy Markdown
Member

Purpose

This is validated using aiter v0.1.16.post2 which is the version used in the vllm/vllm-openai-rocm

Optimize the sparse indexer for topk-token = 2048 following speed of light implementation from ATOM https://github.com/ROCm/ATOM/blob/main/atom/plugin/vllm/attention/layer_sparse_mla.py, e.g. DSv3.2 model, with aiter's cp_gather_indexer_k_quant_cache and indexer_k_quant_and_cache and top_k_per_row_decode.

This alignment is to capitalize the long-term benefits from AITER as ATOM is invested in optimizing these AITER kernels.

Three small kernels are intended to be upstream together due to its small changes, and the long-term benefits brought these kernels. All three kernels integration also provides performance gain.

Test Plan

lm-eval of DSv3.2

Test Result

Block size 1

local-completions ({'model': 'deepseek-ai/DeepSeek-V3.2', 'base_url': 'http://0.0.0.0:8000/v1/completions', 'num_concurrent': 256, 'max_retries': 10, 'max_gen_toks': 2048, 'max_length': 1048576, 'timeout': 60000}), gen_kwargs: ({}), limit: None, num_fewshot: 30, batch_size: auto
|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k|      3|flexible-extract|    30|exact_match|↑  |0.9522|±  |0.0059|
|     |       |strict-match    |    30|exact_match|↑  |0.9530|±  |0.0058|

Block size 64

local-completions ({'model': 'deepseek-ai/DeepSeek-V3.2', 'base_url': 'http://0.0.0.0:8000/v1/completions', 'num_concurrent': 256, 'max_retries': 10, 'max_gen_toks': 2048, 'max_length': 1048576, 'timeout': 60000}), gen_kwargs: ({}), limit: None, num_fewshot: 30, batch_size: auto
|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k|      3|flexible-extract|    30|exact_match|↑  |0.9591|±  |0.0055|
|     |       |strict-match    |    30|exact_match|↑  |0.9598|±  |0.0054|

lm-eval of DeepSeek V4 (represent topk = 1024)

ocal-completions ({'model': 'deepseek-ai/DeepSeek-V4-Pro', 'base_url': 'http://0.0.0.0:8000/v1/completions', 'num_concurrent': 256, 'max_retries': 10, 'max_gen_toks': 2048, 'max_length': 1048576, 'timeout': 60000}), gen_kwargs: ({}), limit: None, num_fewshot: 30, batch_size: auto
|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k|      3|flexible-extract|    30|exact_match|_  |0.9484|_  |0.0061|
|     |       |strict-match    |    30|exact_match|_  |0.9492|_  |0.0060|

DeepSeek V3.2

Concurrency Output tok/s Before Output tok/s After Output Gain Total tok/s Before Total tok/s After Total Gain Mean TPOT Before Mean TPOT After TPOT Change
C1 78.57 78.97 +0.505% 157.45 158.25 +0.505% 12.60 ms 12.58 ms -0.193%
C16 819.39 826.54 +0.873% 1641.98 1656.31 +0.873% 18.77 ms 18.52 ms -1.286%
C32 1325.95 1350.32 +1.838% 2657.08 2705.91 +1.838% 23.54 ms 23.18 ms -1.528%
C64 2004.22 2008.08 +0.193% 4016.26 4024.01 +0.193% 31.23 ms 31.20 ms -0.092%

DeepSeek V4-Flash

Concurrency Baseline output tok/s Optimized output tok/s Throughput gain Baseline TPOT ms Optimized TPOT ms TPOT reduction Baseline E2E ms Optimized E2E ms E2E reduction TTFT change
C1 75.93 80.12 +5.51% 13.08 12.39 +5.27% 13485.97 12781.42 +5.22% -0.86%
C2 143.81 151.38 +5.26% 13.77 13.08 +5.05% 14238.40 13526.44 +5.00% +0.20%
C4 270.97 286.37 +5.68% 14.48 13.78 +4.86% 15114.30 14301.53 +5.38% +30.89%
C8 536.93 566.93 +5.59% 14.61 13.92 +4.78% 15255.85 14448.52 +5.29% +30.57%
C16 999.42 1059.70 +6.03% 15.66 14.84 +5.23% 16389.16 15455.11 +5.70% +26.28%
C32 1753.69 1875.45 +6.94% 17.58 16.53 +5.97% 18677.87 17465.24 +6.49% +20.15%
C64 3034.10 3196.82 +5.36% 20.39 19.43 +4.68% 21583.41 20487.41 +5.08% +16.48%

DeepSeek V4-Pro

Concurrency Baseline output tok/s Optimized output tok/s Throughput gain Baseline TPOT ms Optimized TPOT ms TPOT reduction Baseline E2E ms Optimized E2E ms E2E reduction TTFT change
C1 43.32 46.65 +7.68% 22.97 21.31 +7.23% 23639.11 21952.05 +7.14% -7.38%
C2 82.17 88.09 +7.21% 24.15 22.52 +6.78% 24920.57 23244.70 +6.72% -0.06%
C4 157.00 167.21 +6.50% 25.21 23.58 +6.47% 26086.49 24493.86 +6.11% -26.05%
C8 305.30 324.55 +6.31% 25.87 24.23 +6.35% 26830.69 25239.19 +5.93% -24.80%
C16 561.45 593.94 +5.79% 28.02 26.43 +5.68% 29173.72 27577.56 +5.47% -6.21%
C32 965.09 1028.15 +6.53% 32.31 30.36 +6.05% 33938.80 31857.61 +6.13% +9.03%
C64 1536.90 1622.01 +5.54% 40.41 38.46 +4.84% 42617.04 40381.70 +5.25% +18.42%

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Signed-off-by: tjtanaa <tunjian.tan@embeddedllm.com>
@mergify mergify Bot added rocm Related to AMD ROCm v1 labels Jun 19, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Jun 19, 2026
Signed-off-by: tjtanaa <tunjian.tan@embeddedllm.com>
@tjtanaa
tjtanaa marked this pull request as ready for review June 19, 2026 16:54
@tjtanaa
tjtanaa requested a review from AndreasKaratzas as a code owner June 19, 2026 16:54
((total_seq_lens, head_dim), fp8_dtype),
((total_seq_lens, 4), torch.uint8),
((total_seq_lens, head_dim), FP8_DTYPE),
((total_seq_lens, 1), torch.float32),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any context on this? (both for the 4 -> 1 modification and uint8 -> fp32)

@AndreasKaratzas AndreasKaratzas added the ready ONLY add when PR is ready to merge/full CI is needed label Jun 21, 2026
tjtanaa added 2 commits July 6, 2026 23:38
Signed-off-by: tjtanaa <tunjian.tan@embeddedllm.com>
Signed-off-by: tjtanaa <tunjian.tan@embeddedllm.com>
_ON_GFX942 = False
_ON_GFX950 = False

FP8_DTYPE = current_platform.fp8_dtype()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pre-evaluate the platform DTYPE as the current_platform.fp8_dtype() is a host synchronize op. We should try to invoke it as fewer as possible.

@Fangzhou-Ai

Copy link
Copy Markdown
Collaborator

For coordination: draft #52882 is intended as a more complete superseding
alternative rather than a competing decode-only call-site change. It includes
the exact 2-D MTP-length adapter required by AITER v0.1.19, prefill global-to-local
index conversion, A/B/fallback controls, and the 500K/1M graph-safe native path.
The draft description documents the overlap, full 84-shape matrix, and TP8 model
evaluation. Please treat #52882 as the proposed consolidated direction.

amd-sriram added a commit to amd-sriram/vllm that referenced this pull request Aug 20, 2026
current_platform.fp8_dtype() cannot change after import, but the sparse
MLA indexer ops call it on every invocation - once per DSA layer per
forward, including inside the fused QK prologue custom op. vllm-project#46172 added
the module-level FP8_DTYPE constant but left the call sites untouched.

Route every use in rocm_aiter_mla_sparse.py through FP8_DTYPE and drop
the per-call locals, so exactly one lookup survives, at import.
@mergify

mergify Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @tjtanaa.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Aug 22, 2026
amd-sriram added a commit to amd-sriram/vllm that referenced this pull request Aug 24, 2026
current_platform.fp8_dtype() cannot change after import, but the sparse
MLA indexer ops call it on every invocation - once per DSA layer per
forward. vllm-project#46172 added the module-level FP8_DTYPE constant but left the
call sites untouched.

Route every use in rocm_aiter_mla_sparse.py through FP8_DTYPE and drop
the per-call locals, so exactly one lookup survives, at import.

The fused QK prologue's two call sites are not touched here: vllm#51315
moves that impl and its fake into _aiter_ops.py, where they already read
that file's FP8_DTYPE constant.

Signed-off-by: Sriram Kumar <sriramkumar.kishorekumar@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm v1

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants