[Paper Review] Transformer Quality in Linear Time
FLASH introduces the Gated Attention Unit and mixed chunk attention to achieve linear-time attention with Transformer-like quality, delivering substantial training speedups on long-context language modeling tasks.
We revisit the design choices in Transformers, and propose methods to address their weaknesses in handling long sequences. First, we propose a simple layer named gated attention unit, which allows the use of a weaker single-head attention with minimal quality loss. We then propose a linear approximation method complementary to this new layer, which is accelerator-friendly and highly competitive in quality. The resulting model, named FLASH, matches the perplexity of improved Transformers over both short (512) and long (8K) context lengths, achieving training speedups of up to 4.9$ imes$ on Wiki-40B and 12.1$ imes$ on PG-19 for auto-regressive language modeling, and 4.8$ imes$ on C4 for masked language modeling.
Motivation & Objective
- Address the long-context limitations of Transformers by enabling scalable, efficient attention.
- Develop a new layer (Gated Attention Unit) that maintains high quality with weaker attention.
- Propose a linear-time attention approximation (mixed chunk attention) that integrates local quadratic and global linear components.
- Demonstrate that FLASH matches or approaches Transformer++ quality while offering substantial training speedups on large-scale datasets (Wiki-40B, PG-19, C4).
- Provide extensive ablations and comparisons against state-of-the-art linear and quadratic attention models.
Proposed method
- Introduce Gated Attention Unit (GAU) where O = (U ⊙ ĤV)W_o and ĤV = AV, with A computed from a gated mechanism that can use a simple, single-head attention.
- Show GAU can match Transformer quality even with weaker attention by gating U with a retrieved V via attention.
- Develop mixed chunk attention: partition the sequence into non-overlapping chunks; apply local quadratic attention within each chunk and global linear attention across chunks (causal or non-causal) and combine results with gating.
- Represent GAU within FLASH, which combines GAU blocks with the mixed chunk attention to achieve linear complexity with minimal quality loss.
- Provide pseudocode and discuss accelerator-friendly implementation, focusing on minimizing memory rereformatting and maintaining linear scaling in practice.
- Conduct extensive experiments on bidirectional and auto-regressive language modeling across C4, Wiki-40B, and PG-19 with model sizes around 110M–500M parameters.
Experimental results
Research questions
- RQ1Can GAU achieve Transformer-level quality using a weaker, single-head attention mechanism?
- RQ2Can mixed chunk attention deliver linear-time complexity while preserving high-quality performance for long sequences?
- RQ3How do FLASH-Quad (quadratic) and FLASH (linear) compare to Transformer++ and other linear-attention methods in MLM and LM tasks across varying context lengths?
- RQ4What are the speedups and quality trade-offs when scaling context length from 512 to 8K on large-scale datasets?
- RQ5How does GAU-based FLASH perform in fine-tuning on downstream long-context tasks (e.g., TriviaQA) compared to Transformer++ and baselines?
Key findings
- GAU with a small single-head attention can match Transformer-level quality.
- FLASH achieves linear scalability and substantial training speedups: up to 4.9× on Wiki-40B and 12.1× on PG-19 for autoregressive LM, and 4.8× on C4 for MLM.
- FLASH-Quad and FLASH deliver lower latency and competitive perplexity across context lengths 512–8192 on Wiki-40B, with larger gains on longer contexts (e.g., PG-19).
- Compared to Transformer++, FLASH reduces training cost by up to 12.1× on PG-19 and achieves favorable quality-speed trade-offs across tasks.
- Ablation studies show both local quadratic and global linear components are crucial; GAU outperforms MC-TFM++ (mixed-chunk variant on Transformer++) by substantial margins.
- Chunk size and design choices (e.g., first-to-all token option) influence fine-tuning performance and speed, with larger chunks generally benefiting longer contexts.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.