Repository navigation
Conversation
The fused fp16 flash-decode path does not template head_dim 512 or zero-length new KV (KV-sharing layers that re-read an earlier layer's cache), so those single-token decodes fell back to the multi-kernel hipBLASLt pipeline. Every single-token decode also read seqlens_k back to the host (D2H + stream sync) in the first GQA layer of each forward pass. - hip_gqa_decode_f32: single-query split-K decode for head_dim 128/256/512, fp32 or fp16 Q/KV/out, fused non-interleaved Q RoPE, last-block merge. gqa_forward_hipblaslt routes eligible decodes here instead of Steps 8-10. - Device-length mode: with a shared past/present buffer each batch derives its key range, sliding-window start and RoPE position from seqlens_k on the device. The host only plans the split grid from an estimate (RuntimeState::seqlens_hint_total: set by every real read, advanced by sq once per forward pass); the last split runs to the end of the range, so any estimate is correct and an accurate one is fastest. - The fused path skips the seqlens_k readback for in-place decode and gives the tuning lookup the same estimate. Gemma-4 E4B AWQ uint4 decode on gfx1151 (default settings), over main: 51.63 -> 54.44 TPS (+5.4%, 388-token prompt), 50.08 -> 52.99 (+5.8%, 2k), 43.43 -> 46.17 (+6.3%, 16k); +5.1% to +6.7% with HIPDNN_EP_MATMUL_DP4A=0. Co-Authored-By: Cursor Claude Opus 5.5 <cursoragent@cursor.com> Made-with: Cursor
donghanbj
requested review from
CaymanYang,
amd-bqiao,
amd-mingw,
asparkhi,
edelaye,
fhanuman,
qianglin-amd,
sambanerxilinxamd and
wcy123
as code owners
October 25, 2026 11:00
|
Thanks for opening a PR! This project follows LLVM's incremental-development and AI-tool-use Before requesting review, please check that:
Reviewers are assigned through |
Co-Authored-By: Cursor Claude Opus 5.5 <cursoragent@cursor.com> Made-with: Cursor
L2 Accuracy Results (EP vs CPU)
Threshold: 0.01 | Run: 8055 - Commit: |
Binary sizesBaseline: run 40617608668 -
MorphiZen EP Performance Results
EPContext Export Performance
EPContext Import Performance
OGA Benchmark Results
OGA Wheel Smoke (Python benchmark_e2e.py)
VLM Benchmark Results
TTFT / TPS vs mainBaseline: run 40617608668 -
Run: 8055 - Commit: |
Kernel Unit Test Results
Leaves: 16 (0 failed) | Cases: 289 (0 failed) Mode: lookup | Coverage: 1 | Run: 8055 - Commit: |
Contributor
Author
|
/run-test models=all node=xsjnucstrhalo09 |
Contributor
|
ROCm GenAI CI finished with result: FAILURE.
|
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Single-token GQA decode gets a split-K kernel for the cases the fused fp16 flash-decode path does not template (head_dim 512 and KV-sharing layers), and decode over an in-place KV cache no longer reads
seqlens_kback to the host. Gemma-4 E4B decode is 5-6% faster on gfx1151.Related issue or design
None.
Why
seqlens_kback to the host (D2H + stream sync) in the first GQA layer of each forward pass, although with a shared past/present buffer the append, RoPE and attention kernels can take the length from the device.What
hip_gqa_decode_f32: single-query split-K decode for head_dim 128/256/512 (1, 2, 4 or 8 query heads per KV head; fused Q RoPE only for head_dim >= 256), fp32 or fp16 Q/KV/out, fused non-interleaved Q RoPE, last-block merge.gqa_forward_hipblasltroutes eligible decodes here instead of Steps 8-10; other geometries keep the existing pipeline.seqlens_kon the device. The host only plans the split grid from an estimate (RuntimeState::seqlens_hint_total: set by every real read, advanced bysqonce per forward pass). The last split runs to the end of the range, so any estimate is correct and an accurate one is fastest. Empty splits skip the q setup.seqlens_kreadback for in-place decode and gives the tuning lookup the same estimate.Test plan
hipgpu.dlland the custom kernels, rebuilthip-mlir-opt/hip-compiler:MorphizenMLIRLitTests651 passed, 9 unsupported, 0 failed.Performance
Decode TPS, Gemma-4 E4B AWQ uint4, gfx1151 (Windows), 128 generated tokens, mean of 3 iterations:
HIPDNN_EP_MATMUL_DP4A=0Prefill / TTFT unchanged (decode-only change).
Notes for reviewers
HIPDNN_EP_MATMUL_DP4A=0the output is identical to main. The split-K kernel accumulates the attention in a different order than the hipBLASLt pipeline.HIPDNN_EP_GQA_F32_DECODE=0disables the new kernel.Checklist
AI assistance (Cursor, Claude Opus 5.5) was used for profiling analysis, the kernel and dispatch implementation, and the benchmark runs. I reviewed the changes and validated them with the lit suite and the end-to-end runs above.