Nexus: Same Pretraining Loss, Better Downstream Generalization via Common Minima
Organizations: Tsinghua University · ByteDance Seed
Abstract
The foundational capabilities of large language models are acquired during pretraining on internet-scale, highly heterogeneous data mixtures. In this work, we investigate an interesting geometric question regarding the converged state of pretraining: Does the model converge to a common minimizer across all data sources (e.g., \cref{fig:cwa_illustration:close}), or merely a minimizer of the summed loss (e.g., \cref{fig:cwa_illustration:distant})? We hypothesize that the geometric "closeness" of task-specific minima is intrinsically linked to downstream generalization. We reveal that standard optimizers (e.g., AdamW) often converge to points where task-specific minima are distant from each other. To address this, we propose the Nexus optimizer, which encourages the closeness of these minima by maximizing gradient similarity during optimization. Experiments across models ranging from 130M to 3B parameters, various data mixtures and hyperparameter schedules, show that Nexus significantly boosts downstream performance, despite achieving the same pretraining loss (see \cref{fig:demo:benchmark}). Notably, on the 3B model, Nexus reduces the out-of-distribution loss by 0.012 and yields up to a 15.0% accuracy improvement on complex reasoning tasks (e.g., GSM8k). This finding challenges the reliance on pretraining loss as the sole proxy for model evaluation and demonstrates the importance of implicit biases in unlocking downstream generalization.
Figures & tables
| Model | Optim. | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Pretrain. | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | |||
| 1B | AdamW | Acc. ( ) | 1.826 | 1.433 | 32.1 | 25.0 | 21.8 | 29.6 | 18.0 | 13.0 | 19.0 | 17.0 | 21.9 |
| Loss ( ) | 2.363 | 2.221 | 2.124 | 1.640 | 1.429 | 1.204 | 1.270 | 2.035 | 1.786 | ||||
| Nexus | Acc. ( ) | 1.826 | 1.428 | 33.5 | 30.4 | 21.8 | 29.3 | 20.0 | 13.0 | 19.0 | 22.0 | 23.6 | |
| Loss ( ) | 2.316 | 2.201 | 2.102 | 1.638 | 1.396 | 1.176 | 1.261 | 1.977 | 1.758 | ||||
| Improv. | Acc. ( ) | - | - | +1.4 | +5.4 | 0.0 | -0.3 | +2.0 | 0.0 | 0.0 | +5.0 | +1.7 | |
| Chinchila | Optim. | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
| Pretrain. | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | |||
| 2 | AdamW | Acc. ( ) | 1.606 | 1.302 | 47.8 | 32.8 | 22.6 | 36.6 | 44.0 | 32.0 | 43.0 | 38.0 | 37.1 |
| Loss ( ) | 2.265 | 2.005 | 1.910 | 1.534 | 1.259 | 1.054 | 1.116 | 1.922 | 1.633 | ||||
| Nexus | Acc. ( ) | 1.602 | 1.290 | 48.9 | 29.6 | 23.4 | 36.6 | 59.0 | 40.0 | 47.0 | 38.0 | 40.3 | |
| Loss ( ) | 2.179 | 1.981 | 1.881 | 1.504 | 1.227 | 1.026 | 1.086 | 1.921 | 1.601 | ||||
| Improv. | Loss ( ) | +0.004 | +0.012 | +0.086 | +0.024 | +0.029 | +0.030 | +0.032 | +0.028 | +0.030 | +0.001 | +0.032 | |
| Schedule | Optim. | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Eval | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | |||
| WSD | AdamW | Acc. ( ) | 1.606 | 1.302 | 47.8 | 32.8 | 22.6 | 36.6 | 44.0 | 32.0 | 43.0 | 38.0 | 37.1 |
| Loss ( ) | 2.265 | 2.005 | 1.910 | 1.534 | 1.259 | 1.054 | 1.116 | 1.922 | 1.633 | ||||
| Nexus | Acc. ( ) | 1.602 | 1.290 | 48.9 | 29.6 | 23.4 | 36.6 | 59.0 | 40.0 | 47.0 | 38.0 | 40.3 | |
| Loss ( ) | 2.179 | 1.981 | 1.881 | 1.504 | 1.227 | 1.026 | 1.086 | 1.921 | 1.601 | ||||
| Improv. | Loss ( ) | +0.004 | +0.012 | +0.086 | +0.024 | +0.029 | +0.030 | +0.032 | +0.028 | +0.030 | +0.001 | +0.032 | |
| Metric | Optim. | Pretrain Set | OOD Set | GPQA-D | GSM8k | Math500 | HumanEval | MBPP |
|---|---|---|---|---|---|---|---|---|
| Grad Sim. ( ) | AdamW | 0.4499 | 0.2228 | 0.0824 | 0.0374 | 0.0422 | 0.0367 | 0.0091 |
| Nexus | 0.4661 | 0.2464 | 0.0924 | 0.0325 | 0.0427 | 0.0382 | 0.0092 | |
| Param. Closeness. ( ) | AdamW | 1.452 | 2.812 | 4.500 | 3.418 | 3.775 | 4.472 | 3.645 |
| Nexus | 1.441 | 2.806 | 4.482 | 3.326 | 3.766 | 4.444 | 3.648 | |
| Loss ( ) | AdamW | 1.606 | 1.302 | 1.910 | 1.259 | 1.054 | 1.116 | 1.922 |
| Nexus | 1.602 | 1.290 | 1.881 | 1.227 | 1.026 | 1.086 | 1.921 |
| Notation | Description |
|---|---|
| Data and Loss Functions | |
| Total number of distinct pretraining data sources (tasks). | |
| Sampling probability (data mixing ratio) for the -th data source. | |
| The expected / empirical loss on the -th source task. | |
| The averaged pretraining loss: . | |
| The loss on an unseen downstream evaluation task . | |
| Model Size | Optimizer | Outer LR | Inner LR ( ) | Chinchilla | Tokens (B) | Weight Decay | Reference |
| 1B | Adam | 0.002 | - | 50 | 0.2 | Sec. ˜ 4.3 | |
| Nexus | 0.002 | 0.04 | 50 | 0.2 | |||
| 3B | Adam | 0.001 | - | 110 | 0.2 | Secs. ˜ 4.2 and 4.5 Secs. ˜ 4.4 and 14.3 | |
| Muon | 0.001 | - | 110 | 0.1 | |||
| Nexus | 0.001 | 0.1 | 110 | 0.2 |
| Data | Optim. | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Pretrain. | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | |||
| Math10 | AdamW | Acc. ( ) | 1.606 | 1.302 | 47.8 | 32.8 | 22.6 | 36.6 | 44.0 | 32.0 | 43.0 | 38.0 | 37.1 |
| Loss ( ) | 2.265 | 2.005 | 1.910 | 1.534 | 1.259 | 1.054 | 1.116 | 1.922 | 1.633 | ||||
| Nexus | Acc. ( ) | 1.602 | 1.290 | 48.9 | 29.6 | 23.4 | 36.6 | 59.0 | 40.0 | 47.0 | 38.0 | 40.3 | |
| Loss ( ) | 2.179 | 1.981 | 1.881 | 1.504 | 1.227 | 1.026 | 1.086 | 1.921 | 1.601 | ||||
| Improv. | Loss ( ) | +0.004 | +0.012 | +0.086 | +0.024 | +0.029 | +0.030 | +0.032 | +0.028 | +0.030 | +0.001 | +0.032 | |
| Model | Optim. | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Pretrain. | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | |||
| 1B | Adam | Acc. ( ) | 1.331 | 1.863 | 34.2 | 25.8 | 18.8 | 24.8 | 18.0 | 14.0 | 38.0 | 1.0 | 21.8 |
| Loss ( ) | 2.552 | 2.280 | 2.191 | 1.700 | 1.708 | 1.346 | 1.324 | 2.991 | 2.011 | ||||
| Nexus | Acc. ( ) | 1.338 | 1.835 | 31.4 | 25.0 | 18.8 | 23.0 | 22.0 | 12.0 | 41.0 | 15.0 | 23.5 | |
| Loss ( ) | 2.446 | 2.261 | 2.172 | 1.689 | 1.749 | 1.325 | 1.325 | 2.908 | 1.984 | ||||
| Improv. | Loss ( ) | -0.007 | +0.028 | +0.106 | +0.019 | +0.019 | +0.011 | -0.041 | +0.021 | -0.001 | +0.083 | +0.027 | |
| Size | Optim. | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Pretrain. | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | |||
| 130M | AdamW | Acc. ( ) | 2.038 | 1.559 | 28.0 | 22.6 | 24.2 | 25.1 | 7.0 | 6.0 | 0.0 | 10.0 | 15.4 |
| Loss ( ) | 2.555 | 2.438 | 2.338 | 1.793 | 1.612 | 1.360 | 1.407 | 2.230 | 1.967 | ||||
| Nexus | Acc. ( ) | 2.031 | 1.549 | 27.0 | 25.7 | 21.8 | 28.8 | 5.0 | 11.0 | 0.0 | 10.0 | 16.2 | |
| Loss ( ) | 2.523 | 2.414 | 2.312 | 1.792 | 1.601 | 1.330 | 1.384 | 2.183 | 1.942 | ||||
| Improv. | Acc. ( ) | - | - | -1.0 | +3.1 | -2.4 | +3.7 | -2.0 | +5.0 | 0.0 | 0.0 | +0.8 | |
| Optim. | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Pretrain. | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | ||
| AdamW | Acc. ( ) | 1.606 | 1.302 | 47.8 | 32.8 | 22.6 | 36.6 | 44.0 | 32.0 | 43.0 | 38.0 | 37.1 |
| Loss ( ) | 2.265 | 2.005 | 1.910 | 1.534 | 1.259 | 1.054 | 1.116 | 1.922 | 1.633 | |||
| Adam+Nexus | Acc. ( ) | 1.602 | 1.290 | 48.9 | 29.6 | 23.4 | 36.6 | 59.0 | 40.0 | 47.0 | 38.0 | 40.3 |
| Loss ( ) | 2.179 | 1.981 | 1.881 | 1.504 | 1.227 | 1.026 | 1.086 | 1.921 | 1.601 | |||
| (- AdamW) | Acc. ( ) | - | - | +1.1 | -3.2 | +0.8 | 0.0 | +15.0 | +8.0 | +4.0 | 0.0 | +3.2 |
| Phase | Optim. | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| SFT | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | |||
| Pre-SFT | AdamW | Acc. ( ) | 1.655 | 1.263 | 52.7 | 28.9 | 25.8 | 41.1 | 54.0 | 37.0 | 50.0 | 42.0 | 41.4 |
| Loss ( ) | 2.221 | 1.938 | 1.842 | 1.484 | 1.233 | 1.031 | 1.053 | 1.859 | 1.583 | ||||
| Nexus | Acc. ( ) | 1.647 | 1.258 | 50.9 | 22.7 | 22.7 | 35.9 | 57.0 | 40.0 | 48.0 | 42.0 | 39.9 | |
| Loss ( ) | 2.138 | 1.929 | 1.838 | 1.489 | 1.179 | 1.006 | 1.030 | 1.803 | 1.552 | ||||
| Improv. Loss ( ) | +0.008 | +0.005 | +0.083 | +0.009 | +0.004 | -0.005 | +0.054 | +0.025 | +0.023 | +0.056 | +0.031 | ||
| Algorithm Newton-Schulz Iteration | Algorithm RMS-Aligned Update |
| def zeropower_via_ns(G, steps=5): a, b, c = 3.4445, -4.7750, 2.0315 X = G / (torch.norm(G) + 1e-7) for _ in range(steps): A = X @ X.mT X = aX + (bA + c*A@A) @ X return X | def sgd_alignRMS_update(G): K = min(G.shape[-2:]) # Normalize to match Muon scale norm = torch.norm(G) + 1e-7 return G * (K**0.5) / norm |
| Model | Configuration | Metric | Loss Metrics ( ) | Gen. | Reasoning | Math | Code | Avg. | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Pretrain. | OOD | MMLU | GPQA | GPQA-D | BBH | GSM8k | MATH | HumanEval | MBPP | All | |||
| 1B | AdamW (BS=128) | Acc. ( ) | 1.937 | 1.506 | 29.3 | 25.0 | 20.3 | 23.3 | 8.0 | 5.0 | 11.0 | 14.0 | 17.0 |
| Loss ( ) | 2.396 | 2.333 | 2.231 | 1.728 | 1.510 | 1.286 | 1.340 | 2.091 | 1.864 | ||||
| 3B | AdamW (BS=128) | Acc. ( ) | 1.627 | 1.326 | 45.4 | 29.7 | 21.9 | 40.7 | 39.0 | 26.0 | 37.0 | 39.0 | 34.8 |
| Loss ( ) | 2.262 | 2.033 | 1.937 | 1.556 | 1.281 | 1.067 | 1.148 | 1.951 | 1.654 | ||||
Language Model Pretraining
Language model pretraining teaches models language patterns and knowledge from large text corpora before they are adapted to specific tasks.
See all 440 papers