TL;DR
BAdam is a novel optimizer that brings the power of full-parameter finetuning to memory-constrained hardware by combining Block Coordinate Descent (BCD) with Adam’s update rule. It allows researchers to finetune models like Llama 3-8B on a single consumer-grade RTX 3090 (24GB) while consistently outperforming popular low-rank methods like LoRA.
The Memory Bottleneck in LLM Finetuning
Finetuning Large Language Models (LLMs) usually forces a difficult choice: Full Parameter Finetuning (FPF) or Parameter-Efficient Finetuning (PEFT).
FPF (using the standard Adam optimizer) is the gold standard for performance but is a memory nightmare. For a model with $M$ billion parameters, Adam requires roughly $18M$ bytes of GPU RAM just for the weights and optimizer states—not even counting the memory needed for activations. This makes finetuning an 8B model impossible on most single-GPU setups.
PEFT methods, like LoRA, solve the memory problem by only updating a tiny fraction of parameters in a low-rank subspace. However, this "low-rank constraint" can limit the model's ability to learn complex new tasks. The authors of BAdam sought a "third way": a method that performs full parameter updates (high-rank) but maintains the tiny memory footprint of PEFT.
How BAdam Works: Block Coordinate Descent
BAdam (Block-coordinate Adam) achieves its efficiency through a clever application of Block Coordinate Descent (BCD):
- Partitioning: The model's parameters are split into $D$ blocks (typically by transformer layer).
- Sequential Updates: Instead of updating every parameter at every step, BAdam updates only one block at a time.
- Local Adam: For the active block, it performs $K$ steps of the standard Adam update.
- Memory Clearing: Crucially, BAdam only stores the optimizer states (momentum and second moment) for the currently active block. Once a block is updated, these states are cleared from memory before moving to the next block.
- Partial Backpropagation: Because only one block is being updated, the backward pass only needs to calculate gradients down to that specific block, significantly reducing computation time.
While BCD is an old optimization technique, BAdam is the first to rigorously adapt it for the specific architecture and memory demands of modern LLMs.
Datasets and Evaluation
The authors evaluated BAdam across a wide variety of tasks:
- Instruction Tuning: Finetuned on Alpaca-GPT4 (52k samples).
- Math Finetuning: Finetuned on MathInstruct (260k samples).
- Natural Language Understanding: Evaluated on the SuperGLUE benchmark (including tasks like BoolQ, MultiRC, and WiC).
- Continued Pretraining: Tested on the StarCoder-Python dataset to see if the method holds up during raw code training.
Evaluation benchmarks included MT-bench (for instruction following) and various math-specific benchmarks like GSM8K, MATH, and MMLU-Math.
Key Insights and Ideas
- High-Rank Updates Matter: The authors empirically showed that BAdam’s updates have a much higher "effective rank" than LoRA. This suggests that BAdam captures more complex information during training, which explains why it often surpasses LoRA in downstream performance.
- The "Free" Speedup: One of the most elegant features of BAdam is that it isn't just memory-efficient; it's fast. By stopping the backpropagation process at the active block, BAdam reduces the backward pass time by nearly half compared to methods that must propagate gradients through the entire model.
- BCD is a Natural Fit for Transformers: The modular, layer-based nature of Transformers makes them perfect candidates for block partitioning. The authors found that the order of blocks (ascending vs. descending vs. random) doesn't significantly impact final convergence, making the method very robust.
- Preserving Knowledge: An ablation study showed that BCD variants (like BSGD) actually outperformed their full-parameter counterparts (SGD) in downstream tasks. The authors suspect that updating only one block at a time helps "preserve" the general knowledge of the pretrained model better than updating everything at once.
Key Results
- Memory Efficiency: BAdam successfully finetuned Llama 3-8B on a single RTX 3090 (24GB). For comparison, standard Adam would require over 140GB of VRAM for the same task.
- Superior Performance: On MT-bench, BAdam achieved a score of 6.30 for Llama 3-8B, outperforming LoRA (6.27) and Galore (5.82).
- Math Prowess: In math benchmarks for Llama 3-8B, BAdam achieved an average score of 44.4, slightly beating out full-parameter Adam (44.1) while using a fraction of the memory.
- Scaling Up: The authors also demonstrated BAdam on Llama 3-70B using only 4×A100-80GB GPUs, where it again outperformed LoRA (62.7 vs 59.0 average score).
Limitations and Future Work
- Stochastic Analysis: The current theoretical convergence proof is limited to the deterministic case. Future work is needed to extend this to the stochastic setting (using mini-batches).
- Task Scope: The study focused primarily on Supervised Finetuning (SFT). The authors note that testing BAdam on preference optimization (like RLHF or DPO) is a promising next step.
- Hyperparameter K: BAdam introduces one new hyperparameter: $K$ (the number of Adam steps per block). While they provide a guideline for choosing $K$, its optimal value might vary across different model architectures.
Summary updated