Megatron-LM
NVIDIA's GPU-optimized library and reference scripts for training transformer models at scale with advanced parallelism.
At a Glance
Self-hosted Megatron-LM and Megatron Core library, free to install and use under the repository's permissive license (BSD-style LICENSE file; README badge shows Apache). Third-party files carry their own notices.
Engagement
Available On
Alternatives
Listed Oct 2026
About Megatron-LM
Megatron-LM is NVIDIA's repository for training transformer models at scale. It contains two components: Megatron-LM, a reference example with pre-configured training scripts, and Megatron Core, a composable library of GPU-optimized building blocks. The latest documented docs version is 0.19.0, and the repository lists a core_v0.19.2 release.
What It Is
Megatron Core provides transformer building blocks, parallelism strategies (tensor, pipeline, data, expert, and context parallelism), mixed precision support (FP16, BF16, FP8, FP4), and model architectures. The README positions it for framework developers and ML engineers building custom training pipelines, while the Megatron-LM reference scripts target research teams, learning distributed training, and quick experimentation.
Training Workflow
After installing from PyPI (megatron-core) or from source, the quickstart first runs a minimal distributed loop with mock data on two GPUs to validate the environment. It then runs a LLaMA-3 8B training script with FP8 mixed precision on eight GPUs. To train on custom data, users prepare a JSONL file with a text field and run tools/preprocess_data.py to tokenize it into .bin and .idx binary files.
Advanced Capabilities
The documentation covers Mixture of Experts, multi-token prediction, multi-latent attention, context parallelism, Megatron-FSDP, a distributed optimizer, optimizer CPU offload, activation offloading, distributed checkpointing, inference engines, quantization, and reinforcement learning. Supported models include language and multimodal models. Megatron Bridge, a separate project, converts checkpoints between Hugging Face and Megatron formats.
Performance Claims
The README states the codebase trains models from 2B to 462B parameters across thousands of GPUs, reaching up to 47% Model FLOP Utilization on H100 clusters, measured without training to convergence.
Community Discussions
Be the first to start a conversation about Megatron-LM
Share your experience with Megatron-LM, ask questions, or help others learn from your insights.
Pricing
Open Source
Self-hosted Megatron-LM and Megatron Core library, free to install and use under the repository's permissive license (BSD-style LICENSE file; README badge shows Apache). Third-party files carry their own notices.
- Install from PyPI: megatron-core
- Clone and install from source
- Megatron Core composable GPU-optimized building blocks
- Parallelism strategies: TP, PP, DP, EP, CP
- Mixed precision: FP16, BF16, FP8, FP4
Capabilities
Key Features
- Tensor, pipeline, data, expert, and context parallelism
- Mixed precision training (FP16, BF16, FP8, FP4)
- Mixture of Experts support
- Megatron-FSDP and distributed optimizer
- Distributed checkpointing
- Data preprocessing to binary .bin/.idx format
- Inference engines and TensorRT-LLM export
- Post-training (quantization, distillation, pruning) and RL
- Pre-configured training scripts such as LLaMA-3 8B
