tiledattention header

TiledAttention

Code:

GitHub

Paper at AI on HPC (ISC 2026):

arXiv

TiledAttention is a reference scaled dot-product attention (SDPA) forward kernel for NVIDIA GPUs, implemented in cuTile Python (TileIR) and exposed for PyTorch-oriented workflows. This SDPA implementation is intended as a cuTile-in-Python reference to show that custom hardware-level kernels can be written and iterated directly in Python, including modality-specific attention variants beyond text-only LLM settings. The design follows FlashAttention-style online softmax with tiled (K,V) streaming, while emphasizing schedule-level modifiability (tile shapes, staging, shared-memory layout) for reproducible kernel research.

In the accompanying study, TiledAttention is evaluated against PyTorch SDPA auto-dispatch and explicit baselines across sequence length, head dimension, causal/non-causal masking, and FP16/BF16 precision.

This Hub kernel is packaged as a Python-only CUDA kernel. At runtime it also requires cupy-cuda13x and cuda-tile in the consumer environment.

Benchmark on NVIDIA DGX (GB10)

Full study results dataset using NVIDIA Nsight Compute profiling:

DOI

The figures below summarize the benchmark study results.

Fused vs unfused vs TiledAttention: figure6

Individual SDPA backends vs TiledAttention: figure7

Available Functions

  • sdpa(q, k, v, causal=False, scale=None)

sdpa

Computes forward scaled dot-product attention using the TiledAttention kernel.

Input requirements:

  • q, k, v: CUDA tensors of shape [B, H, S, D]
  • matching shape, dtype, and device
  • dtype: torch.float16 or torch.bfloat16

Parameters:

  • causal (bool, default False): enables causal masking
  • scale (float | None, default None): attention scale; if None, uses 1/sqrt(D)

Returns:

  • output tensor of shape [B, H, S, D] on CUDA

How to Use

# pip install -U kernels
from kernels import get_kernel
import torch

k = get_kernel("thisistaimur/tiledattention", version=1, trust_remote_code=True)

q = torch.randn(1, 8, 1024, 64, device="cuda", dtype=torch.float16)
k_t = torch.randn_like(q)
v = torch.randn_like(q)

out = k.sdpa(q, k_t, v, causal=False)
print(out.shape, out.dtype)

With explicit scale:

