Why standard time complexity is a poor measure for GPUs
The "Attention is logarithmic, actually" article argues that it doesn't make sense to classify attention as a quadratic operation due to the highly parallelized nature of GPUs. He argues that the work-depth model of complexity is more informative for parallelized hardware.
In a nutshell, number of operations performed ("work") hides the fact that many operations can happen simultaneously. So quadratic work
- element-wise multiplication is
work but depth because every operation can happen simultanously - sum reduction is
work but depth since you can sum pairs in a reduction tree - matrix multiplication is
work but depth - softmax is
work but depth
The blog derives that vanilla attention is
However, this is just the theoretical floor. The