Skip to main content

cuequivariance-ops-torch

Introduction

cuequivariance_ops_torch provides CUDA kernels for the cuEquivariance project's PyTorch components. As such, it contains pytorch bindings to optimized kernels that cuEquivariance's operations map down to. In general, we advice that you access those kernels through cuEquivariance, but you may also find them useful on their own.

Installation

Please install using either pip install cuequivariance-ops-torch-cu12 or pip install cuequivariance-ops-torch-cu13 (depending on the CUDA toolkit you wish to use).

Kernel Factory TriMul kernels

On CUDA 13 wheels, triangle_multiplicative_update runs prebuilt Kernel Factory (KF) TriMul kernels for BF16 calls on the exact shapes each kernel was validated on, on H100 SXM (80GB HBM3), H200, GH200 480GB, B200 and RTX PRO 6000 Blackwell (Server and Workstation Edition). Every other call keeps the existing implementation. The kernels ship as prepackaged cubins and need nothing extra; their outputs match the existing implementation within its numerical tolerance, not bitwise. (Development builds may register a kernel in its CuTe DSL JIT form; that needs nvidia-cutlass-dsl[cu13]==4.7.0 and apache-tvm-ffi==0.1.14.post0, which are not dependencies of the published package. Without them, dispatch keeps the existing implementation.)

A call reaches KF only when the pair AND the module's parameters are BF16, or when FP32 inputs are passed with precision="bfloat16" (the op rounds them first). The automatic mixed precision default, a BF16 pair with FP32 parameters (with or without BF16 autocast), keeps the existing implementation in 0.13 (an FP32-input KF variant is BIO-1329).

In training, a second backward through one forward (retain_graph=True) recomputes the forward and is exact in eager mode, but transiently needs about 1.9x the first backward's memory. Replayed from a CUDA graph, such a second backward gives NaN gradients by design (loud, never silently wrong; the first backward of every replay is exact), where the existing implementation returns correct gradients. Double backward (create_graph=True) raises.

Some KF kernels synchronise their thread blocks with software grid barriers and assume exclusive use of the GPU: under MPS sharing without SM partitions they can hang.

The environment variable CUEQ_TRIMUL_KF_CAMPAIGN selects the mode. It is read once, when cuequivariance_ops_torch is imported:

Value Mode
unset, auto, 1, true, on, yes Default. KF runs where it is admitted (see above); every other call, and any call whose kernel is unavailable on this install or GPU, runs the existing implementation.
0, false, off, no KF disabled: the existing implementation everywhere.
force Testing only. Every BF16 no-grad call on a GPU with a registered KF kernel must run KF; such a call outside the admitted shapes raises instead of falling back. Calls KF never takes (non-BF16, grad-enabled) keep the existing implementation.

Any other value warns and uses the default. Values are case-insensitive.

KF under torch.compile

KF covers the allow-listed shapes, and under torch.compile each one gets its own compiled graph of the calling function. Dynamo keeps at most torch._dynamo.config.recompile_limit graphs per function (8 by default), so with the default torch.compile (automatic dynamic shapes) up to recompile_limit - 2 distinct listed shapes per process get KF once shapes start to vary; further new shapes use the cuEq 0.12 route on one shared dynamic graph (logged once). A shape that already has a KF graph keeps it, results are unaffected, and the calling function never exceeds the limit because of KF when its batch size is fixed. For KF on many shapes, compile with dynamic=False and raise torch._dynamo.config.recompile_limit above the number of shapes. Under DDP or multi-node training each rank applies the limit on its own, so ranks that see shapes in different orders may run KF on different shapes: correctness is unaffected, and a small speed imbalance between ranks is possible.

KF TriMul kernels are used for training only through the packed op (triangle_multiplicative_update); the split-parameter entry (triangle_multiplicative_update_split_parameters) does not use KF for training in 0.13 (it uses the SM90 training owner where that applies, else the PyTorch formula), even where the training shape query answers True or prepare_..._training reports "owner": "kf".

