rope dim - #17
Open
JaredforReal wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR generalizes the SM90 dense decode split-KV MLA kernel to support both head_size_k=576 (with RoPE dimension) and head_size_k=512 (no RoPE) by making HEAD_DIM_K a compile-time template parameter and adjusting tiling/barrier/shared-memory usage accordingly.
Changes:
- Templatize traits and kernel entrypoints on
HEAD_DIM_K, and add 512/576 explicit instantiations for fp16/bf16. - Make Q/K tiling and barrier counts depend on
NUM_TILES_DIM_K, and gate the 8th tile path behindREUSE_ROPE. - Update the public API dispatch to select the correct kernel specialization based on
head_size_k.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| csrc/sm90/decode/dense/traits.h | Parameterizes decode traits by HEAD_DIM_K and introduces derived constants (NUM_TILES_DIM_K, Q_BYTES, REUSE_ROPE) used throughout the kernel. |
| csrc/sm90/decode/dense/splitkv_mla.h | Updates kernel declaration to include HEAD_DIM_K template parameter. |
| csrc/sm90/decode/dense/splitkv_mla.cuh | Adapts kernel internals to variable tile counts and optional RoPE tile reuse; updates runtime assertions and shared-memory layout selection. |
| csrc/sm90/decode/dense/instantiations/fp16.cu | Adds explicit fp16 instantiations for 576 and 512 head dims. |
| csrc/sm90/decode/dense/instantiations/bf16.cu | Adds explicit bf16 instantiations for 576 and 512 head dims. |
| csrc/sm90/decode/dense/config.h | Introduces HEAD_DIM_K_NOPE=512 alongside the existing 576 configuration. |
| csrc/api/dense_decode.h | Dispatches to the appropriate HEAD_DIM_K specialization based on head_size_k. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+22
to
+26
| static constexpr int TILE_SIZE_K = 64; | ||
| static constexpr int REUSE_ROPE = (TILE_SIZE_K == PAGE_BLOCK_SIZE) \ | ||
| && (TILE_SIZE_K == (HEAD_DIM_K - HEAD_DIM_V)); | ||
| static constexpr int Q_BYTES = BLOCK_SIZE_M * HEAD_DIM_K * sizeof(InputT); | ||
| static constexpr int NUM_TILES_DIM_K = HEAD_DIM_K / TILE_SIZE_K; |
Comment on lines
+1287
to
+1291
| template<typename InputT, int HEAD_DIM_K> | ||
| void run_flash_splitkv_mla_kernel(DenseAttnDecodeParams ¶ms) { | ||
| FLASH_ASSERT(params.d == Config::HEAD_DIM_K); | ||
| if constexpr(HEAD_DIM_K > Config::HEAD_DIM_V) { | ||
| // with rope dim = 64 | ||
| FLASH_ASSERT(params.d == Config::HEAD_DIM_K); |
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.
No description provided.