Validation loss 3.28 with AdamW in less than 10k iterations (local bs=64)#15
Open
svaiter wants to merge 2 commits into
Open
Validation loss 3.28 with AdamW in less than 10k iterations (local bs=64)#15svaiter wants to merge 2 commits into
svaiter wants to merge 2 commits into
Conversation
Replace the GPT-2 architecture with the one from modded-nanogpt commit 844e5fdb2334ff83324e6f1f900ce443dd9e1226: RoPE in attention, RMSNorm (parameter-free) before attn/MLP and at the output, attention scale 1/sqrt(2*n_layer), no learned positional embeddings, default PyTorch init. Switch vocab_size to 50257. Update the Adam solver to match the reference run.sh: lr=1.8e-3, betas=(0.9, 0.98), wd=0.1, trapezoidal LR schedule with 256 warmup / 2048 warmdown over 9536 iterations. The cosine-like get_lr stays for the other solvers; the new trapezoidal schedule is added alongside. Adjust per-step batch_size and validation batch_size so the 124M model fits on a 24GB GPU (RTX 4090). On 8xH100 the user can raise them back. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reverts the 24GB-fit adjustment so the production 8xH100 config matches the reference run.sh (global batch = 8 GPUs * 64 = 512). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fix partially issue #5 (bullet point Reaching 3.28).
Validation loss on 10B FineWeb tokens was around 3.6–3.8 after 8k iterations on 8×H100 (2 nodes on jzay) but classical target is ≤3.29 due to the issue 481 of llm.c project by A. Kaparthy
Main cause is that the model in this repo was a mix between classic GPT-2 (learned positional embeddings, LayerNorm, no attention scaling) and new stuff like sinusoidal init. Taking modded-nanogpt commit 844e5fd a bit more rigorously leads to 3.28 loss after ~9k iterations with AdamW, like the run 2 of modded-nanogpt.
At the moment, only the behavior of theses changes on AdamW was tested.
The commits in this PR were prepared using Claude Opus 4.7.
Main changes
generatecode inbenchmark_utils/model_gpt2.py(never used for this benchmark).Architecture changes
Modified file:
benchmark_utils/model_gpt2.pypositional embedding table (
wperemoved).replacing
LayerNorm/ln_f.1/sqrt(2*n_layer)applied to the attentionoutput before the residual add.
init_funchook is kept so the sinusoidal-init experiment still works.vocab_size50257 (real GPT-2 vocab) instead of 50304.Hyperparameters
Modified files:
solvers/adam.py,benchmark_utils/lr_scheduler.pylearning_rate=1.8e-3,betas=(0.9, 0.98),weight_decay=0.1num_steps=9536,warmup_iters=256,warmdown_iters=2048get_lr_trapezoidal(linear warmup → plateau →linear warmdown). The existing cosine-like
get_lris retained for theMuon/SOAP/Scion solvers.