RDNA support and optimization in AMD’s Composable Kernel

Fast AI on AMD’s consumer GPUs needs fast kernels. The Composable Kernel (CK) library supplies those kernels for many important workloads, but its support for RDNA3 and RDNA4 GPUs was very limited. The library mainly targeted AMD’s CDNA data-center architectures instead. We changed that: we brought full RDNA support to CK’s core operations and tuned them for high performance.

About the customer and the project

AMD develops the Composable Kernel library as part of its ROCm software stack. CK provides optimized kernels for machine learning workloads on AMD GPUs, and several major projects build on it:

  • MIOpen, the deep learning library behind PyTorch’s AMD GPU support, uses CK’s convolution kernels.
  • Aiter, an inference library, uses CK’s GEMM, FMHA and MoE kernels.
  • FBGEMM, a matrix multiplication library, uses CK’s GEMM kernels.
  • FlashAttention, the official implementation of FlashAttention and FlashAttention-2, uses CK’s FMHA kernels.

Improving CK therefore improves the whole software stack above it.

The challenge

CK was built around CDNA, AMD’s data-center architecture. RDNA, AMD’s consumer architecture, works differently at the instruction level. On top of that, the distinction matters beyond gaming GPUs: the new MI455X accelerator is CDNA5 but borrows several RDNA4 features, such as wave size 32 and Wmma instructions. Solid RDNA support in CK was therefore a requirement, not a nice-to-have.

The work covered two areas. First, all GEMM-based algorithms: plain GEMM, block-scale GEMM, batched GEMM, grouped GEMM, and forward and backward convolution, which CK computes through implicit GEMM. Second, FMHA (FlashAttention): forward, backward, and the forward variants for split-KV, append-KV and paged KV.

Our approach

One implementation for all GEMM workloads. We added a single RDNA implementation shared by every GEMM-based algorithm, including convolutions. This choice paid off immediately. When the MI455X arrived with its new instructions, its support could build on the same code. A per-workload implementation would have meant reworking each one separately.

Scheduling for higher occupancy. We built the compute pipelines around instruction schedules that fit the RDNA register budget. Keeping register use low raises occupancy, and higher occupancy keeps the GPU busy.

One performance for every layout. On earlier RDNA GPUs, some matrix layouts were slower than others. On RDNA4 we used the new global load with transpose instructions, so all layouts now reach the same performance. Users no longer need to pick their data layouts around kernel limitations.

An epilogue without a bottleneck. The epilogue writes results to global memory. We restructured it to avoid traffic through shared memory (LDS), while keeping writes coalesced. The output stage no longer competes with the compute stage for shared-memory bandwidth.

FMHA extended to RDNA. CK Tile already implemented FMHA for CDNA. We extended it to RDNA and its differences. RDNA3 duplicates matrix registers between lanes 0-15 and 16-31 for the A and B matrices, so we added wave-level permutations before the second GEMM. CDNA supports both 32×32 and 16×16 MMA instructions, while RDNA supports only 16×16. We extended the dropout implementation so both configurations produce the same results.

The result

CK now runs its full GEMM family and FMHA workloads on RDNA3 and RDNA4 GPUs. On RDNA4, FP16 GEMM at M=N=K=8192 reaches up to 127.5 TFLOPS, and all four layouts (RCR, RRR, CRR, CCR) stay within about 5% of each other. FP8 reaches 247 TFLOPS for the RCR layout, roughly twice the FP16 number.

The shared implementation also made the MI455X easier to support, since its RDNA4-derived instructions plug into the same code.

Key takeaway

Architecture-specific tuning is expensive when each workload gets its own implementation. By sharing one RDNA implementation across all GEMM workloads, this project made the initial support cheaper to build and the follow-up hardware (MI455X) cheap to adopt. That is the maintainability argument for common code in performance libraries.

Want this for your project?

We help customers get the most out of AMD and other GPUs, from kernel optimization to full library support across architectures.

Contact us to discuss how we can help with your performance engineering project.

Want to read more? You can read about more projects we worked on by checking our other case studies.

Scroll to Top