60,412
stars
+21
8,471
forks
380
watchers
564
prs
146
issues
0
releases
161
discussions
README
nanochat !nanochat logo !scaling laws nanochat is the simplest experimental harness for training LLMs. It is designed to run on a single GPU node, the code is minimal/hackable, and it covers all major LLM stages including tokenization, pretraining, finetuning, evaluation, and inference. For example, you can train your own GPT-2 capability LLM (which cost ~$43,000 to train in 2019) for only $48 (~2 hours of 8XH100 GPU node) and then talk to it over a simple CLI. On a spot instance, the total cost can be closer to ~$15. More generally, nanochat is configured out of the box to train an entire miniseries of compute-optimal models by setting one single complexity dial: --depth, the number of layers in the GPT transformer model (GPT-2 capability happens to be approximately depth 26). All other hyperparameters (the width of the transformer, number of heads, learning rate adjustments, training horizons, weight decays, ...) are calculated automatically in an optimal way. For questions about the repo, I recommend either using DeepWiki from Devin/Cognition to ask questions about the repo, or use the Discussions tab, or come by the nanochat channel on Discord. Time-to-GPT-2 Leaderboard Presently, the main focus of development is on tuning the pretraining stage, which takes the most amount of compute. Inspired by the modded-nanogpt repo and to incentivise progress and community collaboration, nanochat maintains a leaderboard for a "GPT-2 speedrun", which is the wall-clock time required to train a nanochat model to GPT-2 grade capability, as measured by the DCLM CORE score. The runs/speedrun.sh script always reflects the reference way to train GPT-2 grade model and talk to it. The current leaderboard looks as follows: | | time | val_bpb | CORE | Description | Date | Commit | Contributors | |---|-------------|---------|------|-------------|------|--------|--------------| | 0 | 168 hours | - | 0.2565 | Original OpenAI GPT-2 checkpoint | 2019 | - | OpenAI | | 1 | 3.04 | 0.74833 | 0.2585 | d24 baseline, slightly overtrained | Jan 29 2026 | 348fbb3 | @karpathy | | 2 | 2.91 | 0.74504 | 0.2578 | d26 slightly undertrained +fp8 | Feb 2 2026 | a67eba3 | @karpathy | | 3 | 2.76 | 0.74645 | 0.2602 | bump total batch size to 1M tokens | Feb 5 2026 | 2c062aa | @karpathy | | 4 | 2.02 | 0.71854 | 0.2571 | change dataset to NVIDIA ClimbMix | Mar 4 2026 | 324e69c | @ddudek @karpathy | | 5 | 1.80 | 0.71808 | 0.2690 | autoresearch round 1 | Mar 9 2026 | 6ed7d1d | @karpathy | | 6 | 1.65 | 0.71800 | 0.2626 | autoresearch round 2 | Mar 14 2026 | a825e63 | @karpathy | The primary metric we care about is "time to GPT-2" - the wall clock time needed to outperform the GPT-2 (1.6B) CORE metric on an 8XH100 GPU node. The GPT-2 CORE score is 0.256525. In 2019, the training of GPT-2 cost approximately $43,000 so it is incredible that due to many advances over 7 years across the stack, we can now do so much faster and for well below $100 (e.g. at the current ~$3/GPU/hr, an 8XH100 nod
Top issues
#737Use Official PyTorch FA3 Builds5 comments · 2026-04-29#590[Bug] scripts/chat_sft.py produces loss: nan from step 00001 on small device-batch-size (≤8) due to fully-masked micro-batches4 comments · 2026-03-05#858Could nanochat be a testbed for recurrent/loop Transformers?3 comments · 2026-09-22#810chat_rl: the sampled assistant_end token is masked out, so stopping is never reinforced3 comments · 2026-07-20#698RTX 3050TI Not detecting m.get_device()3 comments · 2026-04-12#542Add --model-tag to scripts.chat_cli call in runcpu.sh/speedrun.sh example2 comments · 2026-02-19#514[BUG] AssertionError in gpt.py: Evaluation prompts exceed static RoPE cache (seq_len=256)2 comments · 2026-02-08#73Question: Are there plans to implement TorchScript/TorchTrace/ONNX inference?2 comments · 2025-10-15
Discussions
#889MeG1 comments · 2026-11-04#868Polynomial kernel attention of odd degree0 comments · 2026-10-29#867VLLM plugin for nanchat 2026 #92d63d40 comments · 2026-10-27#863airgpt: a nanochat-style pipeline for Apple Silicon in MLX0 comments · 2026-10-12#8628x RTX Pro 6000 S GPUs pre-trained in ~2hr 15m0 comments · 2026-10-12#856Stuck at the optimizer after figuring out backward()1 comments · 2026-09-17#846Verify run 6 baseline metrics3 comments · 2026-09-01#819GPT-2 grade on a single RTX 5090 in 41 hours — recipe, Blackwell gotcha, and an open question about sliding windows1 comments · 2026-08-02