Before you start: words you need#
| Word | Plain meaning |
|---|---|
| ROCm / HIP | AMD’s GPU software stack and its CUDA-like kernel language (5.a, 7.h). hipify translates most CUDA source mechanically. |
| Wavefront | AMD’s warp: 64 lanes on CDNA 3 and 4 (MI300X, MI355X), 32 on CDNA 5 (MI450 series). |
| CU / WGP | Compute unit, AMD’s SM equivalent; CDNA 5 groups them into work-group processors (WGPs). |
| LDS | Local data share: AMD’s shared memory. 64 KB per CU on MI300X, 160 KB on MI355X. |
| MFMA | Matrix fused multiply-add: the instructions that drive AMD’s Matrix Cores (AMD’s tensor cores). |
| Composable Kernel (CK) | AMD’s C++ template library for GEMM, attention and fused kernels: AMD’s CUTLASS. |
| AITER | AI Tensor Engine for ROCm: AMD’s library of production inference kernels (attention, MoE, GEMM, norms, communication), built from Triton, CK, assembly and FlyDSL kernels. |
| Pallas | JAX’s kernel language. On TPU it compiles through Mosaic TPU; on NVIDIA GPUs through Mosaic GPU. |
1. What is it?#
Everything in 25.a–25.j has a counterpart on other accelerators, with different names and different amounts of hardware help. This lesson maps the ideas onto the two non-NVIDIA platforms that serve large models at scale in 2026:
| Idea | NVIDIA Hopper/Blackwell | AMD CDNA 3/4 (MI300X, MI355X) | AMD CDNA 5 (MI450 series) | Google TPU |
|---|---|---|---|---|
| Thread group | warp (32) | wavefront (64) | wavefront (32) | — (vector lanes, compiler-managed) |
| Matrix unit | tensor core (wgmma, tcgen05) | Matrix Core (MFMA) | Matrix Core | MXU (systolic array, 7.i) |
| On-chip scratchpad | shared memory (228 KB) + TMEM | LDS (64 KB; 160 KB on MI355X) | LDS (320 KB per WGP, reported) | VMEM (vector memory), compiler- or Pallas-managed |
| Bulk async copy | TMA | buffer loads, direct-to-LDS loads | TDM (tensor data mover) | DMA engines, driven by the pipeline Pallas emits |
| Low-precision | FP8, FP4 with block scales | FP8; MI355X adds FP6/FP4 and OCP MX | MX formats | BF16, INT8, FP8 (Ironwood) |
| Kernel languages | CUDA, CUTLASS, CuTe DSL, Triton, Gluon | HIP, CK, Triton, Gluon (AMD), FlyDSL, TileLang | Gluon (cdna5 module), Triton, HIP | Pallas (Mosaic TPU), XLA |
| Production library | cuBLAS, FlashInfer, FlashAttention | hipBLASLt, AITER, CK | AITER | XLA, tpu-inference kernels |
Facts checked on 13 November 2026: AITER v0.1.29 (9 November 2026), Composable Kernel tagged with ROCm 7.2.4, Triton 3.9.0, JAX 0.12.0.1.
2. Why does it matter?#
Fleets are no longer single-vendor. MI355X serves production traffic at several large companies, MI450-series Helios racks started shipping in the second half of 2026 (7.h), and TPUs serve Gemini and, through vLLM’s TPU backend, open models (7.i). Two practical consequences:
- “It compiles” is not “it is fast”. HIP translates CUDA, and Triton kernels run on AMD, but tile sizes, wave size, LDS capacity and the matrix-instruction shapes differ. Untuned kernels commonly leave a large fraction of the hardware idle (7.h’s “assuming CUDA kernels just work”).
- The fastest kernels are vendor libraries. On AMD that means AITER; on TPU, XLA and the Pallas kernels in JAX and vLLM’s TPU backend. Knowing what they contain tells you what an engine can and cannot do on that hardware.
3. Simple analogy#
The same recipe in three kitchens. The NVIDIA kitchen has a conveyor belt (TMA), a robot chef (tensor cores) and a heated pass (TMEM). The AMD kitchen has wider work tables (64-lane wavefronts, large LDS), a different robot whose arms reach different distances (MFMA shapes), and, in its newest version, its own conveyor belt (TDM). The TPU kitchen is a single huge assembly line (the systolic array) where the head chef (the compiler) plans every movement; your recipe says what goes where, not who carries it.
A good cook rewrites the recipe for each kitchen. A recipe card that “works everywhere” (Triton) is a great start, never the end.
4. Tiny example: the same idea in HIP and in Pallas#
HIP: a warp-level reduction. The code is CUDA with hip prefixes, but the reduction tree must
start at the right width, because a wavefront on MI300X/MI355X has 64 lanes:
#include <hip/hip_runtime.h>
__device__ float wave_sum(float v) {
// warpSize is 64 on CDNA 3/4, 32 on CDNA 5 and on NVIDIA; never hard-code 32.
for (int offset = warpSize / 2; offset > 0; offset /= 2)
v += __shfl_down(v, offset);
return v;
}
__global__ void row_sum(const float* x, float* out, int cols) {
float acc = 0.f;
for (int c = threadIdx.x; c < cols; c += blockDim.x)
acc += x[blockIdx.x * cols + c];
acc = wave_sum(acc);
if (threadIdx.x % warpSize == 0) atomicAdd(&out[blockIdx.x], acc);
}A CUDA kernel with for (offset = 16; ...) and a 32-bit __ballot mask compiles under hipify
and returns wrong answers on CDNA 3/4: half the wavefront is never reduced.
Pallas on TPU: a blocked matmul (from the JAX Pallas TPU matmul guide). The kernel body sees
blocks already in VMEM; the BlockSpecs tell Pallas which block each grid step needs, and Pallas
generates the double-buffered HBM → VMEM copies itself.
import functools, jax, jax.numpy as jnp
from jax.experimental import pallas as pl
from jax.experimental.pallas import tpu as pltpu
def matmul_kernel(x_ref, y_ref, z_ref, acc_ref, *, nsteps):
@pl.when(pl.program_id(2) == 0)
def _():
acc_ref[...] = jnp.zeros_like(acc_ref)
acc_ref[...] += jnp.dot(x_ref[...], y_ref[...], preferred_element_type=jnp.float32)
@pl.when(pl.program_id(2) == nsteps - 1)
def _():
z_ref[...] = acc_ref[...].astype(z_ref.dtype)
def matmul(x, y, bm=512, bk=1024, bn=1024):
m, k = x.shape
_, n = y.shape
return pl.pallas_call(
functools.partial(matmul_kernel, nsteps=k // bk),
grid_spec=pltpu.PrefetchScalarGridSpec(
num_scalar_prefetch=0,
in_specs=[pl.BlockSpec((bm, bk), lambda i, j, k: (i, k)),
pl.BlockSpec((bk, bn), lambda i, j, k: (k, j))],
out_specs=pl.BlockSpec((bm, bn), lambda i, j, k: (i, j)),
scratch_shapes=[pltpu.VMEM((bm, bn), jnp.float32)],
grid=(m // bm, n // bn, k // bk)),
out_shape=jax.ShapeDtypeStruct((m, n), x.dtype),
compiler_params=pltpu.CompilerParams(
dimension_semantics=("parallel", "parallel", "arbitrary")),
)(x, y)Compare with 25.a’s Gluon kernel: no barriers, no warps, no swizzles. The TPU’s compiler owns the data movement; the kernel author owns the blocking and the grid order. The guide reports that the default 128-sized blocks are far slower than 512/1024/1024 on recent TPUs, so blocking is still the author’s main lever.
5. Technical explanation#
AMD: what changes for a kernel author#
- Wave size. 64 lanes on CDNA 3/4. Reductions, ballots (
__ballotreturns 64 bits), shuffles and “one warp per row” designs must be rewritten. CDNA 5 moves to wave32 (reported by AMD and analysts), so code must work with both. - Matrix instructions. MFMA shapes such as
v_mfma_f32_32x32x8_f16and16x16x16operate on a wavefront’s registers; accumulators live in dedicated AccVGPRs alongside ordinary VGPRs. CDNA 4 added FP6/FP4 and block-scaled MX variants. Tile shapes tuned for NVIDIA’s 64×Nwgmmaare rarely right. - LDS. 64 KB per CU on MI300X limits pipeline depth and tile size much more than NVIDIA’s 228 KB; MI355X’s 160 KB (with doubled LDS read bandwidth) relaxes it, and CDNA 5 doubles it again.
- Data movement. CDNA 3/4 have no TMA; kernels use wide buffer loads, often directly into LDS, with
software pipelining. CDNA 5 adds the TDM, a tensor DMA engine with descriptors of up to five
dimensions moving tiles between memory and LDS asynchronously: AMD’s TMA. Triton 3.9’s Gluon has an
amd.cdna5.tdmmodule, and AMD’s MI450 Gluon blogs use it. - Chiplets. Eight XCDs each have their own L2; workgroups are distributed round-robin across XCDs by default, so two “neighbouring” tiles may land on different L2s. Tile rasterisation (25.e) must be XCD-aware to get L2 reuse (7.h).
AMD’s kernel stack#
| Layer | What it is | Use it for |
|---|---|---|
| hipBLASLt | vendor GEMM library | default GEMMs, FP8 |
| Composable Kernel (CK) and CK Tile | C++ templates for GEMM, grouped GEMM, attention (FMHA), MoE, with a tile-programming API | AMD’s equivalent of CUTLASS; many AITER kernels |
| AITER | production operator library with Triton, CK, hand-written assembly and FlyDSL backends; C++ and Python APIs | attention (MHA, MLA, paged), fused MoE, block-scaled GEMM, RMSNorm, RoPE + KV cache, all-reduce |
| FlyDSL | AMD’s Python, MLIR-based DSL with explicit layout algebra, aimed at CUTLASS/CuTe DSL users | new AITER MoE and GEMM kernels (AOT-compiled) |
| Triton / Gluon | portable kernels; Gluon’s AMD modules for explicit control | engines’ portable kernels |
| TileLang, Helion | multi-backend DSLs (25.d) | prototyping |
AITER’s README calls it the “default kernel backend for LLM inference on AMD GPUs”: vLLM uses it as the
default ROCm attention backend (ROCM_AITER_FA, ROCM_AITER_UNIFIED_ATTN and others, 18.c) and for
fused MoE, SGLang uses it by default in its ROCm images, and AMD’s ATOM engine is built on it. Its
performance table claims up to 17× for MLA decode and 2.1× end-to-end for DeepSeek-R1 in SGLang
(vendor figures, against earlier baselines).
TPU: what changes for a kernel author#
- There are no threads. A TPU core has a scalar unit, a wide vector unit and MXUs (7.i). The compiler schedules everything; there is nothing like a warp to specialise.
- Memory spaces are explicit: HBM, VMEM (vector memory, the on-chip scratchpad that blocks live
in), SMEM (scalar memory for indices and metadata) and registers. Pallas exposes them
(
pltpu.VMEM,pltpu.SMEM, scalar prefetch). - Pipelining is generated.
pallas_callwith a grid andBlockSpecs produces a double-buffered HBM↔VMEM pipeline;pltpu.emit_pipelinebuilds nested ones inside a kernel. Manual DMA (pltpu.async_copywith semaphores) is available for irregular access such as paged KV caches. - Block shapes follow the MXU. Blocks should be multiples of the MXU’s dimension (256 on recent TPUs, 128 on older ones) and of the (8, 128) vector-register tiling.
- Dimension semantics. Marking grid axes
"parallel"lets the compiler split them across the two TensorCores of chips that have them (and megacore configurations);"arbitrary"axes run in order (reductions).
Ragged paged attention is the TPU’s serving kernel: vLLM’s TPU backend (the tpu-inference
repository, whose GitHub description now says it is moving to vllm-project/vllm-jax) implements it in Pallas,
with several versions (ragged_paged_attention/v2, v3, head-dim-64 and quantised variants). It uses
scalar-prefetched block tables in SMEM and manual DMA to gather KV pages into VMEM — the same problem
as 25.f’s paged decode kernels, solved with DMA descriptors instead of TMA.
Pallas on NVIDIA GPUs: Mosaic GPU#
Pallas also targets Hopper and Blackwell through Mosaic GPU, with explicit warpgroup programming,
TMA, wgmma/tcgen05, emit_pipeline_warp_specialized and set_max_registers. JAX 0.11 (July 2026)
deprecated pallas_call for Mosaic GPU in favour of plgpu.kernel; its module documentation warns the
APIs “can change weekly”. It is the JAX ecosystem’s answer to Gluon and CuTe DSL.
Other accelerators, briefly#
AWS Trainium kernels are written in NKI (Neuron Kernel Interface, 7.j), a tile-level Python language over software-managed SBUF/PSUM memories — structurally closer to Pallas TPU than to CUDA. TileLang, DeepGEMM and FlashMLA announced Huawei Ascend 950 support on 30 September 2026, and DeepEP has an Ascend version too: a sign that the kernel designs of this module travel even when the code does not.
6. Under the hood: porting a kernel from H100 to MI355X#
What actually changes when a tuned CUDA/Triton kernel moves to CDNA 4:
1. Wave size 32 -> 64 every warp-level primitive; "rows per warp" mappings; masks are 64-bit
2. Matrix shape wgmma 64xNx16 -> MFMA 32x32x8 / 16x16x16 (per wavefront); accumulator layout differs
3. Scratchpad 228 KB smem -> 160 KB LDS fewer pipeline stages or smaller tiles
4. Async copy TMA + mbarrier -> buffer loads (direct-to-LDS) + s_waitcnt different pipelining
5. Occupancy registers: 512 VGPRs+AccVGPRs per lane budget vs 255 regs/thread; waves per SIMD
6. L2 one L2 -> 8 per-XCD L2s rasterise tiles per XCD
7. Formats NVFP4 -> MXFP4 (OCP) different block size and scale type (13.g)For Triton kernels, step 1–5 are the compiler’s job, but the autotuning space must change: AMD’s
Triton backend has its own knobs (waves_per_eu, matrix_instr_nonkdim, kpack) and the best
BLOCK_M/N/K values differ. Re-tune, do not reuse NVIDIA configs (25.l).
7. Performance implications#
- Library coverage decides AMD performance. Models whose hot kernels exist in AITER (DeepSeek MLA, Llama/Qwen attention, block-scaled MoE) run well; a new attention variant without an AITER path falls back to portable Triton and can lose a large factor.
- LDS capacity shapes tile choice on MI300X; MI355X narrows the gap.
- TPU performance is about blocking and layout. The Pallas guide’s own example: block sizes 128 → 512/1024/1024 is the difference between poor and good MXU utilisation.
- Cross-vendor benchmarks are kernel benchmarks. “GPU A versus GPU B” results for a model mostly measure which vendor’s kernels exist for that model on that date (7.g).
8. Production implications#
- Pin and test the vendor library. AITER releases weekly (v0.1.27 → v0.1.29 in two weeks of late 2026); vLLM and SGLang ROCm images pin specific versions. Treat an AITER bump like a kernel change: accuracy and performance tests (25.l, 28.d).
- Keep kernels portable where you can. Triton (and Helion/TileLang) kernels give a working AMD path on day one; vendor-specific kernels for the top few hot spots then close the gap.
- Check per-architecture flags. ROCm builds target specific
gfxversions (gfx942MI300X/MI325X,gfx950MI355X,gfx1250for CDNA 5 in LLVM and Triton). A wheel without yourgfxtarget fails or JIT-compiles at start-up. - On TPU, use the platform’s serving stack. vLLM’s TPU backend and JAX serving ship the Pallas kernels; writing your own is rarely needed unless you add an attention variant.
9. Common mistakes#
- Hard-coding 32 as the warp size, or 32-bit ballot masks, in code that may run on AMD.
- Reusing NVIDIA tile sizes and autotuning configs on AMD.
- Ignoring XCD locality in GEMM tile ordering on MI300X/MI355X.
- Assuming NVFP4 checkpoints run natively on AMD; CDNA 4 implements OCP MX formats (MXFP4/6/8).
- Writing TPU kernels with tiny blocks, which leaves the MXU and the DMA engines idle.
- Treating Pallas Mosaic GPU or Gluon’s AMD modules as stable APIs.
- Judging a platform from one model, when the result depends on kernel coverage for that model.
10. Hands-on exercise#
- Take the HIP reduction above, change
warpSize / 2to16, and run it on an MI300X or MI355X (cloud instances exist). Show which outputs are wrong and why. - Run a Triton matmul from 6.e on an MI355X with the NVIDIA-tuned config and with an autotuned AMD
config (include
waves_per_euandmatrix_instr_nonkdim). Report the ratio. - Serve the same model in vLLM on ROCm with the AITER attention backend and with
TRITON_ATTN. Measure decode tokens per second at batch 1 and 64. - On a TPU VM (or the Pallas interpreter on CPU with
interpret=True), run the matmul above with block sizes 128 and 512/1024/1024 and compare.
11. Interview questions#
- Map TMA, warps, shared memory and tensor cores onto AMD CDNA 4 and onto TPU.
- What breaks when a CUDA kernel that assumes 32-lane warps runs on MI300X?
- What is AITER, what backends does it use, and why do engines depend on it on AMD?
- What does CDNA 5’s tensor data mover change for kernel design?
- How does a Pallas TPU kernel express pipelining, and what does the compiler do for you?
- How does ragged paged attention on TPU fetch scattered KV pages?
- Your team must support NVIDIA and AMD with one codebase. What is your kernel strategy?
12. Further reading#
Checked on 13 November 2026.
- [REFERENCE] AITER (v0.1.29) and Composable Kernel
- [REFERENCE] AMD Instinct MI350 Series microarchitecture (ROCm docs)
- [REFERENCE] FlyDSL: expert GPU kernel development with a Python-native MLIR DSL (ROCm blog)
- [REFERENCE] Attention decode on AMD MI450 GPUs: a Gluon kernel optimisation guide (ROCm blog)
- [REFERENCE] JAX Pallas documentation, the TPU matmul guide and Mosaic GPU reference
- [REFERENCE] vLLM TPU backend (tpu-inference) — ragged paged attention kernels in Pallas
- Related lessons: AMD Instinct (7.h), Google TPU (7.i), Trainium and NKI (7.j), the software stack (5.a)