[Paper Review] Sub-Linear Memory: How to Make Performers SLiM
This paper proposes a memory-efficient back-propagation algorithm for Performer models that enables training with sublinear memory scaling by processing sequences in slices, achieving O(1) memory usage when C=1. The method computes exact gradients without approximation, enabling full backward compatibility for training or fine-tuning on low-memory devices like smartphones or older GPUs.
The Transformer architecture has revolutionized deep learning on sequential data, becoming ubiquitous in state-of-the-art solutions for a wide variety of applications. Yet vanilla Transformers are notoriously resource-expensive, requiring $O(L^2)$ in serial time and memory as functions of input length $L$. Recent works proposed various linear self-attention mechanisms, scaling only as $O(L)$ for serial computation. We perform a thorough analysis of recent Transformer mechanisms with linear self-attention, Performers, in terms of overall computational complexity. We observe a remarkable computational flexibility: forward and backward propagation can be performed with no approximations using sublinear memory as a function of $L$ (in addition to negligible storage for the input sequence), at a cost of greater time complexity in the parallel setting. In the extreme case, a Performer consumes only $O(1)$ memory during training, and still requires $O(L)$ time. This discovered time-memory tradeoff can be used for training or, due to complete backward-compatibility, for fine-tuning on a low-memory device, e.g. a smartphone or an earlier-generation GPU, thus contributing towards decentralized and democratized deep learning.
Motivation & Objective
- Address the high memory cost of training long-sequence Transformers, especially on low-memory devices.
- Overcome the limitation of batch size reduction due to O(L²) memory complexity in standard Transformers.
- Enable training or fine-tuning of Performer models on devices with constrained memory, such as smartphones or older GPUs.
- Maintain backward compatibility and exact gradient computation while reducing memory consumption.
- Explore a time-memory tradeoff that allows users to control memory usage at the cost of increased parallel computation time.
Proposed method
- Process the input sequence in slices of size C, where C controls the memory-time tradeoff.
- Use Algorithm 1 to perform forward and backward passes in a sequential, slice-by-slice manner, storing only the loss and intermediate buffers.
- Construct symbolic representations Φ^(n) during backward pass to compute exact gradients without approximations.
- Reuse random seeds for dropout masks across forward and backward passes within each slice to support stochastic computation.
- Integrate with existing optimization techniques like gradient accumulation and reversible layers to further reduce memory usage.
- Ensure backward compatibility by computing exact gradients, making the method suitable for both training and fine-tuning.
Experimental results
Research questions
- RQ1Can we reduce memory consumption in Performer models below O(L) without introducing approximation errors?
- RQ2What is the tradeoff between memory usage and parallel computation time in long-sequence training?
- RQ3Can the proposed method be used for fine-tuning on low-memory devices while maintaining model accuracy?
- RQ4Is the method compatible with existing deep learning optimization techniques like gradient accumulation and reversible layers?
- RQ5Does the slice-based back-propagation preserve gradient accuracy compared to full-batch training?
Key findings
- The proposed algorithm achieves O(1) memory usage during training when C=1, with only O(L) time complexity, enabling training on devices with minimal memory.
- For the Copying task (L=512), memory usage dropped from 0.0449 GB (full) to 0.0374 GB (C=64), with a time increase from 0.0474 sec to 0.1228 sec per iteration.
- On Penn Treebank (L=1024), memory usage decreased from 0.300 GB (full) to 0.231 GB (C=256), with time increasing from 0.1377 sec to 0.3060 sec per iteration.
- On Enwik8 (L=4096), memory usage dropped from 1.513 GB (full) to 0.909 GB (C=1366), with time increasing from 0.4598 sec to 0.8654 sec per iteration.
- Empirical results show indistinguishable performance across all methods, confirming that the algorithm computes exact gradients and maintains model accuracy.
- The method is fully backward-compatible and supports fine-tuning on low-memory devices, enabling decentralized and democratized deep learning.
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.