nanochat: a minimal harness to train and chat with a GPT-2-class model on one GPU node
nanochat is a small, hackable codebase that trains a ChatGPT-style language model end to end, from tokenization through pretraining, finetuning, evaluation and chat, on a single GPU node.
nanochat is Andrej Karpathy's codebase for training LLMs. The README calls it the simplest experimental harness for the job. It covers tokenization, pretraining, finetuning, evaluation and inference. Its one complexity dial is --depth, the number of transformer layers. According to the README, width, head count, learning rate and training length are then set automatically. A depth-26 model is said to reach GPT-2 capability. The README puts the cost at $48 for about two hours on an 8XH100 node, or closer to $15 on a spot instance.
The author writes that you install dependencies with uv, then run bash runs/speedrun.sh, which takes about 1.5 hours on an 8XH100 node. After that, python -m scripts.chat_cli lets you talk to the model. The README says the speedrun model is a bit like talking to a kindergartener. GPUs with less than 80GB need a smaller --device-batch-size. CPU and Apple Silicon can run a shrunken model through runs/runcpu.sh, though the README says that will not give strong results.
Karpathy wrote the README and says he has not personally exercised all the non-CUDA code paths, so there may be sharp edges. The repo is MIT licensed. Its AI policy asks contributors to disclose substantial LLM contributions to pull requests. A leaderboard tracks wall-clock time to GPT-2 grade capability.
In the author's words
nanochat is the simplest experimental harness for training LLMs.
From the README or the author's post. We checked that the sentence is there, not that it is true.
When to reach for it
Reach for it when you want to see a complete LLM pipeline run on one machine, or when you want to test a training code change with a short run. The README suggests a depth-12 run of about five minutes for that.
See it
AI wrote this entry from the project's own README or its author's post. What the project does, and that AI built it where the entry says so, are the author's statements, quoted here. Nobody at IKANGAI ran or tested it. How this list is made