Abstract
Training Large Language Models (LLMs) requires a delicate balance between computational efficiency and model performance. While adaptive optimizers like AdamW are standard, their per-parameter approach is memory-intensive and often fails to account for the architectural heterogeneity of LLMs. We present Scaling with Gradient Grouping (SGG), a plug-and-play optimizer wrapper that stabilizes and accelerates training by dynamically clustering gradient statistics. SGG enables parameter-efficient methods like LoRA to achieve performance parity with full-rank training while maintaining a minimal memory footprint.
Introduction
The current landscape of LLM training is defined by a "performance tax" on efficiency. Practitioners often face a deadlock: adopt memory-intensive full-rank training for stability or use efficient methods like LoRA at the cost of significant performance degradation. This discrepancy stems from the diverse optimization behaviors across different layers and parameter groups within a model. SGG addresses this by introducing collective group-wise constraints that harmonize the training process across these heterogeneous components.
Methodology
SGG operates as a wrapper atop existing optimizers (e.g., AdamW, LAMB, CAME), implementing a three-step dynamic adjustment cycle:
- Online Clustering: SGG utilizes Mini-batch K-means to periodically group gradient momentum vectors within each layer into $K$ clusters (typically $K=2$ or $3$).
- Stability Measurement: A novel metric, Median of Deviation to Average (MDA), quantifies how a cluster's dynamics deviate from the layer average relative to global model statistics.
- Group-Specific Scaling: Based on the MDA, SGG calculates scaling factors to modulate learning rates. Erratic groups are scaled down to prevent loss spikes, while stable groups receive larger updates.
By offloading clustering computations to the CPU, SGG maintains near-zero additional GPU memory overhead.
Experimental Setup
The efficacy of SGG was evaluated across 20 public datasets covering diverse tasks:
- Pre-training: LLaMA models (60M to 1B) on the C4 dataset.
- Supervised Fine-Tuning (SFT): RoBERTa on GLUE and LLaMA on Alpaca.
- PEFT & Reasoning: Benchmarks including BoolQ, PIQA, and HellaSwag.
- Preference Alignment: Direct Preference Optimization (DPO) on Qwen2.5-0.5B.
- Multimodal LLMs: LLaVA framework on GQA and ScienceVQA.
Key Insights: Training Homogeneity
A core finding is that parameters within a single layer do not move in unison. By identifying these sub-groups, SGG applies "collective discipline" without sacrificing the precision of per-parameter adaptation. Comparing cluster behavior to global statistics promotes training homogeneity, preventing divergent layer dynamics from causing training instability.
Results
SGG demonstrates significant improvements across various training regimes:
- Closing the LoRA Gap: LoRA + SGG achieved a validation perplexity of 14.73 in 1B pre-training, nearly matching full-rank AdamW (14.56) and vastly outperforming standard LoRA (19.21).
- Universal Performance Gains: Across all model sizes on C4, SGG reduced validation perplexity by up to 10.3% for low-rank methods.
- Enhanced Alignment: In DPO tasks, SGG improved top-1 accuracy by 1.8% over standard AdamW.
- Robustness: SGG maintains stability across a wide range of batch sizes (128 to 4096), effectively mitigating gradient outliers.
Conclusion and Future Work
SGG successfully "tames" LLM training by harmonizing gradient dynamics. While the current implementation adds a minor computational overhead (4-8% training time) due to clustering, its ability to bridge the gap between efficiency and performance is a significant step forward. Future research will explore more complex grouping strategies and evaluate SGG on frontier-scale models exceeding 70B parameters.
Summary updated