Research

AI-generated text

Register reuse speeds up NVFP4 attention on NVIDIA RTX Blackwell

A revised attention kernel reuses registers and interleaves operations to keep Tensor Cores busier on NVIDIA RTX Blackwell GPUs.

Register reuse speeds up NVFP4 attention on NVIDIA RTX Blackwell

Reusing registers and changing the execution schedule can speed up attention on NVIDIA RTX Blackwell GPUs. The optimized NVFP4 kernel starts part of the next data tile’s matrix multiplication while softmax processing for the current tile is still underway. This reduces Tensor Core idle time without reserving a second complete buffer for attention scores.

Reactor, which provides infrastructure and APIs for serving real-time video, robotics and world models, integrated the kernel into its production serving stack and used it for real customer traffic. Its measurements showed standalone attention-kernel speedups of 1.17 to 1.64 times and end-to-end inference latency reductions of approximately 1% to 15%, depending on the workload.

Why RTX Blackwell has a different bottleneck

Attention can be expensive during inference on the long sequences used by world models. On NVIDIA Hopper and NVIDIA Blackwell data center GPUs, FlashAttention3 and FlashAttention4 improve performance by overlapping matrix multiply-accumulate operations with softmax. Those hardware-specific approaches cannot be applied directly to the SM120-based NVIDIA RTX PRO 6000 Blackwell Series, however, because its Tensor Core architecture differs.

For BF16 inference in video-generation models, matrix multiplication is the main constraint on attention performance on RTX Blackwell devices, whereas softmax is a major forward-attention bottleneck on Blackwell data center GPUs. NVFP4, introduced with the NVIDIA Blackwell architecture, provides hardware-accelerated 4-bit matrix multiplication with higher Tensor Core throughput. Exploiting that throughput requires coordinating data movement, softmax and storage of intermediate results.

Attention involves two main matrix multiplications: QKᵀ and PV. The first produces attention scores from query and key vectors; the second combines value vectors using weights derived from softmax. In the tiled kernel discussed here, P contains unnormalized softmax weights, and final normalization occurs after results have been accumulated across tiles.

Splitting score tiles in two

SageAttention3 is a native NVFP4 attention implementation designed for SM120 that performs both matrix multiplications in NVFP4. Quantization produces an NVFP4 data tensor and an FP8 scaling tensor. Because softmax outputs are restricted to the range from 0 to 1, they may not make good use of NVFP4’s dynamic range on their own. SageAttention3 uses two-level scaling to normalize the values before quantization, reducing accuracy loss.

The original cooperative thread array, or CTA, uses four producer warps and eight consumer warps. Producers load the data, while consumers perform QK, softmax, scaling, quantization and PV sequentially for each N128 tile. Tensor Cores can sit idle during the intermediate processing.

Data loads are tied to 128 × 128 shapes, so using less than the full shape would underuse memory bandwidth. The corresponding RTX Blackwell NVFP4 matrix operation is limited to m16n8k64, however, requiring two instructions with k64 each to cover a contraction dimension of 128. The original schedule issues them in succession and waits for execution before moving to softmax.

Register capacity is also tight: producer warps use 3,072 registers and consumer warps use 59,392. The total of 62,464 occupies approximately 95.3% of the SM’s register capacity, leaving little room for another complete score tile.

The revised schedule retains four producer warps, eight consumer warps and full N128 K/V loads, but splits each score tile into two N64 register slots. Once the scores in one half have been exponentiated and quantized to NVFP4, their registers can hold the corresponding QK results for the next tile. Work on the next tile can therefore be interleaved with the current tile’s remaining softmax, quantization and PV operations.

The online-softmax state is still updated using the complete N128 score tile before either half is consumed. After producing the first tile’s scores, the kernel alternates between the two register slots; for the final tile, it does not launch another QK operation. It then normalizes the accumulated output and stores it in BF16.

Measured kernel speedups