Exported models use the cuEq 0.12 route in 0.13: torch.export (strict or non-strict) and ONNX export (and so TensorRT) never record a KF kernel, and neither does a trace with symbolic sizes outside torch.compile (e.g. make_fx or FakeTensorMode).

Documentation

For detailed usage information of the kernels, please refer to the doc-strings in their respective modules. For higher-level documentations, refer to cuEquivariance.

Pairformer inference primitives

The Torch package also exposes lower-level primitives for integrating Pairformer inference graphs:

  • attention_pair_bias_mask_from_normalized projects an already-normalized pair representation and applies an arbitrary Boolean [B,U,V] mask. The implementation is shape-generic; BF16 D=256, H=16, and square sequence lengths 384 and 512 are the performance-validated configurations. FP16 and BF16 inputs use native low-precision tensor-core products with FP32 accumulation; FP32 inputs retain the higher-accuracy TF32x3 path.
  • pair_update_finalize_masked_attention_bias finalizes a pair residual and, on the shapes admitted for the device's exact compute capability, also returns the next layer's already-masked BF16 attention bias, which attention_pair_bias_masked_cache(..., is_cached_z_proj=True) consumes in place of attention_pair_bias. The canonical shape bounds and measurement scope are in _apb_route_policy.py: _pair_update_finalize_admits for exact capabilities (9, 0), (10, 0) and (12, 0), and _sm100_apb_block_kf_admits for the embedded block. The consumer computes any cache it is handed. On (10, 0) and (10, 3) both halves are taken over by the embedded Kernel Factory APB block (apb_kf_sm100_torch: six CUBINs per exact SM, sm_100a and sm_103a from one source, launched through the CUDA driver, no CuTeDSL at runtime) inside its admitted hull for D_z=384, H=12, DH=64, when the producer has no pair-projection bias and the consumer receives the packed QKV projection with bias, both q/k norm weights and the gate/output biases.
  • pairformer_combined_triangle_multiplication combines incoming and outgoing triangle multiplication after caller-provided non-affine LayerNorm with epsilon 1e-5. Its fused direction join applies the affine middle LayerNorm with epsilon 0.03. This operation intentionally fails closed outside BF16 inference with B=1, D=256, sequence length 384 or 512, and an SM100 GPU. The caller guarantees that the second normalized carrier is the separately materialized spatial transpose of the first; the hot path validates metadata and distinct storage but does not compare tensor contents. It returns the base update before any caller-owned peri-LayerNorm, output mask, dropout, or residual addition; model-level dropout must be disabled for inference. Use pack_pairformer_grouped_projection to convert grouped projection weights to the expected payload/gate layout.

Both operations are registered as torch.library custom operators with fake implementations for torch.compile tracing. See their Python docstrings for the complete input contracts.

Calling convention for declined cells

Call triangle_multiplicative_update unconditionally. Under torch.compile a BF16 cell no kernel owner admits (any architecture, hidden width 256 with a pair width in 256..512 -- the measured band; inference or training) runs the package's compiler-visible reference formula, which is written the way a model's own module is (one gated projection per operand under autograd, one fused projection GEMM without it, contiguous contraction operands) and compiles to the same kernels or better, so a declined call costs no more than the caller's native path (measured on L40S, A100 and H200: inference 1.10-1.50x, training 0.98-1.01x of RFD4's compiled module; the generic Triton route the op used to take there measured 0.58-0.88x). An eager no-grad call no owner admits runs the fused generic route from 2**15 pair rows (B * S * S) and the reference formula below, where the generic route's dispatch cost is not repaid. The shape predicate (triangle_multiplicative_update_inference_shape_is_supported) exists for callers that must decide before the tensors exist; it is not needed to avoid a penalty.

Usage

You can import the library from python:

import cuequivariance_ops_torch

