Skip to content
KernelIndex
Search⌘K

submission 592885

johnny.t.shi · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

No package. Vendor the mirrored source: 48 lines, June 9 Researcher Reciprocity License v1.0.

v1_aiter_mla.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-amd-mixed-mla-592885?include=source"
interfacepython
Compatibility
measured onAMD Instinct MI355X
declared hardwareAMD Instinct MI355X
architecturesgfx950
dtypesbf16, int32

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
AMD Instinct MI355X
82.5µs
#402 of 766
2026-03-19

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:8563b03a79880de1c18a7ba77c6ca5fb33fa7de7efd36cbba3c6068fe7f6dd03
license declaredunknown
license concludedunknown
authorsjohnny.t.shi
imported2026-08-15

Kernel source

v1_aiter_mla.py48 lines
#!POPCORN leaderboard amd-mixed-mla
#!POPCORN gpu MI355X
"""MLA Decode v1 — use aiter's ASM-optimized MLA decode."""
from task import input_t, output_t
import torch
from aiter.mla import mla_decode_fwd

def custom_kernel(data: input_t) -> output_t:
    q, kv_data, qo_indptr, kv_indptr, config = data
    kv_bf16 = kv_data["bf16"]

    batch_size = config['batch_size']
    num_heads = config['num_heads']
    qk_head_dim = config['qk_head_dim']
    v_head_dim = config['v_head_dim']
    sm_scale = config['sm_scale']

    total_kv = kv_bf16.shape[0]
    output = torch.empty((q.shape[0], num_heads, v_head_dim), dtype=q.dtype, device=q.device)

    # Treat contiguous KV as paged with page_size=1
    # kv_bf16 shape: [total_kv, nhead_kv, head_dim] → reshape to [total_kv, 1, nhead_kv, head_dim]
    if kv_bf16.dim() == 3:
        kv_buffer = kv_bf16.unsqueeze(1)  # [total_kv, 1, nhead_kv, head_dim]
    elif kv_bf16.dim() == 2:
        kv_buffer = kv_bf16.unsqueeze(1).unsqueeze(2)  # [total_kv, 1, 1, head_dim]
    else:
        kv_buffer = kv_bf16

    kv_indices = torch.arange(total_kv, device=q.device, dtype=torch.int32)
    kv_last_page_lens = torch.ones(batch_size, device=q.device, dtype=torch.int32)

    mla_decode_fwd(
        q=q,
        kv_buffer=kv_buffer,
        o=output,
        qo_indptr=qo_indptr,
        kv_indptr=kv_indptr,
        kv_indices=kv_indices,
        kv_last_page_lens=kv_last_page_lens,
        max_seqlen_q=1,
        page_size=1,
        nhead_kv=1,
        sm_scale=sm_scale,
    )

    return output
scrolls · 48 lines total

Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0

Best evidence level for this revision: reported

JSON