TL;DR
Training Large Language Models (LLMs) usually requires massive GPU memory to handle the large mini-batches needed for fast convergence. CoLM (Coresets for Training LLMs) is a new data-centric approach that selects a small, "smart" subset of data (a coreset) to mimic the gradients of a much larger batch. By accounting for data imbalance, the Adam optimizer, and high-dimensional gradients, CoLM reduces memory requirements by 2x and speeds up training by 2.7x while actually outperforming standard training with 4x larger batches.
The Memory Wall in LLM Training
In deep learning, "bigger is usually better" when it comes to batch sizes—larger batches provide more stable gradients and faster convergence. However, LLMs are memory hogs. A single 2.7B parameter model (like Phi-2) requires 44GB of GPU memory just to handle a batch size of 128. This "memory wall" forces researchers to use smaller batches, which slows down training and can hurt final performance.
While "coresets"—subsets of data that mathematically approximate the full dataset's properties—have worked for simple image classification, they fail for LLMs for three primary reasons:
- Data Imbalance: Language datasets are mixtures of many sources. Standard coreset methods often ignore "small" sources (rare tasks or categories), leading to poor generalization.
- The Adam Optimizer: Most coreset methods match "vanilla" gradients, but LLMs use the Adam optimizer, which scales gradients based on historical averages.
- The Curse of Dimensionality: LLM gradients have millions of dimensions, making the distance calculations required to find representative samples computationally prohibitive.
Introducing CoLM: Coresets for Training LLMs
The authors introduce CoLM, which tackles these three challenges through a multi-pronged strategy:
- Handling Imbalance: CoLM identifies "small" sources (those with fewer examples than the average source size) and simply includes all of their examples in every mini-batch. For "large" sources, it selects representative "medoids" (central examples) to keep the batch size small.
- Adam-Aware Matching: Instead of matching raw gradients, CoLM normalizes gradients using historical exponential moving averages—essentially "speaking the same language" as the Adam optimizer.
- Zeroth-Order Sparsification: To handle the massive dimensionality, CoLM uses zeroth-order methods (specifically a technique called SPSA) to estimate gradients for only the last projection matrix of the model. It then applies a mask to keep only the most "salient" dimensions (those with the largest normalized gradient magnitude), reducing the search space to a manageable size.
Key Insights
- The "Small Source" Necessity: The paper proves theoretically and empirically that gradient matching naturally favors majority groups. If you don't explicitly protect small sources by including them entirely, the model loses its ability to learn those niche tasks.
- Data-Centric vs. Model-Centric: Most memory-saving tricks (like LoRA or quantization) focus on the model weights. CoLM proves that being smart about which data you show the model is just as effective, and more importantly, CoLM stacks perfectly with those existing methods.
- Sparsity is Sufficient: Remarkably, the authors found that selecting subsets based on as little as 0.7% of the gradient dimensions is enough to find high-quality representative samples.
Performance and Efficiency Gains
CoLM was evaluated across demanding benchmarks like MathInstruct, SuperGLUE, and The Pile. The results demonstrate significant improvements in memory efficiency, training speed, and overall model performance.
- Memory Efficiency: CoLM reduces the memory footprint of fine-tuning by 2x.
- Superior Performance: On MathInstruct, CoLM with a batch size of 64 outperformed standard fine-tuning with a batch size of 256.
- Generalization: CoLM improved performance by up to 7.1% on in-domain tasks and a staggering 20% on out-of-domain tasks compared to same-sized random mini-batches.
- Speedup: Because it processes fewer examples while maintaining the "signal" of a large batch, CoLM achieved a 2.7x wall-clock speedup compared to standard training, alongside a much faster convergence rate and lower gradient variance.
Limitations and Future Work
While CoLM is highly effective, it currently relies on knowing the "sources" of the data (e.g., which dataset an example came from). While the authors showed that clustering hidden states can act as a proxy for these labels, this adds a small amount of computational overhead.
Future work could explore more sophisticated ways to automatically discover these data mixtures during training. Additionally, while the paper focuses on fine-tuning and smaller-scale pre-training, testing CoLM on the training of 70B+ parameter models from scratch remains an open and exciting frontier.
Summary updated