Back to blog
ai-engineering

TileLang attention on MI250X beats AMD CK at head size 256

Our TileLang prefill attention reads 1.06-1.18x AMD's Composable Kernel and 1.38-1.93x PyTorch on MI250X at head size 256. How, and what to verify first.

HA

November 8, 2026

4 min read

TileLang attention on MI250X beats AMD CK at head size 256

In short: AI language models spend much of their time on one step called attention, where each word looks back at the words before it. AMD ships its own hand-tuned code for this step. We wrote our own version in TileLang, an open tool that targets both AMD and NVIDIA chips, and on the AMD GPUs of Europe's LUMI supercomputer it runs 6–18% faster than AMD's own for the model shape we tested. Faster attention means answers start sooner and the same hardware serves more people.

We are building attention and mixture-of-experts kernels in TileLang, an open kernel language, for AMD's Instinct MI250X on the LUMI supercomputer. Our goal is one kernel source that holds its own against the vendors' libraries. For prefill attention at head size 256, it does: our kernel reads 1.06–1.18× AMD's Composable Kernel (CK) flash attention and 1.38–1.93× PyTorch's attention, with both timed in the same process.

Setup: one GCD (half an MI250X) on LUMI-G, ROCm 7.2.3, the attention shape of a Qwen 27B model (24 query and 4 key/value heads, head size 256, causal), lengths from 1k to 16k tokens plus real inputs from the model, November 2026.

Grouped-query attention, read once

In grouped-query attention (GQA) six query heads share one key/value head. A plain kernel reads each K/V tile once per query head. Ours gives one workgroup a block of query positions for all six heads, so each K/V tile is read once instead of six times, and Q stays in registers.

The first version already beat PyTorch's attention: 1.48× at 1,024 tokens, 1.22× at 4,096 and 1.18× at 8,192 (PyTorch 2.7.1 on ROCm 6.2), at 2.5e-4 to 2.6e-4 error against float64. Reworking loads and tiles then took it past CK: 1.16× at 1k, 1.14–1.15× at 4k, 1.09–1.10× at 8k and 1.08× at 16k.

TileLang prefill attention vs AMD Composable Kernel, speed ratio ours ÷ CK
LengthOurs ÷ CK
1k tokens1.16×
4k tokens1.14–1.15×
8k tokens1.09–1.10×
16k tokens1.08×

One GCD of AMD MI250X on LUMI, ROCm 7.2.3, both kernels timed in the same process. Ranges are across runs; bars show the upper value.

What made the difference on MI250X

  • Count shared memory first. MI250X allows 64 KB of shared memory (LDS) per workgroup. With head size 256, tiles that fill all 64 KB did not launch, most likely because TileLang adds small reduce workspaces on top. At 48 KB of tiles they launch.
  • Occupancy decides tile choice. How many workgroups fit on a compute unit, set by registers and the LDS budget, decided which tiles won, and it is invisible at source level.
  • GQA packing pays most at head size 256, where each K/V tile is largest.

Verify against float64, not fp16

One finding is worth knowing before you start. TileLang's own AMD flash-attention example reported every output about 5% off, which looks like a kernel bug. It was not. Against a float64 computation the kernel's error was 0.028%, the same as PyTorch's scaled_dot_product_attention, while the example's fp16 reference drifted to 4.3% at 4,096 tokens (0.07% at 256, 0.3% at 1,024). An error that grows smoothly with length and hits every element evenly points to precision in the reference, not to a tile or layout bug. Compute the reference in fp32 or float64; we will send that fix to the TileLang maintainers.

Relative error against float64
TileLang kernelPyTorch SDPAExample fp16 reference
1,024 tokens0.028%0.028%0.33%
4,096 tokens0.028%0.028%4.3%

Relative error of each result against a float64 computation. Lower is better. TileLang's AMD flash-attention example on one GCD of AMD MI250X, PyTorch 2.7.1, ROCm 6.2.

Limits

  • The 1.06–1.18× uses C edits on TileLang's generated source, or hand-structured forms on our patched TileLang fork (not yet upstream). Stock TileLang alone reaches 0.93× of CK at head size 256 and 8k tokens.
  • At head size 128 our kernels beat CK up to about 2,500 tokens (a fork-only form edges ahead at 2,800–3,100), and CK leads from about 5,000 tokens up, where we read 0.946–0.971×.

We acknowledge the EuroHPC Joint Undertaking for awarding this project access to the EuroHPC supercomputer LUMI, hosted by CSC (Finland) and the LUMI consortium, through a EuroHPC Development Access call (EHPC-DEV-2026D11-419).

Sources

Tags

gpu-kernelsllm-opsperformance
HA

About the author

Hamza Abdagić

View profile