TiledAttention: a CUDA Tile SDPA Kernel for PyTorch
Organizations: Helmholtz Centre for Environmental Research - UFZ
Abstract
TiledAttention is a scaled dot-product attention (SDPA) forward operator for SDPA research on NVIDIA GPUs. Implemented in cuTile Python (TileIR) and exposed as a PyTorch-callable function, it is easier to modify than low-level CUDA templates while retaining realistic behavior via online softmax and tiled streaming. Algorithmically, TiledAttention follows the established FlashAttention-style online-softmax formulation; our novelty is the cuTile/TileIR implementation strategy, schedule-level modifiability, and reproducible benchmarking/profiling workflow. The approach is both performant and directly editable at the schedule level from Python (tile shapes, staging, shared-memory layout), enabling rapid, reproducible kernel research without template-heavy CUDA/CUTLASS rewrites. We benchmark TiledAttention on an NVIDIA DGX GB10 node with a reproducible harness and compare against PyTorch SDPA (auto-dispatch), explicit unfused baselines (torch_sdpa_math, standard eager attention), and forced backend probes (FlashAttention2, EffecientAttention, CuDNN Attention) across sequence length, head dimension, and precision (FP16/BF16). While production fused baselines remain stronger overall, TiledAttention delivers large speedups over standard eager attention paths and is available for direct use within PyTorch workflows, providing a practical balance between performance and customizability.
Figures & tables
| Load tile | Stream tiles + score/mask | Update ; normalize + store |
| Parameter | Typical values | Effect |
|---|---|---|
| (Q rows) | 64, 128 | CTA work per launch; affects occupancy and reuse |
| (KV columns) | 64, 128, 256 | Streaming granularity; impacts memory coalescing and softmax update cost |
| Stages / prefetch | 1–4 | Hides global memory latency via pipelining |
| Shared-mem layout | row/col swizzles | Impacts bank conflicts and vectorized loads |
| Item | Value |
|---|---|
| System | NVIDIA DGX GB10 host GPU |
| GPU driver | 580.126.09 |
| CUDA toolkit | CUDA 13.1 (V13.1.115) |
| cuTile | 1.1.0 |
| PyTorch | 2.10.0+cu130 |
| Timing method | CUDA events; median + p95 over runs |
| Comparison | Mean ratio | Median ratio | Win count |
|---|---|---|---|
| TiledAttention / PyTorch SDPA (auto) | 0.632 | 0.634 | 4 / 80 |
| TiledAttention / PyTorch SDPA (math) | 28.15 | 20.31 | 80 / 80 |
| TiledAttention / standard eager attention | 14.36 | 10.76 | 80 / 80 |
| Regime | Shapes | Best | Runner-up | Sensitivity |
|---|---|---|---|---|
| Short | (64, 128) | (64, 64) | 3.92% | |
| Mid | (64, 128) | (64, 64) | 8.53% | |
| Long | (64, 128) | (64, 64) | 9.39% |
| Config | |||
|---|---|---|---|
| async_default (fp32) | 0.766 | 0.668 | 1.017 |
| tm64_tn64 (fp16acc) | 0.779 | 0.698 | 0.968 |
| async_auto (shape-aware) | 0.775 | 0.694 | 1.017 |
| Priority | Recommended path | Rationale |
|---|---|---|
| Peak production throughput across broad shapes | PyTorch SDPA (auto) | Best aggregate performance in this study. |
| Rapid kernel iteration / schedule research | TiledAttention | Python-level tile policy changes with reproducible profiling loop. |
| Custom kernel development in a broader DSL ecosystem | Triton / FlashAttention codebases | Strong alternatives when teams can afford separate kernel engineering and tuning effort. |
| Custom masking/layout experiments | TiledAttention | Easier to modify kernel behavior than template-heavy CUDA paths. |
| Replacing unfused attention baselines | TiledAttention | Large gains vs eager and math- SDPA paths (Table 3 ). |
GPU Kernel Optimization
GPU kernel optimization improves the speed and memory efficiency of computations by tailoring code to GPU hardware and workloads.
See all 202 papers