out = k.sdpa(q, k_t, v, causal=True, scale=1.0 / (q.shape[-1] ** 0.5))
Downloads last month
-
Apache-2.0
Supported hardwares new
CUDA
all
GPU
B300
288GB
NVIDIA SXM
B200
192GB
NVIDIA SXM
H200
141GB
NVIDIA SXM
H100
80GB
GPU
H800
80GB
GPU
H20
96GB
GPU
L40s
48GB
GPU
L40
48GB
GPU
L20
48GB
GPU
L4
24GB
DGX Spark
GB10
128GB
GPU
RTX PRO 6000 WS
96GB
GPU
RTX PRO 6000 Max-Q
96GB
GPU
RTX PRO 5000
48GB
GPU
RTX PRO 4500 WS
32GB
GPU
RTX PRO 4000
24GB
GPU
RTX PRO 4000 SFF
24GB
GPU
RTX PRO 2000
16GB
GPU
RTX 6000 Ada
48GB
GPU
RTX 5880 Ada
48GB
RTX
RTX 5000 Ada
32GB
GPU
RTX 4500 Ada
24GB
RTX
RTX 4000 Ada
20GB
RTX
RTX 4000 SFF Ada
20GB
GPU
RTX 3500 Ada Mobile
12GB
GPU
RTX 2000 Ada
16GB
GPU
RTX A6000
48GB
GPU
RTX A5000
8GB
GPU
RTX A5000 Max-Q
16GB
GPU
RTX A5000 Mobile
16GB
GPU
RTX A4000
16GB
GPU
RTX A4000 Max-Q
8GB
GPU
RTX A4000 Mobile
8GB
GPU
RTX A3000 Mobile
6GB
GPU
RTX A2000
6GB
GPU
RTX A2000 Embedded
4GB
GPU
RTX A2000 Max-Q
4GB
GPU
RTX A2000 Mobile
4GB
GPU
A800
40GB
GPU
A100
80GB
GPU
A40
48GB
GPU
A30
24GB
GPU
A10
24GB
GPU
A2
16GB
RTX
RTX 5090
32GB
RTX
RTX 5090 D
32GB
RTX
RTX 5090 Mobile
24GB
RTX
RTX 5080
16GB
RTX
RTX 5080 Mobile
16GB
RTX
RTX 5070
12GB
RTX
RTX 5070 Mobile
8GB
RTX
RTX 5070 Ti
16GB
RTX
RTX 5070 Ti Mobile
12GB
RTX
RTX 5060 Ti
16GB
RTX
RTX 5060
8GB
RTX
RTX 5060 Mobile
8GB
RTX
RTX 5050
8GB
RTX
RTX 5050 Mobile
8GB
RTX
RTX 4090
24GB
RTX
RTX 4090D
24GB
RTX
RTX 4090 Mobile
16GB
RTX
RTX 4080 SUPER
16GB
RTX
RTX 4080
16GB
RTX
RTX 4080 Mobile
12GB
RTX
RTX 4070
12GB
RTX
RTX 4070 Mobile
8GB
RTX
RTX 4070 Ti
12GB
RTX
RTX 4070 Super
12GB
RTX
RTX 4070 Ti Super
16GB
RTX
RTX 4060
8GB
RTX
RTX 4060 Ti
8GB
RTX
RTX 4090 Laptop
16GB
RTX
RTX 4080 Laptop
12GB
RTX
RTX 4070 Laptop
8GB
RTX
RTX 4060 Laptop
8GB
RTX
RTX 4050 Laptop
6GB
RTX
RTX 3090
24GB
RTX
RTX 3090 Ti
24GB
RTX
RTX 3080
12GB
RTX
RTX 3080 Ti
12GB
RTX
RTX 3080 Mobile
16GB
RTX
RTX 3070
8GB
RTX
RTX 3070 Ti
8GB
RTX
RTX 3070 Ti Mobile
8GB
RTX
RTX 3060 Ti
8GB
RTX
RTX 3060
12GB
GPU
RTX 2080 Ti
11GB
GPU
RTX 2080
8GB
GPU
RTX 2070
8GB
GPU
RTX 2070 SUPER Mobile
8GB
GPU
RTX 2070 SUPER
8GB
RTX
RTX 3060 Mobile
6GB
RTX
RTX 3050 Mobile
4GB
GPU
RTX 2060
6GB
GPU
RTX 2060 12GB
12GB
GPU
RTX 2060 Mobile
6GB
GPU
RTX 2050 Mobile
4GB
GPU
GTX 1080 Ti
11GB
GPU
GTX 1080
8GB
GPU
GTX 1070 Ti
8GB
GPU
GTX 1070
8GB
GPU
GTX 1060
3GB
GPU
GTX 1050 Ti
4GB
GPU
RTX Titan
24GB
GPU
GTX 1660
6GB
GPU
GTX 1650 Mobile
4GB
NVIDIA T4
T4
16GB
GPU
T10
16GB
GPU
V100
32GB
GPU
Quadro P6000
24GB
GPU
P40
24GB
GPU
P100
16GB
Jetson
Jetson AGX Orin 64GB
64GB
Jetson
Jetson AGX Orin 32GB
32GB
Jetson
Jetson Orin NX 16GB
16GB
Jetson
Jetson Orin NX 8GB
8GB
Jetson
Jetson Orin Nano 8GB
8GB
Jetson
Jetson Orin Nano 4GB
4GB
Jetson
Jetson AGX Xavier
32GB
Jetson
Jetson Xavier NX
8GB
Jetson
Jetson TX2
4GB
Jetson
Jetson Nano
4GB