whatisgithub

What is megatron-lm?

nvidia/megatron-lm — explained in plain English

Analysis updated 2026-06-24

16,322PythonAudience · researcherComplexity · 5/5Setup · hard

In one sentence

NVIDIA's Python library for training very large AI language models, from 2 billion to hundreds of billions of parameters, across thousands of GPUs simultaneously, using advanced parallelism built for research and production scale.

Mindmap

mindmap
  root((Megatron-LM))
    What It Does
      Trains large LLMs
      Multi-GPU scaling
      Research and production
    Parallelism Types
      Tensor parallelism
      Pipeline parallelism
      Data parallelism
    Precision Support
      FP8 and BF16
      Mixed precision
    Components
      Megatron-LM scripts
      Megatron Core library
    Audience
      ML researchers
      LLM engineers
      GPU cluster teams
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Train a custom large language model with hundreds of billions of parameters across a multi-GPU cluster

USE CASE 2

Fine-tune an existing large model using Megatron Core's composable pipeline designed for framework developers

USE CASE 3

Benchmark GPU cluster efficiency for LLM training using tensor, pipeline, and data parallelism together

USE CASE 4

Test FP8 and BF16 mixed-precision training to speed up compute on H100 GPU hardware

What is it built with?

PythonPyTorchCUDA

How does it compare?

nvidia/megatron-lmqwenlm/qwen-agentmeta-llama/codellama
Stars16,32216,32116,327
LanguagePythonPythonPython
Setup difficultyhardmoderatehard
Complexity5/53/54/5
Audienceresearcherdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1day+

Requires a multi-GPU cluster with CUDA, benchmarks use H100 and A100 hardware, not suitable for single-GPU or CPU setups.

So what is it?

Megatron-LM is a GPU-optimized Python library from NVIDIA for training very large transformer models, the class of AI architectures that powers modern large language models. It is designed for research teams and ML engineers who need to train models ranging from 2 billion to hundreds of billions of parameters across thousands of GPUs simultaneously. The repository contains two main components. Megatron-LM is the higher-level reference implementation with pre-configured training scripts, useful for learning or experimentation. Megatron Core is the lower-level, composable library that framework developers can use to build custom training pipelines. The core technical challenge it solves is distributing model training across many GPUs efficiently, through multiple parallelism strategies: tensor parallelism (splitting individual operations across GPUs), pipeline parallelism (splitting model layers across GPUs), and data parallelism (running the same model on different data batches in parallel). It also supports mixed precision training, using lower-precision number formats like FP8 and BF16 to speed up computation. According to the benchmarks, it achieves up to 47% Model FLOP Utilization (a measure of hardware efficiency) on H100 GPU clusters, tested up to a 462-billion parameter model on 6,144 GPUs. You would use Megatron-LM if you are training or fine-tuning large language models at research or production scale and need tooling designed to work across large GPU clusters. The full README is longer than what was provided.

Copy-paste prompts

Prompt 1
How do I set up Megatron-LM to fine-tune a language model across 8 A100 GPUs using tensor parallelism?
Prompt 2
What is the difference between Megatron-LM and Megatron Core, and which should I use to build a custom training pipeline?
Prompt 3
Walk me through configuring tensor parallelism and pipeline parallelism in Megatron-LM for a 65B parameter model
Prompt 4
How do I enable FP8 mixed precision training in Megatron-LM on an H100 GPU cluster?
Prompt 5
What does Model FLOP Utilization mean in the Megatron-LM benchmarks and how do I measure it for my own training run?

Frequently asked questions

What is megatron-lm?

NVIDIA's Python library for training very large AI language models, from 2 billion to hundreds of billions of parameters, across thousands of GPUs simultaneously, using advanced parallelism built for research and production scale.

What language is megatron-lm written in?

Mainly Python. The stack also includes Python, PyTorch, CUDA.

How hard is megatron-lm to set up?

Setup difficulty is rated hard, with roughly 1day+ to a first successful run.

Who is megatron-lm for?

Mainly researcher.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.