NanoChat – The best ChatGPT that $100 can buy
TL;DR Highlight
nanochat trains a GPT-2-grade LLM in about 2 hours on 8XH100 for roughly $48
Who Should Read
A backend developer who only calls LLM APIs and wants to run the whole training pipeline, from tokenizer to inference, themselves
Core Mechanics
- GPT-2-grade model for $48
- GPT-2 cost about $43,000 to train in 2019, versus about 2 hours on an 8XH100 node (~$24/hr), or $48, now.
- On a spot instance the total can be closer to ~$15.
- Whole training stack in one repo
- It covers tokenization, pretraining, finetuning, evaluation, and inference.
- Run runs/speedrun.sh to train, then python -m scripts.chat_cli to chat.
- One --depth dial sets model size
- Depth is the number of transformer layers; width, heads, learning rate adjustments, training horizon, and weight decay are computed automatically.
- GPT-2 capability is around depth 26, in the d24-d26 range with current code.
- GPT-2 speedrun leaderboard
- The metric is time to beat the GPT-2 (1.6B) DCLM CORE score of 0.256525.
- The original GPT-2 is 168 hours; the latest entry is 1.65 hours (autoresearch round 2, Mar 14 2026).
- Dataset swap and bigger batches cut time
- Raising total batch size to 1M tokens took the time from 2.91h to 2.76h.
- Switching the dataset to NVIDIA ClimbMix took it from 2.76h to 2.02h.
- Runs on one GPU or CPU too
- Omitting torchrun runs on a single GPU with nearly identical results but 8x longer.
- With under 80GB VRAM, lower --device-batch-size from the default 32 to 16, 8, 4.
Community Reactions
- Opinion that the title is misleading
- Commenters said you must rent H100 time, so it is neither on-device nor truly $100.
- Another noted 8XH100 nodes start around $450/day and asked where the $100 comes from.
- Experience: author wrote it mostly by hand
- The author replied it was basically all hand-written with tab autocomplete.
- He said claude/codex agents were not helpful, possibly because the repo is far from the data distribution.
- Questions about personal data and local training
- One asked whether they could train on their psychology materials and run it on a 1xH100 node on demand.
- Another wanted metrics for training on a personal computer, even if it takes months.
- Opinion: finetuning is the realistic personal option
- A commenter said full training is different, but finetuning and inference of models like Qwen3 work on Apple Silicon Macs and gaming PCs.
- They suggested unsloth for NVIDIA and MLX for Apple.
How to Apply
- Walk the pipeline on CPU first
- Today, run uv sync --extra cpu and then runs/runcpu.sh without a GPU.
- Check only the flow from tokenization to chat, not output quality.
- Run a 5-minute d12 experiment loop
- If you have a GPU node, pretrain with --depth=12.
- After each code change, compare val_bpb and core_metric in wandb.
- Cut batch size first on GPUs under 80GB
- If you hit OOM, lower --device-batch-size from 32 to 16, 8, 4.
- 8XA100 or a single GPU also works, just slower.
- Estimate internal training cost with the speedrun formula
- Multiply the hourly GPU price by 8, then by training hours.
- The source's math is ~$3/GPU/hr × 8 × 2 hours = $48.
Try It
# Paste into a terminal (8XH100 node, repo already cloned)
uv sync --extra gpu
source .venv/bin/activate
bash runs/speedrun.sh
# After training finishes, chat
python -m scripts.chat_cliTerminology
Related Papers
Quadrillion-parameter transformers and how to train them
On fixed data, much bigger models with scaled weight decay and ensembling keep loss falling as compute grows.
Astra can read and write weights to improve Qwen
An LLM edited Qwen3.5-0.8B's weights directly, lifting MATH-500 from 7.9% to 48.1%.
Show HN: Qwen3-4B with the AI writing tics trained out
Distilling Qwen3-4B with LoRA cut its AI-writing slop score from 121 to 12.5 per 1000 words
Dust: Pretraining Transformers Without Backpropagation
Adding per-token noise to activations lets transformers pretrain without backpropagation, rivaling backprop.
Show HN: TurboGPT: train 22KiB transformer in 13s
A CUDA C++ project trains a tiny byte-level GPT in under a minute.
I had Gemini train its own replacement for $9
Fine-tuning GLiNER on $9 of Gemini labels reached 0.83 F1 locally.
Learning to solve hard problems in RL for LLMs by never giving up
Cutting compute on easy problems and retrying hard ones in RL raised accuracy on the hardest problems
Training a 3.8B LLM to 0.384 CORE for $998
A 3.8B LLM trained on 8 B200s in 43 hours for $998 scored 0.384 on CORE.
Related Resources
- https://github.com/karpathy/nanochat
- https://x.com/karpathy/status/1977755427569111362
- https://x.com/karpathy/status/1977758204139331904
- https://github.com/KellerJordan/modded-nanogpt
- https://kellerjordan.github.io/posts/muon/
- https://github.com/karpathy/nanoGPT
- https://github.com/karpathy/nanochat/pull/18
- https://github.com/workofart/ml-by-hand