FastMix: Fast Data Mixture Optimization via Gradient Descent
Summary (Overview)
- FASTMIX is a novel framework that automates data mixture discovery for LLM pre-training and post-training while training only a single proxy model, drastically reducing computational cost compared to prior approaches.
- The core contribution is a reparameterization of mixture selection as a weighted bilevel optimization problem, showing that optimizing mixture ratios is mathematically equivalent to assigning per-source loss weights under uniform source sampling.
- This reformulation makes mixture coefficients fully differentiable, enabling joint, gradient-based optimization of both mixture weights and model parameters via standard optimizers like SGD or Adam.
- FASTMIX achieves state-of-the-art performance with dramatically lower search costs: in pre-training, it reaches 48.2 average score (rank 1 across 14 benchmarks) in just 1.3 GPU-hours—up to 550× faster than RegMix and 55× faster than CLIMB.
- In post-training (SFT), FASTMIX achieves 65.4 average score (5.5 points above the next best method) in 2.2 GPU-hours versus 115+ GPU-hours for CLIMB/RegMix, demonstrating strong cross-domain generalization.
Introduction and Theoretical Foundation
Background and Motivation
The performance of large-scale models depends critically on training data composition. While large and diverse datasets have driven recent advances, identifying the optimal data mixture for pre-training and post-training remains a significant open problem. Popular methods fall into two categories:
- Manual trial-and-error approaches lack standardization and fail to generalize across settings.
- Proxy-based methods (RegMix, CLIMB, DoReMi) train many proxy models under different candidate mixtures, incurring prohibitive computational overhead (hundreds of GPU-hours).
Problem Formulation
Data mixture optimization is formally posed as a bilevel optimization problem. Let be a collection of data sources, and let denote mixture weights on the probability simplex (, ). The training objective under mixture is , and the target is:
The crux of the difficulty: unlike model parameters , mixture sampling ratios are non-differentiable, precluding end-to-end backpropagation. Prior approaches resort to greedy heuristics or policy-gradient updates, which are sample-inefficient and scale poorly.
Key Theoretical Insight: Reparameterization
The central theoretical contribution is showing that mixture sampling is equivalent to per-source loss weighting under uniform sampling. Under mixture sampling (first draw source , then sample ):
This yields the fully differentiable reformulation:
Here serves as a continuous weight scaling each domain's loss, making mixture weights fully differentiable and amenable to gradient-based optimization.
Methodology
Joint Optimization Objective
To improve generalization beyond validation-only search, FASTMIX incorporates two complementary strategies:
- Entropy-based regularization to prevent mixture collapse:
- Training loss as auxiliary target to balance validation and training signals
The joint search objective is:
where and are trade-off hyperparameters. Empirically, is set small (e.g., ) and is most effective at moderate values (e.g., 0.1).
Alternating Optimization Procedure
FASTMIX implements an iterative procedure alternating between two steps:
(i) Inner loop (network parameter update) — Given current mixture weights , update model parameters for steps:
(ii) Outer loop (mixture weight update) — Update mixture weights based on validation feedback:
Closed-Form Gradient (Key Result)
For the special case with SGD updates, the gradient admits a closed-form solution:
Intuition: The gradient w.r.t. is proportional to the alignment between the validation gradient and the training gradient from source , \nabla_w \mathcal{L}_{t rain}(D_i, w^t}). If these gradients are aligned (positive dot product), the derivative is negative, so gradient descent increases , emphasizing sources that reduce validation loss. If opposed, is decreased. Near-orthogonality yields small updates.
Algorithm
Algorithm 1: FASTMIX Optimization Algorithm
1: Initialize model parameters $w^0$, mixture weights $\alpha^0$, inner-loop duration $n_1$ and outer-loop duration $n_2$.
2: for $t = 0, 1, \ldots, T - 1$ do
3: if $(t) \mod n_1
eq 0$ then
4: // Inner loop: update model parameters
5: $w^{t+1} \leftarrow w^t - \eta_w^t \frac{\partial [\sum_{i=1}^k \alpha_i^t \mathcal{L}_{train}(D_i, w^t)]}{\partial w^t}$
6: else
7: // Outer loop: update mixture weights
8: $\alpha^{t+1} \leftarrow \alpha^t - \eta_alpha^t \frac{\partial \mathcal{L}_{target}}(w^{t+n_2})}{\partial \alpha^t}$
9: end if
10: end for
11: Output: the optimized mixture weight $a^{final}$ after the final outer loop update.
Empirical Validation / Results
Pre-training Experiments
Setup: Pile dataset (17 uncopyrighted subsets), 1M-parameter proxy models trained on up to 1B tokens, search target = Pile-cc validation loss. Evaluation: 1B-parameter model trained on 25B tokens, tested on 14 downstream benchmarks.
| Method | Avg. Score | Avg. Rank | Search Cost (GPU-hours) |
|---|---|---|---|
| Human Heuristic | — | — | — |
| DoReMi | — | — | — |
| RegMix | 47.2 | — | 720.5 |
| CLIMB | 47.5 | — | 71.9 |
| FASTMIX (ours) | 48.2 | 1 | 1.3 |
Key results:
- FASTMIX achieves the highest average performance (48.2) and best average rank (1) across all 14 benchmarks, leading on 9 of 14 individual tasks.
- Search efficiency: 1.3 GPU-hours vs. 71.9 (CLIMB) and 720.5 (RegMix)—a 55× and 550× speedup, respectively.
Post-training (SFT) Experiments
Setup: Qwen2.5-Math-Instruct 7B model, 8 domains (Math, Code, Dialogue, STEM). Search objective: 1:1 weighted sum of GSM8K and gaokao2023en scores. Proxy models: Qwen2.5-1.5B-Instruct (~1B parameters) due to the absence of very small proxies in post-training. Evaluation: MATH, AIME-24, LiveCodeBench-v2, GPQA-Diamond.
| Method | Avg. Score | Search Cost (GPU-hours) |
|---|---|---|
| RegMix (64 proxies) | — | 115.9 |
| CLIMB (64 proxies) | 59.9 | 117.4 |
| FASTMIX (ours) | 65.4 | 2.2 |
Key results:
- FASTMIX achieves 65.4 average score, a 5.5-point lead over the next best method (CLIMB, 59.9).
- Exceptional generalization: Despite optimizing only on math benchmarks (GSM8K, gaokao2023en), FASTMIX achieved the best performance on LiveCodeBench (coding) and GPQA-Diamond (STEM QA)—demonstrating avoidance of overfitting to the optimization signal.
- Search cost: 2.2 GPU-hours vs. 115.9/117.4 for RegMix/CLIMB (a 52× reduction).
Theoretical and Practical Implications
Theoretical Contributions
- Equivalence theorem: The reparameterization formally establishes that mixture sampling and per-source loss weighting are mathematically equivalent, bridging discrete sampling ratios with continuous differentiable weights.
- Closed-form gradient: The derivation of Eq. (7) provides an interpretable, computationally efficient gradient that reveals the mechanism of mixture optimization—reallocating mass toward sources whose gradients align with validation improvement.
- Generalizable framework: The bilevel formulation is applicable across both pre-training and post-training stages, with different proxy model scales.
Practical Implications
- Scalability: FASTMIX's single-proxy-model approach makes mixture optimization feasible at scales where training hundreds of proxies (RegMix/CLIMB) is prohibitive, particularly in post-training with large (1B+) proxy models.
- Cross-domain transfer: The method discovers mixtures that generalize beyond the optimization target, suggesting fundamental capability improvement rather than benchmark overfitting.
- Industrial lessons: The authors share practical insights from industrial development:
- Non-differentiable metrics: Use differentiable proxies (e.g., SFT loss) instead of black-box estimators (SPSA, finite differences), which are unstable and inefficient.
- Regularization: Entropy regularization works on clean academic datasets, but industrial robustness is better achieved via strict oversampling ratio constraints (capping up-sampling at 3× original size).
- Proxy model scale: Small proxies (<0.5B) suffer convergence instability and data-source biases; caution is advised.
- Search target data: Pre-training and SFT data length discrepancies can cause gradient divergence; concatenating SFT sequences to match pre-training length mitigates this.
Conclusion
FASTMIX introduces an efficient framework for data mixture discovery in large-model training. The key contribution is a weighted bilevel reformulation of mixture selection: via reparameterization, optimizing sampling ratios becomes equivalent to learning per-source loss weights, making mixture coefficients differentiable. This enables joint, gradient-based optimization of both model and mixture using a single proxy model rather than hundreds. Across pre-training and post-training, FASTMIX delivers superior accuracy with orders-of-magnitude lower search cost, making data mixture optimization practical, scalable, and robust for next-generation LLMs.
Future Works
The authors identify several limitations and directions for future exploration:
- Greediness: The current one-step, short-horizon outer-loop update introduces a degree of greediness, making the algorithm sensitive to data noise.
- Time-evolving source dynamics: Observed search dynamics reveal that data sources exhibit competitive, time-evolving relationships—some vital early, others dominant after prolonged training. This offers insights into data curriculum design.
- Extension to data source attribution: FASTMIX could be extended beyond data mixing to serve as a framework for data source attribution, inviting community collaboration.
Related papers
- Adaptive-Depth Is a Finishing Stage
Fixed-first training cuts adaptive-depth transformer training compute by 30-45% with negligible quality loss by reserving full-depth updates for a brief final phase.
- Beyond fabrication: Misattributed numbers in papers written by AI research agents
AI research agents mostly misattribute real numbers to wrong experiments rather than fabricating them, so verifying provenance requires checking which run produced each claim.
- What Does a Harness Repair? A Preregistered Study of Visibility, Baseline Adequacy and Evaluation Defects
Preregistered harness-search studies show most accuracy gains are visibility artifacts, and searched harnesses failed to beat trivial constant-label baselines despite large nominal improvements.