Hardware-Aware FP4 FlashAttention-4
This paper introduces Hardware-Aware FP4 FlashAttention-4, a method that overcomes the limitations of Blackwell's FP4 tensor cores by employing Direct-P for noncausal inference and a causal path with FP8 gradients, achieving up to 2.13× faster forward throughput and 1.14× faster single-GPU training updates while avoiding the divergence issues observed in MXFP4 training.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
In the world of artificial intelligence, the most powerful models rely on a mechanism called "attention" to understand context. Imagine a reader scanning a long document; attention allows the model to focus on the most relevant words in a sentence while ignoring the rest, connecting ideas across vast distances. To do this, the computer performs a massive series of calculations, comparing every word against every other word to determine their relationships. For years, these calculations have been performed with high-precision numbers, similar to using a ruler with tiny, precise markings to measure a building. This ensures the model learns correctly, but it is slow and consumes enormous amounts of energy. As models grow larger, the need for speed becomes critical. Researchers have recently developed chips capable of using much smaller, coarser numbers—four-bit floating-point values—to perform these comparisons much faster. However, simply switching to these smaller numbers is not enough; the software that manages the flow of data must also change, or the speed gains disappear.
A researcher at Graphcore has tackled this specific bottleneck with a new method they call Direct-P. Their work focuses on the "forward" pass of attention, where the model processes information to generate an answer, and the "backward" pass, where it learns from its mistakes. The researcher discovered that while the new chips can multiply numbers incredibly quickly, the step in between—converting raw scores into probabilities—was slowing everything down. It was like having a super-fast assembly line that kept stopping because a worker had to carefully measure every single part before passing it on. The researcher found that the standard way of handling this conversion, which involved complex scaling and rounding, created a traffic jam that negated the speed benefits of the new hardware.
To solve this, the researcher redesigned the conversion process to be direct and streamlined. Instead of calculating a precise probability and then rounding it, their method maps the raw scores directly to the specific codes the hardware uses. This eliminates the middleman steps that were causing delays. When they tested this approach on the latest generation of data-center chips, the results were striking. For certain common shapes of data, the new method processed information more than twice as fast as the previous standard, which relied on higher-precision numbers. It achieved this while keeping the output accurate enough for complex tasks like video generation and language understanding. In tests involving a video generation model, the new method was nearly twice as fast as the standard approach, producing results that, while finite and usable, showed measurable drift and lower similarity scores compared to the slower, more precise version.
However, the story is not just about speed; it is also about what happens when the model tries to learn. The researcher explored whether they could use these ultra-fast, low-precision numbers for the entire training process, including the backward pass where the model updates its knowledge. They found that while the forward pass could run at full speed, the backward pass required a careful compromise. When they tried to use the fastest four-bit format for the probability values during training, the learning process became unstable and the model failed to improve. The numbers became too coarse, causing the learning signal to break down. Consequently, the researcher determined that for training to remain stable, they must use a slightly more precise eight-bit format for the probability values, even if the rest of the calculation uses the faster four-bit format. This hybrid approach allowed them to speed up the entire training cycle by about 14 percent on a single powerful chip, a significant gain for large-scale models.
The researcher also looked at the physical limits of the computer chips themselves. They discovered that the speed of the calculation was no longer the main problem; the issue was how the data was stored and moved around inside the chip. The chip has a small, ultra-fast memory area where it holds the numbers while working on them. The researcher found that this memory space was completely full, leaving no room to overlap different stages of the calculation. It was like a kitchen where the counter is so crowded with ingredients that the chef cannot start chopping the next vegetable until the current one is finished, even if the knife is incredibly sharp. Because the memory space was fully occupied, the chip could not work on multiple steps at once, which limited how much faster the whole process could become.
This work highlights a crucial shift in how we think about making artificial intelligence faster. It is not enough to simply build faster calculators; the entire workflow must be redesigned to match the hardware's capabilities. The researcher showed that by changing how probabilities are calculated and by carefully managing the flow of data, they could unlock massive speed improvements. Yet, they also proved that there are hard limits. The memory constraints of the chip mean that even with the fastest possible math, there is a ceiling to how much overlap is possible. The path forward, they suggest, lies not just in faster arithmetic, but in smarter ways to organize the data so that the chip's resources are never left waiting. This balance between raw speed and careful data management is what will allow the next generation of artificial intelligence to run efficiently.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.