Vibeleaderboard
Index / tool
Visit github.com
Category
AI Tools
Rank
Pricing
Open Source
Type
TOOL
Builder
karpathy
Date

About

Andrej Karpathy's full-stack ChatGPT-style training and inference recipe you can run end-to-end for $100 on a single 8xH100 node.

What it does

nanochat is a compact experimental harness for building language models through tokenization, pretraining, finetuning, evaluation, and inference. You choose transformer depth, while it calculates related model dimensions, learning settings, regularization, and training duration. Trained models can then answer prompts through an interactive command line.

Why it's ranked here

The project offers an unusually legible route through the complete model-building process while retaining serious performance work. Its depth-based configuration makes controlled scaling experiments approachable, and the reference training workflow provides a repeatable target. The strongest results still assume expensive data-center GPUs, so its simplicity does not remove the infrastructure requirement.

What's good

One complexity control coordinates width, attention heads, learning rates, weight decay, and training horizons. The code supports single-GPU execution through automatic gradient accumulation and distributed execution with sharded optimizer state. Evaluation covers multiple-choice knowledge, grade-school mathematics, conversational data, and a broad core metric. Explicit precision handling makes hardware behavior easier to inspect.

Tradeoffs

The reference workflow targets eight H100 GPUs, while one GPU takes roughly eight times longer. GPUs below 80GB may require batch-size tuning to avoid memory exhaustion. CPU and Apple Silicon examples intentionally train much smaller models with weak results. Less-tested PyTorch backends may have sharp edges, and reinforcement learning lacks gradient scaling for float16 training.

How to use it well

Use nanochat for learning, reproducible model-training experiments, scaling-law studies, and testing principled architecture or optimizer changes across several model sizes. Start with a smaller depth for fast iteration, track validation loss, capability metrics, memory use, and throughput, then scale promising changes. It does not replace access to large GPU capacity when strong results matter.

Technical notes+

pyproject.toml defines Python 3.10+, uv-managed CPU and CUDA extras, PyTorch 2.9.1, and pytest discovery under tests. nanochat/gpt.py implements rotary embeddings, QK normalization, grouped-query attention, sliding-window patterns, value embeddings, and Flash Attention 3 with an SDPA fallback. nanochat/fp8.py supplies tensorwise dynamic FP8 scaling around torch._scaled_mm through _Float8Matmul, plus recursive linear-layer conversion. nanochat/optim.py combines compiled AdamW and Muon updates, with distributed gradient synchronization and ZeRO-2-style optimizer-state sharding. nanochat/engine.py performs KV-cached sampling and supports a restricted calculator tool state machine. tasks/common.py downloads Parquet dataset exports with file locking, while tasks/gsm8k.py, tasks/arc.py, and tasks/mmlu.py define generative and categorical evaluation behavior.

Observed

Primary language
Python
Runtime requirement
Python 3.10 or newer
Packaging and installation
uv project with mutually exclusive CPU and GPU extras
Interfaces
Training scripts plus an interactive chat CLI
Platform support
CUDA, CPU, and Apple Silicon MPS paths are provided
Core framework
PyTorch 2.9.1

Read from README.md, pyproject.toml, tasks/arc.py, tasks/mmlu.py, tasks/gsm8k.py, nanochat/fp8.py, nanochat/gpt.py, tasks/common.py, nanochat/optim.py, tasks/smoltalk.py, nanochat/common.py, nanochat/engine.py.

What it can do

  • Train a ChatGPT-style language model

    Training data and configuration parametersTrained language model

  • Generate conversational responses

    Text prompts or questionsAI-generated text responses

  • Run inference on trained models

    Trained model and input promptsModel predictions and responses

  • Execute end-to-end training pipeline

    Raw dataset and training configurationProduction-ready language model

  • Deploy model on single GPU node

    Trained model and hardware configurationRunning inference server

Tags

llmtrainingfrom-scratchkarpathychatgpt

Tech Stack

Python

Comments (0)

No comments yet

Editorially curated, with community endorsements as a secondary signal. Corrections welcome.