You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,17 @@
1
1
## Latest Changes
2
2
3
+
## 0.8.0 (2025-12-05)
4
+
5
+
### Added
6
+
-[Torch/JAX] Blackwell-optimized BF16/FP16 forward and backward kernels for `cuet.triangle_attention` (runs on compute capabilities 10.0 and 10.3). These kernels provide superior performance especially for long sequences and higher head dimensions. This is only supported on cu13 builds as of this release.
7
+
8
+
### Bug fix
9
+
-[Torch/JAX] Fixed index overflow and out of bound issues leading to illegal memory access in `cuet.triangle_attention`
10
+
11
+
### Notes
12
+
-[Torch/JAX] Blackwell-optimized kernels require the sequence length N to be a multiple of 8 for the forward pass; pad the sequence if necessary
13
+
-[Torch/JAX] Blackwell-optimized kernels are currently supported only for CUDA 13 builds
Copy file name to clipboardExpand all lines: cuequivariance_torch/cuequivariance_torch/primitives/triangle.py
+33-1Lines changed: 33 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,7 @@ def triangle_attention(
80
80
(1) Context is saved for backward pass. You don't need to save it manually.
81
81
(2) Kernel precision (fp32, bf16, fp16) is based on input dtypes. For tf32, set it from torch global scope
82
82
(3) Triangle attention kernel supports: all hidden_dim<=32 and divisible by 4 for tf32/fp32, and for all hidden_dim<=128 and divisible by 8 for bf16/fp16. In the rare instance that the kernel does not support an input config, fallback to torch is enabled instead of erroring out.
83
+
(4) Blackwell-optimized kernels (for compute capabilities 10.0 and 10.3) provide superior performance especially for long sequences and higher head dimensions. These kernels require the sequence length N to be a multiple of 8 for the forward pass; pad the sequence if necessary. Currently, this feature is supported only for cu13 builds.
83
84
84
85
Example:
85
86
>>> import torch
@@ -333,8 +334,12 @@ def attention_pair_bias(
333
334
- The proj_z output is experimental to prevent breakage when caching
334
335
of pair bias tensor is enabled in the next release.
335
336
- Tested for bf16, fp16, fp32 and tf32. torch.set_float32_matmul_precision maybe used to toggle between fp32/tf32.
337
+
- Currently, the kernel provides superior performance only when DH (head dimension) is a multiple of 32.
338
+
For non-multiples of 32, we also recommend using graph compilation techniques like torch.compile, in addition.
336
339
337
340
Examples:
341
+
Basic usage without caching:
342
+
338
343
>>> import torch
339
344
>>> from cuequivariance_torch import attention_pair_bias
340
345
>>> if torch.cuda.is_available(): # doctest: +SKIP
@@ -365,7 +370,7 @@ def attention_pair_bias(
365
370
... b_ln_z = torch.randn(z_dim,
366
371
... device=device, dtype=torch.bfloat16)
367
372
... # Perform operation
368
-
... output, proj_z = attention_pair_bias(
373
+
... output = attention_pair_bias(
369
374
... s=s,
370
375
... q=q,
371
376
... k=k,
@@ -378,9 +383,36 @@ def attention_pair_bias(
378
383
... w_proj_o=w_proj_o,
379
384
... w_ln_z=w_ln_z,
380
385
... b_ln_z=b_ln_z,
386
+
... return_z_proj=False,
381
387
... )
382
388
... print(output.shape) # torch.Size([1, 32, 64])
383
389
torch.Size([1, 32, 64])
390
+
391
+
Example with caching (recommended for inference when z doesn't change):
392
+
393
+
>>> # Check cache and determine if z is already projected
394
+
>>> if model_cache is not None and "proj_z" in model_cache: # doctest: +SKIP
395
+
... z = model_cache["proj_z"]
396
+
... is_cached_z = True
397
+
... else:
398
+
... is_cached_z = False
399
+
>>>
400
+
>>> # Call attention_pair_bias
401
+
>>> o, proj_z = attention_pair_bias( # doctest: +SKIP
402
+
... s=s, q=q, k=k, v=v, z=z, mask=mask,
403
+
... num_heads=num_heads,
404
+
... w_proj_z=w_proj_z if not is_cached_z else None,
405
+
... w_proj_g=w_proj_g,
406
+
... w_proj_o=w_proj_o,
407
+
... w_ln_z=w_ln_z if not is_cached_z else None,
408
+
... b_ln_z=b_ln_z if not is_cached_z else None,
409
+
... return_z_proj=True,
410
+
... is_cached_z_proj=is_cached_z,
411
+
... )
412
+
>>>
413
+
>>> # Cache proj_z for next call
414
+
>>> if model_cache is not None and "proj_z" not in model_cache: # doctest: +SKIP
0 commit comments