Megatron-LM
NVIDIA / Megatron-LM
NVIDIA 的大规模 Transformer 训练框架,支持张量/流水/序列/上下文并行、FP8、MoE 和分布式 checkpoint。NVIDIA’s large-scale Transformer training framework with tensor, pipeline, sequence and context parallelism, FP8, MoE and distributed checkpointing.
为什么选Why choose it
- 想理解千卡级训练怎么切模型和激活,Megatron 是事实标准,很多大模型训练栈基于它改。Designed for multi-node large-model training.
- 并行组合、通信重叠和 FP8 训练的实现细节,在论文之外看代码更清楚。Parallelism strategies are configurable rather than ad hoc.
- 适合做大规模预训练/继续训练的工程基线,而不是只读综述。FP8, MoE and distributed checkpoints are supported.
不适合Not for
单卡或小集群微调;配置和并行调优门槛高,小团队用 torchtune/DeepSpeed 更轻。You want to fine-tune a 7B model on one GPU.
没有多卡 NCCL 环境,或不愿读分布式 checkpoint 文档的团队。You do not have a multi-GPU cluster and a training team.
最小上手Minimum setup
- 按 README 安装 PyTorch、CUDA、NCCL 与依赖。Run a small single-node example first.
- 用官方小配置在 2–8 卡上跑通一次 pretrain 迭代。Record the parallelism layout, global batch size and throughput.
- 换张量/流水并行度,记录吞吐、显存与通信开销。Scale to two nodes and check checkpoint resume.
依赖与成本Dependencies and cost
CUDA;PyTorch;NCCL;多 GPU;大规模需要高速互联。Check runtime, model weights and external service dependencies in the README.
许可与使用边界License and usage boundaries
代码 BSD-3-Clause(NVIDIA 版权);模型与数据另计。Code is NOASSERTION; model weights, training data and generated content may have separate terms — check each before commercial use.
开源不等于可商用:GPL / AGPL 有传染性;代码许可、模型许可、生成内容许可要分开看。上线前读仓库 LICENSE 与模型卡,必要时让法务确认。Open source is not automatically commercial-use friendly: GPL / AGPL are copyleft; code, model and output licenses are separate. Read the LICENSE and model card before launch, and involve legal when needed.
替代与相邻Alternatives and neighbors
- DeepSpeed — 规模 / 性能Scale / performance,微软的大模型训练优化库:ZeRO、Offload、混合精度与 MoE 训练,把显存与吞吐压到可用。Microsoft's large-model training library: ZeRO, offload, mixed precision and MoE training to make VRAM and throughput usable.
- TorchTitan — 规模 / 性能Scale / performance,PyTorch 官方的大模型训练配方:张量并行、流水并行、FSDP 与分布式检查点,按 Llama 3 路线给参考实现。PyTorch's official large-model training recipe: tensor parallelism, pipeline parallelism, FSDP and distributed checkpoints, following the Llama 3 path.
- Unsloth — 先试这个Start here,QLoRA/LoRA 微调加速:用 Triton 内核把 7B–70B 模型的显存占用和训练时间压下来。Accelerated QLoRA/LoRA fine-tuning: Triton kernels cut VRAM use and training time for 7B–70B models.
下一步Next steps
- 打开 GitHub,先读 README、LICENSE、最近 release 与 issue。Open GitHub and read the README, LICENSE, latest release and issues first.
- 按“部署依赖 / 显存 / 数据 / 网络 / 权限”列一张上手清单。Make an onboarding checklist for deployment dependencies, VRAM, data, network and permissions.
- 用一个小样本跑通,再决定是否进生产;不要直接上生产数据。Run a small sample first, then decide on production; never start with production data.
GitHub 仓库 ↗GitHub repository ↗ 文档 ↗Docs ↗ 加入对比Add to compare