📖 中文学习指南: README.zh-CN.md
LLMs in simple, pure C/CUDA with no need for 245MB of PyTorch or 107MB of cPython. Current focus is on pretraining, in particular reproducing the GPT-2 and GPT-3 miniseries, along with a parallel PyTorch reference implementation in train_gpt2.py.
# 下载初始包
chmod u+x ./dev/download_starter_pack.sh
./dev/download_starter_pack.sh
# CPU 版本(Mac/Linux)
make train_gpt2
OMP_NUM_THREADS=8 ./train_gpt2
# GPU 版本(需要 NVIDIA CUDA)
make train_gpt2cu
./train_gpt2cullm.c/
├── train_gpt2.c # ~1000行 CPU fp32 实现(学习用)
├── train_gpt2.cu # CUDA 主线训练代码
├── train_gpt2.py # PyTorch 参考实现
├── dev/
│ ├── cuda/ # 手写 CUDA 内核库
│ └── data/ # 数据处理脚本
├── doc/
│ └── layernorm/ # LayerNorm 教程
├── scripts/ # 多GPU/多节点脚本
└── README.zh-CN.md # 中文学习指南
| 文件 | 说明 | 适合人群 |
|---|---|---|
train_gpt2.c |
~1000行,单文件,CPU实现 | 初学者学习 |
train_gpt2.py |
PyTorch 参考实现 | 对照理解 |
train_gpt2.cu |
CUDA 主线代码 | GPU训练 |
dev/cuda/*.cu |
手写kernel | 深度优化 |
MIT