[Paper Review] Replacing softmax with ReLU in Vision Transformers
The paper investigates replacing softmax in Vision Transformer attention with ReLU, showing that with sequence-length scaling, ReLU-attention can match softmax attention in scaling performance on ImageNet-21k, and offers improved parallelization.
Previous research observed accuracy degradation when replacing the attention softmax with a point-wise activation such as ReLU. In the context of vision transformers, we find that this degradation is mitigated when dividing by sequence length. Our experiments training small to large vision transformers on ImageNet-21k indicate that ReLU-attention can approach or match the performance of softmax-attention in terms of scaling behavior as a function of compute.
Motivation & Objective
- Explore point-wise alternatives to softmax attention in vision transformers.
- Assess whether ReLU-based attention, scaled by sequence length, can match softmax performance.
- Evaluate the impact of sequence length scaling and qk-layernorm on accuracy and training efficiency.
- Analyze the effects of gating and alternative activations on ReLU-attention.
- Provide practical guidance on training Vision Transformers with non-softmax attention at scale.
Proposed method
- Formulate attention with phi = L^{-alpha} h, focusing on ReLU where alpha ~ 1.
- Define ReLU-attention as phi = L^{-1} ReLU and compare to softmax attention.
- Experiment with various non-linearities and sequence-length scaling to assess accuracy.
- Use ImageNet-21k and ImageNet-1k training configurations from BigVision without changing hyperparameters.
- Evaluate the effect of removing qk-layernorm and the impact of a gated attention unit.
Experimental results
Research questions
- RQ1Can replacing softmax with ReLU in vision transformer attention achieve comparable accuracy when scaled by sequence length?
- RQ2How does sequence-length scaling (L^{-alpha}) affect performance across different non-linearities?
- RQ3What is the role of qk-layernorm in stability and accuracy for ReLU-attention at scale?
- RQ4Does adding a gating mechanism reduce the need for sequence-length scaling in ReLU-attention?
- RQ5How do these replacements impact training compute and parallelization?
Key findings
- ReLU-attention with L^{-1} scaling can match the scaling trends of softmax-attention in ImageNet-21k training.
- Sequence-length scaling with alpha near 1 generally yields the best results across tested models.
- qk-layernorm does not have a large effect on these models at the tested scales, though effects may vary with scale.
- Gating does not eliminate the benefit of sequence-length scaling; best accuracy still occurs with L^{-alpha} scaling.
- Using ReLU-attention enables parallelization over the sequence length with fewer gather operations than traditional softmax attention.
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.