Skip to content

rope dim - #17

Open
JaredforReal wants to merge 1 commit into
vllm-project:mainfrom
JaredforReal:rope_dim
Open

rope dim#17
JaredforReal wants to merge 1 commit into
vllm-project:mainfrom
JaredforReal:rope_dim

Conversation

@JaredforReal

Copy link
Copy Markdown

No description provided.

Signed-off-by: JaredforReal <w13431838023@gmail.com>
Copilot AI review requested due to automatic review settings July 23, 2026 02:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 behind REUSE_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 &params) {
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);

@LucasWilkinson LucasWilkinson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants