Abstract
We introduce CompAct, a technique that reduces peak memory utilization on GPU by 25-30% for pretraining and 50% for fine-tuning of LLMs. Peak device memory is a major limiting factor in training LLMs, with various recent works aiming to reduce model memory. However, most works don’t target the largest component of allocated memory during training: the model’s compute graph, which is stored for the backward pass. By storing low-rank, compressed activations to be used in the backward pass, we greatly reduce the required memory, unlike previous methods which only reduce optimizer overheads or the number of trained parameters. Our compression uses random projection matrices, thus avoiding additional memory overheads. Comparisons with previous techniques for either pretraining or fine-tuning show that CompAct substantially improves existing compute-performance tradeoffs.
Introduction: The Activation Memory Bottleneck
Training Large Language Models (LLMs) is notoriously memory-intensive. While much research has focused on reducing the memory needed for model weights (e.g., LoRA) or optimizer states (e.g., GaLore), these methods often ignore the "elephant in the room": activation memory.
To perform backpropagation, modern frameworks must store the inputs to every layer during the forward pass to calculate gradients later. This "computation graph" scales linearly with batch size and sequence length, quickly becoming the primary bottleneck for researchers with limited hardware. CompAct aims to compress this graph directly, making LLM training more accessible to those without massive GPU clusters.
Methodology: Low-Rank Compression via Random Projections
The core innovation of CompAct is the compression of input activations for linear layers using random projection matrices.
The process follows four key steps:
- Forward Pass Compression: For a linear layer with input $x$, CompAct projects $x$ into a lower-dimensional subspace $z = xP$, where $P$ is a Gaussian random projection matrix. Only the smaller tensor $z$ is saved for the backward pass.
- Low-Rank Gradients: During the backward pass, the gradient is computed directly in this reduced subspace. This has a "trickle-down" effect: because the gradients are low-rank, the optimizer states (like those used in Adam) also become low-rank and significantly smaller.
- On-the-Fly Projection (The Seed Trick): To avoid the computational cost of calculating optimal projections (like SVD) or the memory cost of storing $P$, CompAct generates $P$ on-the-fly using a random seed. By simply storing the seed, the model can re-generate the exact same projection matrix during the backward pass without ever storing the matrix itself in memory.
- Decompression: The low-rank gradient is projected back to the full parameter size only for the final weight update step.
Evaluation and Results
The authors evaluated CompAct across two primary settings: pretraining LLaMA-based models (60M to 1B parameters) on the C4 (Colossal Clean Crawled Corpus) dataset, and fine-tuning a pretrained RoBERTa-base model on the GLUE benchmark.
Memory and Throughput Performance
CompAct achieves substantial memory savings while maintaining high throughput. Unlike SVD-based methods like GaLore, CompAct's use of random projections avoids heavy computational overhead.
Key findings include:
- Memory Savings: CompAct achieved a 17.3% reduction in peak memory for LLaMA-350M and an estimated 30% reduction for LLaMA-65B. In fine-tuning scenarios (RoBERTa), it saved a staggering 50% of peak memory.
- Performance Parity: Despite heavy compression (using ranks as low as $n/8$), the models maintained perplexity and accuracy scores comparable to full-rank training and other state-of-the-art methods like GaLore.
- Throughput Advantage: Because it avoids the heavy SVD overhead of GaLore, CompAct offers higher training throughput (tokens per second), making it not just more memory-efficient, but faster in practice.
- Synergy with Checkpointing: CompAct is compatible with Activation Checkpointing (CKPT). While CKPT saves memory by recomputing the forward pass, CompAct saves memory by storing less data. Combining them leads to even more dramatic savings, as seen in the $r=n/8 + CKPT$ results.
Discussion and Future Work
CompAct demonstrates that "Random Sketching" theory is a powerful tool for LLM efficiency. By leveraging simple Gaussian matrices, the method preserves the most important information of activation tensors without expensive calculations.
However, some limitations remain. Currently, CompAct only compresses activations for linear layers; non-linear operations (like SiLU) and normalization layers (like RMSNorm) are still stored in full. Additionally, the current implementation leaves the output-projection layer of the attention mechanism uncompressed to maintain compatibility with FlashAttention. Future work may involve custom CUDA kernels to bridge these gaps and the exploration of sparse projections to further reduce computational costs.
Summary updated