需 Python 3.12+ 与 PyTorch 2.6.0+,版本不匹配会出问题;源码编译内存占用大,OOM 时需设 MAX_JOBS 限制并行编译;与 Hugging Face 权重互转需另装 Megatron Bridge
Megatron-LM
NVIDIA活跃维护NVIDIA 的大规模 Transformer 训练框架,支持张量并行、流水线并行等模型并行策略,用来在成百上千张 GPU 上高效预训练大语言模型。
Ongoing research training transformer models at scale
uv pip install megatron-coreREADME 未说明具体显存要求;基准测试基于 DGX-GB300、DGX-GB200 等 NVIDIA GPU 系统,未提及 CPU 运行或非 NVIDIA 厂商支持
NVIDIA 的大规模 Transformer 训练库,提供 GPU 优化的并行训练组件与参考脚本
NVIDIA 的大规模 Transformer 训练框架,支持张量并行、流水线并行等模型并行策略,用来在成百上千张 GPU 上高效预训练大语言模型。
核心能力
- 提供 TP、PP、DP、EP、CP 多种并行策略
- 支持 FP16、BF16、FP8、FP4 混合精度训练
- 以可组合库形式提供 Transformer 构建块与模型架构
- 内置分布式 checkpoint 保存、加载与重分片
- 附带预配置训练脚本与现成训练示例
容易踩的坑
- core_v0.20.0NVIDIA Megatron Core 0.20.0最新正式版2026-10-29 · 2026-10-29 21:06 UTC
MoE
- DeepEP v2 dispatcher: adds an experimental DeepEP v2 backend for the flex token dispatcher (#5153).
- NCCL EP MXFP8 communication (experimental): adds MXFP8 dispatch-forward and combine-backward communication to the NCCL EP backend (#6524).
- NCCL EP eager mode: now NCCL EP supports both eager mode and full-iteration graph mode (#6229).
- ShortcutMoE: adds shortcut-connected routing in HybridStack and overlaps expert all-to-all communication with paired attention or Mamba computation; CUDA graphs are not supported (#6959).
Model Architecture and Support
- DeepSeek V4: fully supported by the next-gen
HybridModelclass (#6403, #6404, #6405, #7469). - Manifold-constrained hyper-connections (mHC): adds fused mHC connections to HybridModel, including pipeline and virtual-pipeline parallel support (#6401, #7336).
- Gated Delta Product (GDP): adds GDP layers and model-building support for hybrid architectures (#6074).
- Wide residual streams: adds streamwise residual connections, selective residual-stream recomputation, and integration with MTP and MIMO; currently requires PP=1 and CUDA graphs disabled (#6716, #6805, #6855, #7440).
- MTP-only training: adds a mode that freezes the base model and trains only Multi-Token Prediction heads (#7021).
Parallelism
- Megatron-FSDP v2 integration: adds the experimental Megatron Core adapter and Megatron Bridge, with context, expert, pipeline, and hybrid data-parallel sharding support; the adapter requires TP=1 and expert TP=1 (#5865, #6450, #6486, #7220, #6873).
- Megatron-FSDP v2 checkpointing: adds PyTorch distributed checkpoint save/load for model and optimizer state; optimizer checkpointing currently excludes expert-parallel layouts (#6024, #6215).
- Megatron-FSDP v2 supports hybrid FSDP.
- The user can specify different ZeRO levels for inter-nvlink domains and intra-nvlink domains.
- The user can specify different configs for the dense section and the MoE section.
- Generalized Tensor Parallelism (GTP): adds configurable batch/sequence partitioning, opt-in latent-projection sharding, and MTP support (#7748, #6383, #6242).
Performance and Memory
- Determinism: multi-release effort, please read our blog post to learn more
- Megatron-FSDP v2 CUDA graphs: adds full-iteration graph capture and replay for supported dense-model configurations ([#7075](https://github.com/NVIDIA/Me
- 26.09-lambda.rc12026-10-13 · 2026-10-13 11:34 UTC
这个版本没有写更新说明。
- 26.09-alpha.rc32026-10-13 · 2026-10-13 08:10 UTC
这个版本没有写更新说明。
- 26.09-alpha.rc22026-10-08 · 2026-10-08 17:51 UTC
这个版本没有写更新说明。
- 26.09-alpha.rc12026-10-06 · 2026-10-06 09:08 UTC
这个版本没有写更新说明。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Megatron-LM and Megatron Core
About
This repository contains two components: Megatron-LM and Megatron Core.
Megatron-LM is a reference example that includes Megatron Core plus pre-configured training scripts, ideal for research teams, learning distributed training, and quick experimentation.
Megatron Core is a composable library with GPU-optimized building blocks for custom training frameworks. It provides transformer building blocks, advanced parallelism strategies (TP, PP, DP, EP, and CP), mixed precision support (FP16, BF16, FP8, and FP4), and model architectures, ideal for framework developers and ML engineers building custom training pipelines.
Megatron Bridge provides bidirectional Hugging Face ↔ Megatron checkpoint conversion with production-ready recipes.
Getting Started
Compatibility: Python 3.12+ and PyTorch 2.6.0+ recommended. For source development, the tested NGC PyTorch base images are pinned in docker/.ngc_version.dev and docker/.ngc_version.lts.
Install from PyPI:
uv pip install megatron-core
Or clone and install from source:
git clone https://github.com/NVIDIA/Megatron-LM.git
cd Megatron-LM
uv pip install -e .
Note: Building from source can use a lot of memory. If the build runs out of memory, limit parallel compilation jobs by setting
MAX_JOBS(for example,MAX_JOBS=4 uv pip install -e .).
For NVIDIA GPU Cloud (NGC) container setup and all installation options, review the Installation Guide.
- Your First Training Run - End-to-end training examples with data preparation
- Parallelism Strategies - Scale training across GPUs with TP, PP, DP, EP, and CP
- Contribution Guide - How to contribute to Megatron Core
- Style Guide - Python style overrides
Latest News
- [2026/10] Scale Bitwise-Deterministic Pretraining with NVIDIA Megatron Core - A guide to reproducing training runs, validating checkpoint resume, and reducing determinism overhead at scale with Megatron Core.
- [2026/08] Megatron Core 0.19 - Introduces HybridModel, quantile-based MoE router balancing, packed-sequence MoE dispatch, and CUDA Graph-compatible activation offloading.
- [2026/07] DeepSeek-V3 pretraining on GB300 NVL72 - Megatron Core achieves 1,648 TFLOPs/s per GPU for DeepSeek-V3 671B on 256 GPUs.
- [2026/05] DeepSeek-V4 initial support - Megatron Core's
devbranch includes the initial DeepSeek-V4 implementation; Megatron Bridge provides conversion, inference, and pretraining recipes. - [2026/04] Advancing Emerging Optimizers for Accelerated LLM Training with NVIDIA Megatron - Muon and other emerging optimizers are now supported in Megatron Core via the new Emerging-Optimizers library.
Project Structure
Megatron-LM/
├── megatron/
│ ├── core/ # Megatron Core (kernels, parallelism, building blocks)
│ │ ├── models/ # Transformer, hybrid, and multimodal models
│ │ ├── transformer/ # Transformer building blocks
│ │ ├── tensor_parallel/ # Tensor parallelism
│ │ ├── pipeline_parallel/ # Pipeline parallelism
│ │ ├── context_parallel/ # Context parallelism
│ │ ├── distributed/ # Distributed training (Megatron FSDP, DDP)
│ │ ├── dist_checkpointing/ # Distributed checkpoint saving, loading, and resharding
│ │ ├── optimizer/ # Optimizers
│ │ ├── datasets/ # Dataset loaders
│ │ ├── inference/ # Inference engines and server
│ │ └── export/ # Model export (example: TensorRT-LLM)
│ ├── training/ # Training scripts
│ └── post_training/ # Post-training (quantization, distillation, pruning, etc.)
└── examples/ # Ready-to-use training examples
Performance Benchmarking
The NVIDIA Megatron Bridge Performance Summary publishes training throughput, system configurations, parallelism settings, and links to performance recipes and reproduction instructions. Use the container and matching code version specified by those instructions when reproducing a result.
Selected results from the 26.08.01 NeMo container (August 2026):
| Model | System | GPUs | Precision | Sequence length | Tokens/s/GPU | Model TFLOPs/s/GPU |
|---|---|---|---|---|---|---|
| DeepSeek-V3 | DGX-GB300 | 256 | MXFP8 | 4,096 | 6,288 | 1,636 |
| DeepSeek-V3 | DGX-GB200 | 256 | MXFP8 | 4,096 | 4,912 | 1,277 |
| Qwen3-235B-A22B | DGX-GB300 | 256 | MXFP8 | 4,096 | 8,832 | 1,306 |
| Nemotron 3 Ultra | DGX-GB300 | 256 | NVFP4 | 8,192 | 3,744 | 1,348 |
See the summary for the full batch sizes and parallelism configurations. MoE benchmarks use force-balanced expert routing and do not drop tokens. These results measure performance under the published benchmark conditions; throughput depends on the model, precision, hardware, and configuration.
Roadmaps
- 2026 Q3 Megatron Core Roadmap
- 2026 Q3 MoE Roadmap [
devbranch first developments] - 2026 Q3 Megatron FSDP v2 Roadmap [experimental]
Resources
Getting Help
- 📖 Documentation - Official guides and API reference
- 🐛 Issues - Bug reports and feature requests
Contributing
Contributions are welcome. Ways to contribute:
- 🐛 Report bugs - Help improve reliability
- 💡 Suggest features - Shape the future of Megatron Core
- 📝 Improve docs - Make Megatron Core more accessible
- 🔧 Submit PRs - Contribute code improvements
Citation
If you use Megatron in your research or project, use the following citation:
@article{megatron-lm,
title={Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism},
author={Shoeybi, Mohammad and Patwary, Mostofa and Puri, Raul and LeGresley, Patrick and Casper, Jared and Catanzaro, Bryan},
journal={arXiv preprint arXiv:1909.08053},
year={2019}
}