Why is Transformer training more parallel?
Separate parallel training positions from autoregressive generation.
Content revision 4 · 2026-10-24
T01 · Revision 1 · 2026-10-21
- Recurrent: A → B → C
- Training: A, B, C in one layer
- Decode: A → generate B → generate C
The bottleneck
Recurrent states depend on preceding states, limiting parallelism over positions. The 2017 Transformer connects positions through attention and expresses each layer as matrix operations. This removes within-layer recurrence, not dependencies between layers.
The mechanism
During training the target sequence is known. Shifted ground-truth tokens are inputs and a causal mask hides future tokens. QKᵀ scores positions, and softmax weights V. During decoding future tokens are unknown: ordinary autoregressive generation still produces them sequentially. KV caching avoids recomputing past keys and values.
Attention(Q,K,V) = softmax(QKᵀ / √dₖ + mask)V
Examples and evidence
Teaching example: training [A,B,C]→[B,C,D] can compute losses at all three positions in one forward pass. Generation must obtain B before using B as the next input. Actual parallelism depends on batch size, sequence length, hardware and implementation.
New constraints
Dense attention scores grow quadratically with sequence length. More parallelism does not mean less total computation; long contexts introduce memory, IO, positional representation and data-coverage constraints.
Primary sources
- Attention Is All You Need · 2017-06-12 · Checked 2026-10-21
Manual browser reading records and interactive calculators are available with JavaScript.
Keep exploring
I01 · Why does KV cache grow with context and concurrency?
S03 · Why can FlashAttention be faster with the same formula?