Reactor ran its tests on an NVIDIA RTX PRO 6000 Blackwell Server Edition GPU with 96 GB of memory. It compared the original and optimized NVFP4 kernels using identical Q/K/V inputs, packed tensors and log-sum-exp settings. Kernel timings exclude Q/K/V quantization and output-stride restoration.

  • On the 7,040-token input captured from LongLive, noncausal latency fell from 0.75052 ms to 0.63548 ms and causal latency from 0.44992 ms to 0.37927 ms, speedups of 1.18 and 1.19 times respectively.
  • On the synthetic 4,096-token input, noncausal latency changed from 0.28962 ms to 0.23190 ms and causal latency from 0.21199 ms to 0.16087 ms, speedups of 1.25 and 1.32 times.
  • In the synthetic 8,192-token test, noncausal latency fell from 1.00177 ms to 0.85648 ms and causal latency from 0.76466 ms to 0.46659 ms. The latter produced the largest speedup, at 1.64 times; the noncausal result was 1.17 times.
  • On the synthetic 16,384-token input, noncausal latency improved from 3.80862 ms to 3.25377 ms and causal latency from 2.20630 ms to 1.78152 ms, speedups of 1.17 and 1.24 times.

All cases used a batch size of one, 24 heads, a head dimension of 128 and equal query and key lengths. Each implementation was measured in three fresh processes, with alternating run order, prewarming and repeated CUDA-event timing blocks.

End-to-end model results

In the end-to-end tests, only the specified attention operations used NVFP4; other attention operations and model weights remained in BF16. The BF16 baseline for video-chunk and action-prediction tests used native cuDNN attention. Timings include quantization, layout conversion and production of decoded CPU frames or actions, but exclude model loading, warmup, networking and queueing, among other costs.

  • For a LongLive video chunk of 32 frames at 704 × 1280, switching self-attention and cached history to NVFP4 reduced latency from 5.13 to 4.79 seconds, or 6.70%.
  • In the Helios test with 33 frames at 384 × 640, switching the 11,280-token self-attention reduced time from 5.94 to 5.84 seconds; switching all self-attention calls reduced it to 5.87 seconds. The reductions were 1.70% and 1.11% respectively.
  • In the OmniDreams test with eight frames at 704 × 1280, both idle-camera and moving-camera scenarios improved from 0.60 to 0.51 seconds when rounded. Reductions calculated from unrounded values were 14.77% and 14.95% respectively.
  • In the Cosmos 3 Nano Policy Droid pilot’s 32 × 8 action prediction, switching dense generator attention reduced time from 1.72 to 1.69 seconds, or 1.70%.

For long generations, LongLive produced 1,021 frames in 32 chunks: time fell from 162.52 to 151.89 seconds, a 6.54% reduction. In a Helios run of 1,056 frames in 32 chunks, switching the largest self-attention calls reduced time from 190.88 to 187.48 seconds; switching all supported self-attention reduced it to 188.36 seconds. Those were improvements of 1.78% and 1.32% respectively.

An OmniDreams run of 1,021 frames in 128 chunks fell from 77.34 to 65.79 seconds with an idle camera and from 77.77 to 65.95 seconds with a moving camera. For 2,045 frames in 256 chunks, the corresponding times changed from 155.44 to 131.84 seconds and from 155.92 to 132.00 seconds. The four reductions were 14.94%, 15.20%, 15.18% and 15.34% respectively.

The long-run measurements covered complete, warmed generations through decoded CPU frames, excluding loading and transport. For LongLive and Helios, the reported figures were medians of three independent processes per configuration using eager execution; OmniDreams used one process per configuration and camera scenario. Percentages were calculated from unrounded values.

The core optimization has been merged into FlashInfer’s main branch. The SM120 NVFP4 attention API can be used in supported attention layers on NVIDIA RTX Blackwell; integration should include a comparison of both end-to-end latency and output quality against the BF16 baseline.