Kernels are primarily exposed as torch.nn.Module, but also provide a lower-level interface as torch.library operators. Generally, the module is responsible for proper input transformation and initialization, and the operator execute the kernel. This allows you to export models using this operations using torch.export, and running inference on them using TensorRT.

Support and Feedback

Please contact the cuEquivariance developers for any issues you might encounter.

Metadata

Release files for cuequivariance-ops-torch-cu12 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for cuequivariance-ops-torch-cu12 0.13.0
File
cuequivariance_ops_torch_cu12-0.13.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
cuequivariance_ops_torch_cu12-0.13.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ ARM64, Linux glibc 2.26+ ARM64 Details

Total release size: 12.0 MB

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
bbc6bcd31b0ea66477be5c04156eeae141fb912c036a8591441afcebd751616b
BLAKE2b-256 checksum
How to use checksums
ef91b70d6f50eca912425429dae573853946e3f8d8225f2a9b7c105878aff01e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags CPython 3.14 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
c33f812ca5844b9e6d2ae5f582930c6bbda22a23149417bf597bff7e238111d1
BLAKE2b-256 checksum
How to use checksums
d53a2e51f0bafcde9c65bbdf7cc02543403f73a30459faaff400c7d9856e4707
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2af3310a0b1a27aff4c4c49faada12cac1f10a0bb919c5200c6ef469288e070c
BLAKE2b-256 checksum
How to use checksums
b110c4fd31d6562512c1971e2125bfa2a3e66ea72595ec5a143638555d358441
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags CPython 3.13 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
8101268f8eb1b9f2db94db28d116aa9e84701f09ba68b0d4b4b184833a0f8474
BLAKE2b-256 checksum
How to use checksums
b31986aad0474691d29c6a899e4a07c4b8366cff7cee9a6a2f6af92aaab49640
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
909d49ac15a4c132b110a20ae755a9f956d2466a19c2f36e0274e03a9558784a
BLAKE2b-256 checksum
How to use checksums
f6c2bdc3ca4ac9560dca4b70aeaa5f39ef19a03f80a3ce9abcbd39ef2a9aa3ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags CPython 3.12 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
5c4c42f16380639e4282725e204c72643350af3246b5335bb8d42fb5e7426f58
BLAKE2b-256 checksum
How to use checksums
0eddc3cbedcaef043456154df7226117c72d1db3c2fa343d9702ab6510250728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a7829f277cba6da5a13bc84536f740fa70ec5db3fd227a81b870bedf46e7f696
BLAKE2b-256 checksum
How to use checksums
f5c6f4781e29342b58431341d5d126009781318a8d188183f66f707dc5af7d5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags CPython 3.11 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
5fa5de520f09bf0e45b1c40dab9e0576a3966b96bd402a92e2dafb27a2d5c571
BLAKE2b-256 checksum
How to use checksums
0e816e9b7d615e65f306b892605b46f3d797e096ef4048732918b3848559f840
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b5adf4001fba4f59f2e9597ed48d1339230f4ef21e70449b4c7a4f22ff750e1e
BLAKE2b-256 checksum
How to use checksums
afb84f41b3d5019d1747af51b43f4325db93757061b3b4f1def2abef2a833d14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / cuequivariance_ops_torch_cu12-0.13.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL cuequivariance_ops_torch_cu12-0.13.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags CPython 3.10 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
67f187654af67632490b4964abcf589e7afcf1a3b7ab738906206ab48b790413
BLAKE2b-256 checksum
How to use checksums
d9935b47b602d8faa9ff0b6b9f3d87c9d475bc0567010d6a21bd7ab254d02972
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.13.0 This release

10 release files

0.9.1

10 release files

0.9.0

10 release files

0.8.1

8 release files

0.8.0

8 release files

0.7.0

8 release files

0.6.1

6 release files

0.6.0

6 release files

0.5.1

4 release files

0.5.0

4 release files

0.4.0

4 release files

0.3.0

4 release files

0.2.0

3 release files

0.1.0

3 release files

0.0.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page