nanochat / scripts /base_train.py

Commit History

  1. fix deprecated commit on torchao

    Andrej Karpathy
    f527f76
  2. Improve error handling for batch size alignment

    Andrej
    Unverified signature
    6facdee
  3. Merge pull request #540 from svlandeg/fix/kernel⁠

    Andrej
    Unverified signature
    2fc63c9

  1. delete the whole report thing i think it was a bad idea it just bloats the code. doing this subtracts 540 LOC

    Andrej Karpathy
    f10bd75

  1. Merge branch 'master' into fix-batch-size-assertion

    9f9ef95

  1. fix: use meta device in disable_fp8 to avoid VRAM spike (#616)⁠

    RoomWithOutRoof +1: RoomWithOutRoof
    Unverified signature
    47e983e

  1. bump D:N ratio to 12 per recent scaling laws re-run

    Andrej Karpathy
    1cd94d7

  1. Merge branch 'master' into fix-batch-size-assertion

    daba23c

  1. Autoresearch round 2: smear, backout, and hyperparameter tuning⁠

    Andrej Karpathy +1: Claude Opus 4.6 (1M context)
    a825e63

  1. Merge branch 'master' into fix/kernel

    svlandeg
    a14c399

  1. Merge branch 'master' into fix-batch-size-assertion

    0e5403e

  1. All of these improvements were developed by Claude running autonomously over ~2 days using autoresearch. I didn't touch anything - incredible. All tuning was done on d12 but generalized easily to larger models (e.g. d24 in particular). This means we will also get a new "Time to GPT-2" Leaderboard entry, which I will push separately.⁠

    Andrej Karpathy
    6ed7d1d

  1. Merge branch 'master' into fix-batch-size-assertion

    28894e1

  1. delete autocast, an unnecessary thorn in my side, manage dtypes directly

    Andrej Karpathy
    1076f97
  2. big, breaking change but large upside: swap previous FineWeb-EDU dataset to NVIDIA ClimbMix dataset. Requires people to download the data shards. The upside is that training GPT-2 capablity model now only takes ~2 hours, down from 2.76 hours, so this is a huge win data-wise

    Andrej Karpathy
    324e69c

  1. Simplify batch size assertion message

    998b8f8
  2. Merge remote-tracking branch 'upstream/master' into fix-batch-size-assertion

    d489a1f

  1. Merge branch 'master' into fix/kernel

    svlandeg
    a54691b

  1. fix minor bug in fp8 application to skip tiny matmuls

    Andrej Karpathy
    bac5a35

  1. a number of upgrades to SFT script to bring it up to date w.r.t. pretraining and tuning some of its kwargs based on sweeps

    Andrej Karpathy
    77f8fb8
  2. Add informative error message to batch size assertion

    240a60f

  1. Replace cryptic assertion with descriptive ValueError for batch size alignment

    0f3b6a4

  1. a number of upgrades to SFT script to bring it up to date w.r.t. pretraining and tuning some of its kwargs based on sweeps

    Andrej Karpathy
    788dade

  1. clarify that this is bf16 mfu we're talking about

    Andrej Karpathy
    2f09686
  2. delete torchao dependency, create our own exact API-matched version of Float8Linear, document it very well. for some poorly understood reason, the performance is not only ~identical but actually runs 3% faster. despite of it being significantly simpler and much less code. i don't fully understand why/how atm

    Andrej Karpathy
    e569b59

  1. better comments/flow on all the hyperparameter transfer stuff, and change the WD scaling from my empirical 1/d^2 to a bit more principled version based on Tepoch. All of that theory is based on AdamW and could be suboptimal for Muon

    Andrej Karpathy
    aeff095

  1. nit: don't mutate args, create new var for total_batch_size

    Andrej Karpathy
    2c062aa
  2. auto-calculate optimal batch size. the original setting of 0.5M was only optimal for d12, but d26 prefers 1M and so on

    Andrej Karpathy
    f41dd3c

  1. add fp8 training with torchao

    Andrej Karpathy
    6079f78

  1. also update comments

    svlandeg
    535f664
  2. manually control the over-active garbage collector, save a small few minutes from a typical run

    Andrej Karpathy
    07c4dd4

  1. fix broken import sigh

    Andrej Karpathy
    31b61d2

  1. warmdown of 0.5 is slightly better:

    Andrej Karpathy
    3c3a3d7

  1. Combine AdamW and Muon into single MuonAdamW optimizer, cleaner, ty @chrisjmccormick for idea/help

    Andrej Karpathy
    41bb2ea

  1. add engram-lite, add log, tune scaling laws analysis scripts

    Andrej Karpathy
    c8d93be

  1. first version of engram following modded nanogpt style

    Andrej Karpathy
    59e36cc

  1. Merge branch 've'

    Andrej Karpathy
    a91743c
  2. resolve a crash for odd depths because FA3 needs head_dim % 8 == 0

    Andrej Karpathy
    cf5c9e5

  1. optimal ratio is now around 4

    Andrej Karpathy
    413e91a
  2. add detection of device to report more correct mfu for bf16

    Andrej Karpathy
    2955650

  1. implement flash attention 3 fallback to pytorch sdpa by touching as few lines of code as possible in main files and keeping all implementation to a single file. add tests. add helpful warning messages for the user.

    Andrej Karpathy
    8203efa

  1. oops legacy spurious line now

    Andrej Karpathy
    bdcc030
  2. cleanly separate cpu and gpu sections

    Andrej Karpathy
    255f8b9

  1. fix buggy midtrain and update all kwargs to be idiomatic. that is, argparse uses dashes variables use underscores. the underscores are just a remnant of the previous Configurator object. This is the right way

    Andrej Karpathy
    7312ec9
  2. Big DataLoader refactor: BOS-aligned dataloaders with epoch tracking for pre/mid-training⁠

    Andrej Karpathy
    43c29dd

  1. allow base_loss to report the loss of any arbitrary huggingface model similar to base_eval. had to change dataloader to be a lot better and just take tokenizer, not load the nanochat one. much better this way anyway

    Andrej Karpathy
    21608ec

  1. oops actually make SSSL the default window pattern

    Andrej Karpathy
    b33e394
  2. add alternating window size patterns for the GPT layers, following GPT-3. Experimented a bit and found the pattern SSSL to work well - 3 short, 1 long alternating. This is now the new default and the plots look quite a bit better on flops vs. bpb

    Andrej Karpathy
    fbc1484
  3. Add learnable lambdas that gate the residual connection and a skip connection to the input embeddings, solid bump to val_bpb

    Andrej Karpathy
    aa530cd
  4. Big Muon optimizer changes inspired by latest of modded-nanogpt. Added Polar Express, Adafactor-style variance reduction, cautious weight decay, schedule weight decay linearly to ramp down to zero. Tuned optimum weight decay for multiple model sizes d8, d12, d16, d20 and found a scaling law with optimum wd \propto 1/channels^2, including it as default into code. --weight_decay of base_train is now default on and configured optimally according to all of these experiments. Solid bump to val_bpb observed as a result of these changes.

    Andrej Karpathy
    2c4473d