Summary
The recently introduced FlashAttention re-packages the computation of attention ($softmax(QK^\top)\cdot V$) so that it reduces the number of I/O operations in a _single_ GPU setup. This led to substantial improvement over the earlier implementations of Attention. However, FlashAttention was only designed for a single GPU case.
This paper considers the problem of extending FlashAttention to work for the case of a cluster of GPUs. Specifically the paper identifies three bottlenecks in this extension:
1. For the case of causal Attention, one would expect to see a factor $2\times$ speedup over non-causal Attention (since the former only performs half the number of FLOPs over the latter). However, if one is not careful in how `chunks' of FlashAttention computations are distributed then lot of processors would sit 'idle.' The idea in the paper is to re-distribute the computation of the sub-blocks across processors.
2. The problem with re-distributing 'chunks' of the Attention computation to various processors is that if not done properly, this could lead to a large communication overhead. Thus, to get towards regaining the $2\times$ improvement mentioned above, this paper proposes a better scheduling of these partial computations to reduce the communication. Further, the paper shows how to parallelize the communication and computation tasks at each processor to gain further improvement.
3. To handle really long context length, the now standard practice is to do _gradient checkpointing_, which basically trades memory for re-computation. However, for longer context lengths this recomputation time starts to become a bottleneck. This paper observes that in FlashAttention backward pass recomputation is not needed.
The paper implements the above into a system it calls DistFlashAttention and compares their implementation to existing distributed Attention implementations including Ring (Self)Attention, Megatron-LM and DeepSpeed-Ulysses. It achieves a minimum speedup of $1.26\times$ and a max of $5.64\times$ speedup over various implementations. The speedups for Ring Self-Attention and Megatron-LM also comes along with $2-8\times$ longer sequence lengths. The paper also presents ablation experiments.
Overall, the paper considers an important problem and proposes new system that achieves speedup over existing systems. However, the current writing leaves certain questions unanswered (please see the Question to Authors section for more). Because of these questions, I am rating this a just above threshold of acceptance. However, if the authors are able to address those questions satisfactorily then this paper _could_ be a clear accept for me.
Detailed Comments for Authors
-----------------------------
Below is a list if minor typos/presentation comments:
* [Pg. 2, line -3] "$5.64\times$ compared"-- "speedup" is missing.
* [Pg. 4, line 2] "which" -> "that"
* [Pg. 5, 2 lines above eq (3)] The final implementation of DistFlashAttention is Algorithm 2?
Reasons to reject
* Some parts of the paper could do with more explanation
* How were the three bottlenecks identified? Are these the three most important bottlenecks? If so, how was this determined?
* Also the first two bottlenecks are not specific to FlashAttention but to Attention in general? Either way, this should be clarified.
* Some parts of proposed system (e.g. distributing 'shards' of the Attention computation) are not new to the paper (e.g. the sharding is proposed in RingAttention as well-- from what I understand)
* The paper shunts all discussion of its scheduling ideas to the pseudocode in Algorithm 2. The main part of the paper should at the very least state the main idea(s).
* It would be helpful to put the improvements in the experiments in context if it would be possible to give a theoretical bound for what is the maximum improvement that can be achieved with the three main ideas. For the causal part, it is clear that handling that would give a $2\times$ improvement but I do not get a sense of what is the max improvement once can expect from the other ideas. Also do the improvements from the different ideas multiply? I.e. is there reason to believe that the various ideas are not in 'conflict' with each other? Also stating the max theoretical speedups for the ablation experiments would be useful as well.
As mentioned earlier, none of the above weaknesses are inherent and probably can be fixed by revising the writing.
Questions to authors
1. How were the three bottlenecks identified?
2. Please clarify which bottlenecks are FlashAttention specific and which ones would apply to any Attention implementation.
3. Please clarify which of the proposed ideas appear in other works (like RingAttention) and which ones are new to this paper.
4. What are the main idea(s) in Algorithm 2?
5. What are the max theoretical gains that one can hope from the ideas presented in this paper?