The signature to look for
Reduced to a sentence, the attention problem was: a chain of operations produced an intermediate larger than its inputs and outputs, and that intermediate made round trips to main memory.
That signature has three parts, and finding all three together is a reliable indicator of a fusion opportunity.
Several operations run in sequence, each reading a tensor and writing a tensor.
At least one intermediate is larger than the operation's inputs and its final output. This is the strongest signal, because a computation whose intermediates are all smaller than its endpoints is usually already efficient.
And the arithmetic performed per byte moved is low, meaning a few operations per element rather than a matrix multiplication's worth.
When all three hold, the operation is memory-bound and its traffic is avoidable. When only the first holds, the compiler may already have fused it. When the arithmetic per byte is high, you are compute-bound and none of this applies.
The rest of this lesson works through where that signature appears in a typical training and serving stack.

