Appendix A
论文与延伸阅读
A.1 Megatron 系列原始论文
| 论文 | 核心贡献 |
|---|---|
| Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism(2019) | 张量并行 TP 的基础论文,介绍列并行 / 行并行思想 |
| Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM(2021) | 3D 并行 + 1F1B + interleaved schedule 完整方法论 |
| Reducing Activation Recomputation in Large Transformer Models(2022) | 提出 sequence parallel + selective recompute |
| Megatron-LM v3 / Megatron-Core: Composable Library for Customizable LLM Training(2024) | Megatron-Core 设计哲学与 ModuleSpec 抽象 |
A.2 关键并行 / 显存技术
| 论文 | 主题 |
|---|---|
| ZeRO: Memory Optimizations Toward Training Trillion Parameter Models(2019) | DeepSpeed ZeRO,Megatron-DeepSpeed 集成的基础 |
| ZeRO-Offload: Democratizing Billion-Scale Model Training(2021) | CPU offload |
| ZeRO-Infinity: Breaking the GPU Memory Wall(2021) | NVMe offload |
| GPipe: Easy Scaling with Micro-Batch Pipeline Parallelism(2018) | pipeline 并行起源 |
| PipeDream: Pipelined Backpropagation(2018) | 另一种 pipeline 调度 |
| Ring Attention(2023) | context parallel 的核心算法 |
A.3 attention / kernel 优化
| 论文 | 主题 |
|---|---|
| FlashAttention(2022) | $O(S)$ 内存 attention |
| FlashAttention-2(2023) | 更优的并行策略 |
| FlashAttention-3(2024) | H100 + fp8 优化 |
| Performer(2020) | 线性 attention 的早期工作 |
| PagedAttention(2023) | vLLM 用的 attention 内存管理 |
A.4 模型结构相关
| 论文 | 主题 |
|---|---|
| RoFormer: Rotary Position Embedding(2021) | RoPE 位置编码 |
| GLU Variants Improve Transformer(2020) | SwiGLU |
| Root Mean Square Layer Normalization(2019) | RMSNorm |
| Grouped-Query Attention(2023) | GQA |
| LoRA(2021) | 低秩微调 |
A.5 MoE
| 论文 | 主题 |
|---|---|
| Outrageously Large Neural Networks: Sparsely-Gated MoE(2017) | MoE 起源 |
| Switch Transformer(2021) | 简化 MoE 路由 |
| GShard(2020) | 分布式 MoE 实现 |
| Mixtral of Experts(2024) | 开源 MoE 标杆 |
| DeepSeek-V3(2024) | 极致 MoE 训练工程 |
A.6 数值精度
| 论文 / 资源 | 主题 |
|---|---|
| FP8 Formats for Deep Learning(2022) | fp8 标准 |
| Mixed Precision Training(2017) | fp16 混合精度 |
| TransformerEngine 文档 | NVIDIA fp8 推理 / 训练库 |
A.7 训练大模型的工程经验
| 论文 / 资源 | 主题 |
|---|---|
| PaLM Technical Report(2022) | 540B 训练经验 |
| PaLM 2 Technical Report(2023) | data / scaling 经验 |
| Llama 2(2023) | 开源大模型工程标杆 |
| Llama 3(2024) | 15T token 训练经验 |
| DeepSeek-V3(2024) | FP8 全栈训练 + MoE 工程 |
| Llemma(2023) | 数学领域继续预训练经验 |
A.8 评测与对齐
| 论文 / 资源 | 主题 |
|---|---|
| MMLU(2020) | 多任务评测基准 |
| MATH(2021) | 数学评测 |
| GSM8K(2021) | 小学数学题 |
| DPO(2023) | 偏好对齐 |
| DeepSeekMath / GRPO(2024) | R1 风格训练基础 |
A.9 NVIDIA 官方资源
| 资源 | 说明 |
|---|---|
| github.com/NVIDIA/Megatron-LM | 主仓库 |
| Megatron-Core developer guide | 核心库文档 |
| NVIDIA-NeMo/Megatron-Bridge | HF ↔ Megatron 互转 |
| github.com/NVIDIA-NeMo/NeMo | NeMo 端到端框架 |
| github.com/NVIDIA/TransformerEngine | fused / fp8 算子库 |
| Megatron MoE ModelZoo | MoE 训练参考 |
A.10 中文社区资源
| 资源 | 类型 |
|---|---|
| 知乎"Megatron-LM 源码导读"系列 | 个人博客系列 |
| 知乎"大模型训练之并行综述" | 综述 |
| HuggingFace 中文社区 LLM 工程文章 | 工程实战 |
| 本目录其它 tutorial(DeepSpeed / verl / LLaMA-Factory) | 对比阅读 |
A.11 工具链补充
| 工具 | 用途 |
|---|---|
| Apex | fused optimizer / softmax |
| flash-attention | FlashAttention 主仓 |
| nccl-tests | NCCL 带宽 / 延迟测试 |
| microsoft/DeepSpeed | 对比阅读:ZeRO 实现 |
A.12 给自学者的"60 天阅读路线"
| 周 | 读什么 |
|---|---|
| 第 1 周 | 本书 ch01-04 + 跑通 minimal example |
| 第 2 周 | Megatron-LM 2019 论文 + 本书 ch07(TP)+ mappings.py 读源码 |
| 第 3 周 | Megatron-LM 2021 论文 + 本书 ch08(PP)+ schedules.py |
| 第 4 周 | Sequence-Parallel 论文 + 本书 ch09 + Ring Attention 论文 |
| 第 5 周 | FlashAttention 论文 + 本书 ch10 + TransformerEngine 文档 |
| 第 6 周 | 本书 ch05-06 + 实际预训一个 1B 小模型 |
| 第 7 周 | 本书 ch12 + Megatron-Bridge 实测一次 HF↔Megatron |
| 第 8 周 | 本书 ch13 + 提一个 PR / 给自家 fork 加一个小特性 |
闭环
到这里你已经完整读完了 Megatron-LM 中文 tutorial 全 13 章 + 附录。
Megatron 是 LLM 训练框架里学习曲线最陡的之一,
但读懂它就读懂了"千亿模型工业训练"的本质。
剩下的事情就是跑、改、贡献。