What is geometric-nn-ops?#
2026-10-29
3 min read time
geometric-nn-ops is a library of vendor-neutral GPU kernels for geometry-aware neural networks. Each operation provides a forward pass and a backward pass, and supports training and inference.
The kernels are written in Triton and called through a PyTorch API. Because Triton compiles the same kernel source for different GPU backends, geometric-nn-ops is vendor agnostic. The geometric-nn-ops AMD Life Science release has been validated and optimized for AMD GPUs.
Kernels are grouped into families where each family is a submodule of
geometric_nn_ops_torch. The first family,
geometric_nn_ops_torch.triangle, contains the triangle operations used by
AlphaFold-style protein structure prediction models, such as AlphaFold and
OpenFold.
geometric-nn-ops kernels provide the following advantages:
Triangle attention and the triangle multiplicative update are fused GPU kernels for pair-representation models. The fused kernels avoid materializing large intermediate tensors.
The Triton code base is vendor-neutral. Models don’t need vendor-specific kernel paths.
The
hipequivariance-ops-torchcompatibility package lets existing code written againstcuequivariance_ops_torchrun on AMD GPUs without source changes.
Features#
geometric-nn-ops provides the following features:
Triangle attention: A Triton kernel for
triangle_attentionwith forward and backward passes. It supports an optional pair bias and a boolean key mask, and accepts 4D, 5D, or 6D inputs. A variable-shape mode (dynamic=True) compiles one kernel for all sequence lengths, which avoids recompiling for every input size.Triangle multiplicative update: A Triton forward kernel for
triangle_multiplicative_updatein both theoutgoingandincomingdirections. Its signature matches cuequivariance. When gradients are required, or when no GPU or Triton is available, it falls back automatically to a differentiable pure-PyTorch implementation.Attention with pair bias:
attention_pair_bias()applies pair-bias layer normalization and projection, masked attention, gating, and the output projection, starting from pre-projected queries, keys, and values. This operation is currently implemented in pure PyTorch.Precision control: For
fp32inputs, the Triton kernels readtorch.backends.cuda.matmul.fp32_precision. The"tf32"setting selects the fastest reduced-precisionfp32matmul on the target with at least TF32 accuracy. For example, AMD CDNA3 GPUs use XF32 MFMA instructions, and other targets usebf16emulation. Targets without a reduced-precisionfp32matmul use fullfp32.Drop-in compatibility: The optional
hipequivariance-ops-torchpackage implements thecuequivariance_ops_torchmodule API and routes calls to the geometric-nn-ops kernels.
Use cases#
geometric-nn-ops is designed for the following scenarios:
Protein structure prediction: Accelerate inference for AlphaFold-style models whose trunk is built from triangle attention and triangle multiplicative update blocks.
Model training and fine-tuning: Use the backward passes to train or fine-tune pair-representation models on AMD GPUs.
Porting cuequivariance-based code to AMD GPUs: Run existing
cuequivariance_torchcode on ROCm through thehipequivariance-ops-torchcompatibility package.
Operation support matrix#
Operation |
Forward |
Backward |
Notes |
|---|---|---|---|
|
✅ Triton |
✅ Triton |
Supports optional pair bias and boolean key mask. |
|
✅ Triton |
✅ PyTorch fallback |
Native Triton backward pass is pending. |
|
✅ PyTorch |
✅ PyTorch |
No Triton kernel yet. |
The Triton kernels accept fp32, bf16, and fp16 inputs.
Usage example#
Call the operations from the geometric_nn_ops_torch.triangle module. See
each function’s docstring for the expected tensor layouts and other options.
from geometric_nn_ops_torch.triangle import (
triangle_attention,
triangle_multiplicative_update,
)
# q, k, v: [..., N_seq, N_res, H, D]
o = triangle_attention(q, k, v, bias=pair_bias, mask=mask, scale=scale)
# x: [*, N, N, C_z] pair representation
z = triangle_multiplicative_update(x, direction="outgoing", mask=mask, **weights)