- The paper introduces minLSTM and minGRU, simplified RNNs that remove state dependencies in gates to allow full parallel training.
- The methodology eliminates non-linear range restrictions and leverages parallel prefix scan, achieving up to 1361× faster training on long sequences.
- Empirical results demonstrate competitive performance in language modeling, selective copying, and reinforcement learning despite an 88% increase in memory usage.
The paper simplifies traditional Recurrent Neural Networks (RNNs), specifically Long Short-Term Memory (LSTM) networks and Gated Recurrent Units (GRUs), to create minimal versions named minLSTMs and minGRUs that can be parallelized during training. These simplified models use fewer parameters than their traditional counterparts while achieving competitive performance on various sequence modeling tasks.
The paper begins by revisiting the landscape of sequence modeling, dominated by RNNs for two decades before the advent of Transformers. The inherent sequential nature of RNNs limited parallelization, making them computationally inefficient for long sequences. Transformers, introduced in 2017, enabled parallel training through self-attention but suffer from quadratic computational complexity with respect to sequence length. This limitation has sparked renewed interest in parallelizable recurrent models that scale more efficiently. Recent methods such as state-space models, linearized attention, and linear recurrent neural networks have shown promise in addressing these scalability issues.
The authors focus on LSTMs and GRUs as early examples of input-dependent recurrent models. By removing dependencies on previous states from the gates of these models, they enable parallel training. Further simplification leads to minLSTMs and minGRUs, which use fewer parameters, are fully parallelizable, and achieve competitive performance. Implementations of minGRU and minLSTM are provided in plain PyTorch.
The paper reviews traditional RNNs, highlighting their suitability for tasks involving sequential data but also noting the challenges related to vanishing and exploding gradients. The LSTM is defined by the following equations:
- Γo​=σ(Wio​xt​+Uho​ht−1​+bo​)
- Γo​ is the output gate.
- σ is the sigmoid function.
- Wio​ is the weight matrix for the input xt​.
- Uho​ is the weight matrix for the previous hidden state ht−1​.
- bo​ is the bias vector for the output gate.
- Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)
- Γf​ is the forget gate.
- Γo​0 is the weight matrix for the input Γo​1.
- Γo​2 is the weight matrix for the previous hidden state Γo​3.
- Γo​4 is the bias vector for the forget gate.
- Γo​5
- Γo​6 is the input gate.
- Γo​7 is the weight matrix for the input Γo​8.
- Γo​9 is the weight matrix for the previous hidden state σ0.
- σ1 is the bias vector for the input gate.
- σ2
- σ3 is the candidate cell state.
- σ4 is the hyperbolic tangent function.
- σ5 is the weight matrix for the input σ6.
- σ7 is the weight matrix for the previous hidden state σ8.
- σ9 is the bias vector for the candidate cell state.
- Wio​0
- Wio​1 is the cell state.
- Wio​2 denotes element-wise multiplication.
- Wio​3
- Wio​4 is the hidden state.
The GRU, a simplification of the LSTM, uses only two gates and a single state. The GRU equations are:
- Wio​5
- Wio​6 is the update gate.
- Wio​7 is the weight matrix for the input Wio​8.
- Wio​9 is the weight matrix for the previous hidden state xt​0.
- xt​1 is the bias vector for the update gate.
- xt​2
- xt​3 is the reset gate.
- xt​4 is the weight matrix for the input xt​5.
- xt​6 is the weight matrix for the previous hidden state xt​7.
- xt​8 is the bias vector for the reset gate.
- xt​9
- Uho​0 is the candidate hidden state.
- Uho​1 is the weight matrix for the input Uho​2.
- Uho​3 is the weight matrix for the previous hidden state Uho​4.
- Uho​5 is the bias vector for the candidate hidden state.
- Uho​6
The paper reviews the parallel prefix scan algorithm and its application in computing recurrence relations of the form Uho​7.
The methodology section details the simplification of GRUs and LSTMs to enable training via parallel scan. For the minGRU, the first step involves dropping previous state dependencies from the gates. The GRU's hidden state recurrence is Uho​8, where Uho​9 and ht−1​0. To enable parallel scan, the dependencies on ht−1​1 are removed, simplifying the equations to ht−1​2 and ht−1​3.
The second step involves dropping the range restriction of candidate states. The hyperbolic tangent function, which restricts the range of hidden states, is removed, further simplifying the model. The resulting minGRU equations are ht−1​4, ht−1​5, and ht−1​6. The minGRU requires ht−1​7 parameters, compared to GRU's ht−1​8.
For the minLSTM, the first step involves dropping previous state dependencies from the gates. Similar to the minGRU, the hidden state dependencies are removed from the input, forget, and candidate cell state equations. The second step involves dropping the range restriction of candidate states, removing the hyperbolic tangent function. The third step involves simplifying the scaling of the output by dropping the output gate. The resulting minLSTM equations are ht−1​9, bo​0, bo​1, and bo​2. The minLSTM requires bo​3 parameters compared to LSTM's bo​4.
The paper then presents empirical results, comparing the minimal versions with their traditional counterparts and modern sequence models. The runtime for sequence lengths of bo​5 for minLSTM, minGRU, and Mamba were bo​6, bo​7, and bo​8 milliseconds respectively. For a sequence with length bo​9, the runtime were Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)0, Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)1, and Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)2 respectively. For a sequence length of Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)3, minGRUs and minLSTMs were Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)4 and Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)5 faster per training step than GRUs and LSTMs on a T4 GPU. The improvement is even more significant as sequences grow in length with minGRUs and minLSTMs being Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)6 and Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)7 faster for a sequence length of Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)8. The minimal variants use Γf​=σ(Wif​xt​+Uhf​ht−1​+bf​)9 more memory compared to their traditional counterparts. minLSTM and minGRU are able to solve the Selective Copying task, achieving performance comparable to S6 and surpassing other modern baselines. In reinforcement learning tasks, minLSTM and minGRU outperform Decision S4 and achieve performance competitive with Decision Transformer, Aaren, and Mamba. In language modeling tasks, minGRU, minLSTM, Mamba, and Transformers achieved comparable test losses of Γf​0, Γf​1, Γf​2, and Γf​3 respectively.
The related work section provides an overview of recent efficient recurrent sequence models, categorized into deep state-space models, recurrent versions of attention, and parallelizable RNNs.
The paper concludes by highlighting the parallel training enabled by removing gate dependencies on previous states. The minimal versions offer fewer parameters, full parallelizability, and competitive performance. The authors suggest a reevaluation of simpler foundational models like LSTM and GRU.
The limitations section acknowledges the hardware constraints that impacted the scale of the experiments, including the use of older GPUs with limited memory. Gradient accumulation was used to accommodate memory limitations, reducing the effective batch size and slowing down training.