Add an opt-in MuonClip nanoGPT baseline - #56
Merged
Conversation
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.
Purpose
Add a dedicated one-head nanoGPT baseline for Moonshot AI's MuonClip optimizer while leaving the historical
rg-onehead-trainlauncher, SGD/AdamW/Muon configs, default analysis tables, and existing result fingerprints unchanged.MuonClip is implemented as:
For regular multi-head attention, the implementation measures the maximum finite causal pre-softmax QK logit over every gradient-accumulation micro-batch, computes
and applies the balanced Kimi-K2 scaling
The reference threshold is
100.Isolation from existing baselines
MuonClip is deliberately opt-in through:
Importing the optimizer class does not mutate the ordinary three-arm launcher. The dedicated command installs the extension in-process and delegates to the existing data, checkpoint, evaluation, WeightWatcher, MPS/CUDA/TPU, and long-horizon implementation.
Profiles
configs/muonclip_reference.yamlprovides a matched one-epoch reference:configs/muonclip_10epochs.yamladds a one-seed long spectral-relaxation run with 97,657 training steps, the matched 9,766-step LR horizon, 500-step warmup, and the2e-5floor held after epoch 1.The compact baseline intentionally keeps the repository's matched warmup-cosine protocol. It does not claim to reproduce Kimi K2's 15.5T-token WSD schedule or distributed bfloat16 training.
QK diagnostics
Each MuonClip run writes
muonclip_qk.csvat the configured interval with:The diagnostics are monitoring-only and are never used for checkpoint selection or threshold tuning. Device values are aggregated without a host synchronization on every step; the host transfer occurs only at the diagnostic interval.
Accelerator behavior
Validation
The new tests verify:
0.2 * sqrt(max(n,m))update scaling;