Papers › Sophia: A Scalable Stochastic Second-order Optimizer for Language Model Pre-training

Sophia: A Scalable Stochastic Second-order Optimizer for Language Model Pre-training

23 May 2023arXiv:2305.14342archive 2025-07-28

Hong Liu, Zhiyuan Li, David Hall, Percy Liang, Tengyu Ma

Given the massive cost of language model pre-training, a non-trivial improvement of the optimization algorithm would lead to a material reduction on the time and cost of training. Adam and its variants have been state-of-the-art for years, and more sophisticated second-order (Hessian-based) optimizers often incur too much per-step overhead. In this paper, we propose Sophia, Second-order Clipped Stochastic Optimization, a simple scalable second-order optimizer that uses a light-weight estimate of the diagonal Hessian as the pre-conditioner. The update is the moving average of the gradients divided by the moving average of the estimated Hessian, followed by element-wise clipping. The clipping controls the worst-case update size and tames the negative impact of non-convexity and rapid change of Hessian along the trajectory. Sophia only estimates the diagonal Hessian every handful of iterations, which has negligible average per-step time and memory overhead. On language modeling with GPT models of sizes ranging from 125M to 1.5B, Sophia achieves a 2x speed-up compared to Adam in the number of steps, total compute, and wall-clock time, achieving the same perplexity with 50% fewer steps, less total compute, and reduced wall-clock time. Theoretically, we show that Sophia, in a much simplified setting, adapts to the heterogeneous curvatures in different parameter dimensions, and thus has a run-time bound that does not depend on the condition number of the loss.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2305.14342")

Code

Syntology Ran 6 of 19 code samples harvested from 5 repositories linked to this paper; 13 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · our draft was wrong; 4 ran with no contract checked.

By repository: named in the paper: 5 samples from 1 repository, 0 ran; community (archive-listed): 14 samples from 4 repositories, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

stanford-crfm/levanter mentioned in papermentioned on GitHubjaxApache-2.0 report
Liuhong99/Sophia mentioned on GitHubpytorch report
cor3bit/somax mentioned on GitHubjax report
helw150/levanter mentioned on GitHubjaxApache-2.0 report
kyegomez/Sophia mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

19 samples harvested; 6 ran; 1 honoured the contract we drafted; 13 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
1ran · our draft was wrong
4ran
13unverified

Licence: 0 of the 19 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 5 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

auto_metric_from_name stanford-crfm/levanter/src/levanter/metrics.py named in the paper unverified Apache-2.0 (permissive) · de22a502eda2c3b9 · report
distinct_values stanford-crfm/levanter/src/levanter/schedule.py named in the paper unverified Apache-2.0 (permissive) · c501ae8133a11ec3 · report
fold stanford-crfm/levanter/src/levanter/metrics.py named in the paper unverified Apache-2.0 (permissive) · d40382c2fb844d41 · report
unwrap_metrics stanford-crfm/levanter/src/levanter/metrics.py named in the paper unverified Apache-2.0 (permissive) · 3f1967528c23afbd · report
value_at_step stanford-crfm/levanter/src/levanter/schedule.py named in the paper unverified Apache-2.0 (permissive) · 9b3a9ebcd8b2b32b · report
GenericAdaptiveOptimizer labmlai/annotated_deep_learning_paper_implementations/labml_nn/optimizers/sophia.py community (archive-listed) ran MIT (permissive) · 15bc730db57a3642 · report
Sophia labmlai/annotated_deep_learning_paper_implementations/labml_nn/optimizers/sophia.py community (archive-listed) ran MIT (permissive) · a6e9300c48fec63f · report
SophiaG Liuhong99/Sophia/sophia.py community (archive-listed) ran · metamorphic tier: deterministic MIT (permissive) · 1436d0069dad845e · report
WeightDecay labmlai/annotated_deep_learning_paper_implementations/labml_nn/optimizers/sophia.py community (archive-listed) ran MIT (permissive) · ba6a2ba94fbeb5e9 · report
get_lr Liuhong99/Sophia/train_sophiag.py community (archive-listed) ran · honoured contract fingerprinted MIT (permissive) · a273291a5ece194d · report
group_texts kyegomez/Sophia/experiments/training.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · 2382cb6829841947 · report
_single_tensor_sophiag Liuhong99/Sophia/sophia.py community (archive-listed) unverified MIT (permissive) · 34b6a986acbf4f68 · report
eval_loss_loop helw150/levanter/src/levanter/callbacks.py community (archive-listed) unverified Apache-2.0 (permissive) · 1421ef5f024f6e23 · report
load_array_from_tensorstore helw150/levanter/src/levanter/tensorstore_serialization.py community (archive-listed) unverified Apache-2.0 (permissive) · 003d0a17d2ac09ca · report
local_device_grid_positions helw150/levanter/src/levanter/mesh.py community (archive-listed) unverified Apache-2.0 (permissive) · f3fb5a3a9edbf5ef · report
process_mesh_position helw150/levanter/src/levanter/mesh.py community (archive-listed) unverified Apache-2.0 (permissive) · efa87b8fc2935200 · report
process_mesh_size helw150/levanter/src/levanter/mesh.py community (archive-listed) unverified Apache-2.0 (permissive) · 030ef454b59ac14a · report
save_xla_dumps_to_wandb helw150/levanter/src/levanter/logging.py community (archive-listed) unverified Apache-2.0 (permissive) · 8b3f53737bb49ef4 · report
sophiag Liuhong99/Sophia/sophia.py community (archive-listed) unverified MIT (permissive) · 24947d588d9b62aa · report

Tasks

Language ModelingLanguage ModellingStochastic Optimization

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Introduced by this paper: Sophia

AdamAttentionAttention DropoutBPECosine AnnealingDense ConnectionsDiscriminative Fine-TuningDropoutGPTGPT-2Layer NormalizationLinear LayerLinear Warmup With Cosine AnnealingMulti-Head AttentionResidual ConnectionSoftmaxSophiaWeight Decay

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections