AMD Engineers: Triton Kernels for AlphaFold3-Style Triangle Operations Cut Forward Peak Memory 69x
AMD's ROCm team describes geometric-nn-ops, a standalone PyTorch library of Triton kernels for the triangle attention and triangle multiplicative update in AlphaFold3-style co-folding models. The blog explains how a flash-attention-style kernel handles the row-shared pair bias without ever materializing the full O(N³) logit tensor, reducing peak memory by a factor of about 69 in their forward-pass test at N=768 on an MI355X GPU. It also documents how the same fp32 precision setting resolves to XF32 instructions on CDNA 3 but to three-product bf16 emulation on CDNA 4, and why the multiplicative update's Triton path is forward-only.
AlphaFold3-style co-folding models update an N×N pair representation — one feature vector per pair of the complex's N tokens — with two triangle operations in every trunk block: triangle attention and the triangle multiplicative update. Both sum over a third token k, so their cost grows as N³ while the rest of the trunk grows as N². Doubling the complex size multiplies triangle-op work by up to eight and everything else by up to four, so on large complexes these two operations dominate.
AMD's ROCm engineering team has published geometric-nn-ops, a standalone PyTorch library of Triton kernels for these operations on AMD Instinct GPUs. The blog explains the central memory trick: triangle attention around the starting node computes, for every row i, the softmax over k of (q_ij · k_ik / √D + b_jk) applied to v_ik. Viewed as attention, that is a batch of N independent problems, one per row, except for the bias: b_jk does not depend on i, so all N rows share one [H, N, N] bias. A direct PyTorch implementation materializes [B, N_seq, H, N, N] logits — O(N³·H) memory per call. The Triton kernel is a flash-attention-style kernel (online softmax in the forward, recomputation in the backward) built around that shared bias, and never forms that tensor.
The mechanism is a pointer offset. Each program instance owns a 64-row query tile of one (batch, row, head) triple and streams 16-row key and value tiles past it. The bias pointer is offset by the batch and head indices only, never by the row index, so every program working on any row of a given (batch, head) pair reads the same bias tile. The broadcast across N_seq rows costs no memory: there is no [B, N_seq, H, N, N] copy. In AMD's testing on an MI355X GPU at N=768 (bf16, H=4, D=32), the forward pass peaked 0.15 GiB above its inputs against 10.41 GiB for a direct einsum-and-softmax PyTorch implementation — a reduction by a factor of about 69. For forward and backward together, the reduction factor is about 9.5.