[SDPA][HipDNN] ASM kernel loading and dispatch#5686
Merged
AnaghaRaoAMD merged 5 commits intousers/dahawkin/hipdnn-aiter-ck-spda-pocfrom Mar 23, 2026
Merged
[SDPA][HipDNN] ASM kernel loading and dispatch#5686AnaghaRaoAMD merged 5 commits intousers/dahawkin/hipdnn-aiter-ck-spda-pocfrom
AnaghaRaoAMD merged 5 commits intousers/dahawkin/hipdnn-aiter-ck-spda-pocfrom
Conversation
Contributor
DarylHawkinsAMD
left a comment
There was a problem hiding this comment.
Looks good, just had one question inline
…pda-poc' into user/anarao/kernelLoadDispatch
jerehartAMD
reviewed
Mar 20, 2026
Contributor
jerehartAMD
left a comment
There was a problem hiding this comment.
Looks good! I have a couple of comments, but I think the only one that's especially important to address is the move constructor one
jerehartAMD
approved these changes
Mar 23, 2026
1f85499
into
users/dahawkin/hipdnn-aiter-ck-spda-poc
6 checks passed
DarylHawkinsAMD
pushed a commit
that referenced
this pull request
Mar 27, 2026
## Motivation
Implements the complete kernel loading and dispatch pipeline for the
fwd_hd128_bf16_rtne.co ASM kernel, including workspace size calculation.
## Technical Details
**Kernel Execution Implementation**
1. **SdpaFwdPlan** - Kernel execution state:
- Stores kernel module/function handles, tensor UIDs and metadata
(dims, strides), and attention scale
- execute(): Populates fmha_fwd_v3_args (656 bytes) and launches via
hipModuleLaunchKernel()
- Grid dimensions: [ceil(S_q/256), H_q, B]
- Block dimensions: [512, 1, 1] (fixed for this kernel)
- Strides: Converted from elements to bytes (stride x 2 for BF16)
- Module lifecycle: Loaded on plan build, unloaded in destructor
2. **SdpaFwdPlanBuilder** - Plan creation:
- buildPlan(): Loads kernel via hipModuleLoad() and extracts tensor
metadata from graph
- Parses Q/K/V tensor dimensions and strides from SDPA graph node
- Computes attention scale (default: 1/sqrt(D_qk))
3. **Workspace**: Forward-only inference kernel uses 64KB LDS internally
and requires no external workspace allocation; getWorkspaceSize()
returns 0. LSE (log-sum-exp) buffer is an optional output tensor
(stats_tensor_uid), not workspace.
Builds on workspace sizing from PR #5626 and cleanup from PR #5632.
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.
Motivation
Implements ASM kernel loading and dispatch
Technical Details
Kernel Execution Implementation
Implements the complete kernel loading and dispatch pipeline for
fwd_hd128_bf16_rtne.coASM kernel:SdpaKernelPlan - Kernel execution state (26 member variables):
execute(): Populatesfmha_fwd_v3_args(656 bytes) and launches viahipModuleLaunchKernel()SdpaKernelPlanBuilder - Plan creation:
buildPlan(): Loads kernel viahipModuleLoad()and extracts tensor metadata from graphKey Implementation Details:
HIP_LAUNCH_PARAMmechanism for large arg structures[ceil(S_q/256), H_q, B][512, 1, 1](fixed for this kernel)Modified Files:
src/SdpaKernelPlan.{hpp,cpp}- Execution implementationsrc/SdpaKernelPlanBuilder.cpp- Plan building with graph parsingTest Plan
Verified with existing unit test infrastructure and integration tests
Submission Checklist