<< All versions
Skill v1.0.0
currentAutomated scan100/100mkurman/zorai/nanogpt
──Details
PublishedJuly 29, 2026 at 12:07 PM
Content Hashsha256:677fbd452b1e9b26...
Git SHAd0acbfaf3d62
──Files
Files (1 file, 2.5 KB)
SKILL.md2.5 KBactive
SKILL.md · 52 lines · 2.5 KB
version: "1.0.0"
name: nanogpt description: "Minimal GPT pretraining and fine-tuning (nanoGPT). The simplest, fastest repository for training medium-sized GPTs with ~300-line model.py and ~300-line train.py. Reproduces GPT-2 (124M) on OpenWebText. Supports DDP multi-GPU/multi-node, character-level training, weight loading from HuggingFace GPT-2 checkpoints, and simple finetuning. Note: superseded by nanochat for new projects; this repo remains valuable as a reference implementation and learning tool." license: MIT license tags: [gpt-pretraining, autoregressive-language-modeling, ddp-training, checkpoint-finetuning, nanogpt] metadata: skill-author: K-Dense Inc. -----|--------|--------|-------|---------|-------------|
| Shakespeare char | ~10M | 6 | 6 | 384 | 1 GPU, 3 min | |
|---|---|---|---|---|---|---|
| GPT-2 small | 124M | 12 | 12 | 768 | 8×A100, 4 days | |
| GPT-2 medium | 350M | 24 | 16 | 1024 | Modify config | |
| GPT-2 large | 774M | 36 | 20 | 1280 | Modify config | |
| GPT-2 XL | 1.5B | 48 | 25 | 1600 | Multi-node |
10. Evaluation and Benchmarks
bash
# Benchmark training speedpython train.py config/train_gpt2.py --eval_only# Loss tracking# nanoGPT-reported GPT-2 (124M) on OpenWebText: val loss 2.85# OpenAI GPT-2 (124M) on WebText: val loss ~3.11# (domain gap between WebText and OpenWebText accounts for difference)# Custom benchmarkspython train.py config/train_shakespeare_char.py --eval_iters=200
Key Patterns
- Configs are Python files, not YAML — maximum flexibility, easy to diff
- `init_from='scratch'|'resume'|'gpt2*'` — switch between training modes
- Always use `--compile=True` on GPU for ~2x speedup
- Gradient accumulation with `gradient_accumulation_steps` emulates larger batch sizes
- Data is raw uint16 .bin files — tokenized once, loaded via memmap
- Meta device init for large models — doesn't allocate until needed
- Weight tying between
wte(embedding) andlm_head— standard GPT practice - Use `torchrun` for multi-GPU — not
python -m torch.distributed.launch