mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #348] [MERGED] HIP: reduce packed DS4 attention LDS bank conflicts without changing arithmetic #479
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#479
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/mw00/project-maya/pull/348
Author: @LostVector
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @mw00
Base:
main← Head:upstream/hip-attention-lds📝 Commits (1)
53a0661HIP: add opt-in exact LDS layout for packed DS4 attention📊 Changes
3 files changed (+94 additions, -4 deletions)
View changed files
📝
CMakeLists.txt(+3 -0)📝
src/ds4/ds4_kernels.cu(+40 -4)➕
tests/ds4_attention_layout_bench.cu(+51 -0)📄 Description
This helps AMD GPUs process prompts faster by rearranging attention's temporary data so GPU workers spend less time waiting for the same memory lanes. It keeps the data values and calculations unchanged.
Think of several checkout lanes: if too many workers line up at the same lane, they wait while other lanes sit idle. This change spreads their memory accesses across the lanes more evenly.
Measured impact on our experimental branch: about 16% faster prefill for 32K-token prompts and 18% faster for 8K-token prompts. Prefill is the time spent reading a prompt before generating the answer. Those speedups have not yet been established on the current upstream version. On the upstream base, the attention kernel passed 192 bit-exact comparisons across our three AMD GPUs. The change is opt-in and leaves the existing kernel as the default.
HIP packed sparse attention repeatedly stages BF16 vectors in LDS with a linear row layout. On our RDNA4 cards, permuting those vectors improves the attention kernel without changing the stored values, reduction order, or 16 KiB LDS footprint.
This adds an opt-in
DS4_HIP_ATTN_SWIZZLE=1specialization. The existing kernel remains the default and the CUDA dispatch is unchanged. Staging, dot-product reads and value reads use the same bijective mapping. A standalone HIP test/benchmark covers generated and explicit selections, window-only attention, ragged sizes, single-token and single-head cases, grouping overrides, finite outputs and output guards.This changes the packed-attention kernel only. Upstream also has a separate WMMA attention path, which bypasses this layout when selected. The standalone test uses explicit packed-kernel group sizes to ensure that the on/off comparisons exercise this change; end-to-end applicability depends on the selected attention path.
Rebased and validated against upstream
451f9cb(v1.1.21):maya-ds4andds4_attention_layout_bench; 192 bit-exact comparisons across two Radeon AI PRO R9700 cards and one RX 9070 XT, including fallback repetitions.cmake --build build-hip --target ds4_attention_layout_bench; run./build-hip/ds4_attention_layout_bench 0(device index argument).Earlier full-model evidence, on our experimental branch rather than this upstream base: four fresh-load ABBA arms, 24 measured requests, 32K prefill 884.53 → 1024.89 tok/s (+15.87% throughput), 8K 611.53 → 724.13 (+18.41%). Both paired 32K blocks improved, but there were only two blocks and the interval is wide. Candidate/repeat/reference logits were exact for 195 saved states each. These figures are supporting evidence, not a measured v1.1.20 end-to-end gain. Existing fork checkpoints: https://github.com/LostVector/project-maya/pull/41 and https://github.com/LostVector/project-maya/pull/42.
I also compared the current #344 head: its packed-attention tile accesses remain linear, so this change can be reviewed independently of its multi-GPU transport and pruning work.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.