mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #370] [MERGED] ds4: prompt sparse attention on RDNA4 matrix cores (gfx12 WMMA) #496
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#496
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/370
Author: @Gazelle221B
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @mw00
Base:
main← Head:ds4-attn-wmma-gfx12📝 Commits (1)
6f1bf67Enable DS4 prompt sparse attention WMMA on gfx12📊 Changes
3 files changed (+133 additions, -17 deletions)
View changed files
📝
src/ds4/ds4_kernels.cu(+37 -12)📝
src/ds4/ds4_kernels.cuh(+1 -1)📝
tests/ds4_gguf_test.cu(+95 -4)📄 Description
On RDNA4, DeepSeek's prompt sparse attention ran the scalar FP32 kernel, because
DS4_ATTN_WMMA/attn_wmma_now()only accepted gfx11. In profiles on gfx1201, sparse attention was the largest single part of a long prompt. This change runs the existing WMMA kernel on gfx12 as well, using gfx12's native wave32 layouts:__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32_gfx12takes 8 values per lane. Lanes 0-15 hold k 0-7 and lanes 16-31 hold k 8-15, instead of gfx11's duplicated 16.attn_wmma()passes each half.8 * (lane / 16) + ion gfx12, and2 * i + lane / 16on gfx11.attn_wmma_row()maps it.DS4_ATTN_WMMA=0opt-out. gfx11 device code is byte-identical (gfx1100 assembly compared), and nothing changes on NVIDIA.Independent of #343 and #369.
Prefill, 2x 32 GB AMD GPUs (HIP, gfx1201)
Maya-S six-shard, automatic split, DSpark on, zero prompt reuse, 3 alternating rounds, scalar vs WMMA on the same binary.
DS4_LT=0was set because of #366.Decode (400 tokens) is 26.2 → 28.7 tok/s, i.e. unchanged within noise. With #343's prompt skip also on, WMMA adds 1.33-1.37x at 8K-120K (prefill 823 tok/s at 32K, 856 at 120K). Decode in that combination was too noisy to read (12-29 tok/s in both arms).
Numerics
DS4_ATTN_TEST_EXTREME=1. I haven't been able to run it on gfx11 to see whether the high/residual BF16 scheme shows the same thing there, so I'm leaving it out of the default tests and flagging it here.--no-expert-cache, greedy,spec=0,DS4_STREAM=1 DS4_STREAM_FORCE=012345678 DS4_LANE_CAL=none, identical starting profiles): two scalar processes give bit-identical logits on 23/23 requests, which is the floor. WMMA vs scalar: prompt last-row KL ≤ 4e-5 nats, 21/23 identical greedy answers, with the 32K and 64K answers diverging at generated token 19. On 20 known-answer prompts (including a ~60K needle) WMMA and scalar both score 19/20, with the same outputs.CI-equivalent checks pass: HIP mapping check, server tests, tools tests. I have no CUDA machine to compile on, but the change is under
STRATA_USE_HIPonly.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.