Skip to content

nanochat

Andrej Karpathy's minimal codebase for training a small ChatGPT-style model end to end on one GPU node.

Reviewed by Sheela · Updated

View on GitHub Open source

Our rating

4.3/5

A whole LLM training pipeline you can read in an afternoon and run for the price of a dinner, provided you can rent eight H100s.

What it is

nanochat is a small, readable codebase by Andrej Karpathy that covers the full pipeline of a chat model: tokeniser, pretraining, fine-tuning, reinforcement learning, evaluation and a chat interface.

According to the README, it trains a model that beats GPT-2's CORE benchmark score for about $48, roughly two hours on an 8xH100 node at about $3 per GPU-hour, or nearer $15 on spot instances. A community leaderboard tracks the fastest run, which stood at 1.65 hours in March 2026.

It is meant for learning and research, not for producing a useful assistant. It has no tagged releases, and the last commit on main was on 3 July 2026.

Our review

nanochat is the clearest end-to-end view of how a chat model is made, and nothing it produces is meant to be used. The repo has about 58,900 stars. It extends Karpathy's nanoGPT, which only covered pretraining, to tokeniser training, supervised fine-tuning, reinforcement learning, evaluation and a CLI chat. The README describes the result as being a bit like talking to a kindergartener.

The design choice that makes it teachable is a single dial. Set --depth and the code derives width, heads, learning rates and training horizon so the model comes out compute-optimal; GPT-2 capability sits around depth 24 to 26. There are no configuration objects or model factories, and the contributing guide says changes must work for every depth.

The economics are the headline. GPT-2 cost about $43,000 to train in 2019, the README says; the reference speedrun beats its CORE score for about $48 on a rented 8xH100 node. A single GPU produces near-identical results eight times slower, and cards with less than 80 GB of memory need a smaller --device-batch-size. A CPU and Apple silicon path exists but only trains a toy model in tens of minutes.

Activity has slowed. The last commit on main was on 3 July 2026 and there are no tagged releases, so treat it as a reference implementation rather than a maintained library. It does not fine-tune existing open models; that is TRL's or Unsloth's job, and the October 2025 launch post is now partly out of date, as the README itself warns.

Where it earns its place

  • An ML engineer moving from applied work into pretraining

    Understand every stage of an LLM by running it once

    Rent an 8xH100 node, run runs/speedrun.sh in a screen session and read each script while it trains. About $48 on demand, nearer $15 on spot, buys a model you trained from scratch and can chat with.

  • A university lecturer teaching a graduate NLP course

    Give students a from-scratch training lab without a cluster

    Students train depth-12 models in about five minutes of pretraining per run, or tiny CPU and Apple silicon models, and compare changes on validation bits per byte. The code is small enough to set as reading.

  • A research engineer testing an optimiser or data idea

    Check whether a change speeds up time-to-GPT-2

    Fork, change one thing, rerun a d12 or d16 and compare val_bpb and CORE in Weights & Biases. A positive result can be submitted to the leaderboard with its commit.

Before you commit

Setup
Clone, then `uv sync --extra gpu` (or `--extra cpu`) and `bash runs/speedrun.sh`; the reference run takes about 1.5 to 2 hours on 8xH100, then `python -m scripts.chat_cli` to talk to it.
Data and privacy
Runs locally; downloads pretraining and chat datasets from Hugging Face (NVIDIA ClimbMix, SmolTalk) and logs to Weights & Biases if you enable it. MIT code; datasets carry their own licences.
Cost at scale
No paid edition. About $24 an hour for an 8xH100 node at $3 per GPU-hour, so roughly $48 per GPT-2-grade run; the project aims at micro models trainable for under $1,000.
Limits
No releases; last commit 3 July 2026; less than 80 GB of VRAM needs batch-size tuning; XPU and MPS paths are untested by the author; RL does not support float16.

What's good

  • Tokeniser to chat UI in one readable codebase
  • Beats GPT-2's CORE score for about $48 of GPU time
  • One --depth setting derives the other hyperparameters
  • Public speedrun leaderboard with reproducible commits

What's not

  • Meaningful runs need a rented 8xH100 node
  • Output models are toys by design
  • No tagged releases; last commit July 2026
  • Cannot fine-tune existing open-weight models

Best for

Learners and researchers who want to understand LLM training end to end.

Alternatives

nanochat: common questions

Is nanochat worth it?
A whole LLM training pipeline you can read in an afternoon and run for the price of a dinner, provided you can rent eight H100s. We rate it 4.3 out of 5.
How much does nanochat cost?
Free and open source under the MIT license.
What are the downsides of nanochat?
Meaningful runs need a rented 8xH100 node; output models are toys by design; no tagged releases; last commit July 2026; cannot fine-tune existing open-weight models.
Who is nanochat best for?
Learners and researchers who want to understand LLM training end to end.
How much does nanochat cost for a team or in production?
No paid edition. About $24 an hour for an 8xH100 node at $3 per GPU-hour, so roughly $48 per GPT-2-grade run; the project aims at micro models trainable for under $1,000.
Is nanochat safe for company data?
Runs locally; downloads pretraining and chat datasets from Hugging Face (NVIDIA ClimbMix, SmolTalk) and logs to Weights & Biases if you enable it. MIT code; datasets carry their own licences.
What are the best nanochat alternatives?
The closest alternatives we have reviewed are LLMs from Scratch and TRL.

Answers checked Oct 23, 2026.

Make nanochat? Show this rating on your sitenanochat rated 4.3 out of 5 on ReviewRamble