Megatron-LM

Active
GitHub Python NOASSERTION

Description

NVIDIA's open-source GPU-optimized library for training transformer models at scale, providing tensor parallelism, pipeline parallelism, sequence parallelism, and mixed-precision (FP8/FP4) support — the core foundation for trillion-parameter LLM training.

Key Features

  • Tensor parallelism (TP) — Shard individual transformer layers across GPUs to reduce per-card memory
  • Pipeline parallelism (PP) — Distribute model layers across GPUs for ultra-large models
  • Context parallelism (CP) — Handle ultra-long sequences efficiently with million-token training
  • Mixed-precision training — Full-stack FP16, BF16, FP8, and FP4 low-precision support
  • Mixture of Experts (MoE) — Native support for DeepSeek-V3, Mixtral and other MoE architectures
  • Megatron Bridge — Bidirectional HuggingFace checkpoint format conversion

Use Cases

💡 Large language model pretraining: Train trillion-parameter models across thousands of GPUs
💡 MoE model training: Efficiently train DeepSeek-V3, Mixtral and other mixture-of-experts models
💡 Ultra-long context training: Million-token level long-sequence pretraining
💡 Custom training frameworks: Build tailored training systems from Megatron Core modular components

Strengths & Limitations

Strengths

  • Actively maintained, recent updates
  • High community interest (17.7k stars)

⚠️ Limitations

  • High issue backlog (1.3k open issues)
  • No clear open-source license

Quick Start

# Install Megatron Core
uv pip install megatron-core

# Or install from source
git clone https://github.com/NVIDIA/Megatron-LM.git
cd Megatron-LM && uv pip install -e .

# Run quickstart training script
cd examples
python pretrain_gpt.py ...

# See docs
# https://docs.nvidia.com/megatron-core/developer-guide/latest/get-started/quickstart.html

Related Projects

DeepSpeed

43.1k · Python
Active A

Microsoft's open-source deep learning distributed training optimization library, featuring ZeRO memory optimization, 3D parallelism, and mixed-precision training for efficient training of trillion-parameter models.

distributed-trainingoptimizerdeepspeed +3
  • · ZeRO optimizer — Partitions optimizer states, gradients, and parameters across GPUs for massive memory savings
  • · 3D parallelism — Combines tensor, pipeline, and data parallelism simultaneously
  • · Ultra-long sequence training — Ulysses Sequence Parallelism for training on extremely long context sequences

InternLM

7.3k · Python
Stale B

Open-source LLM family by Shanghai AI Lab, spanning 1.8B to 20B parameter models with long-context reasoning, deep thinking mode, and efficient fine-tuning for chat, reasoning, and code generation.

llmpretrained-modelinference +3
  • · Multiple parameter sizes — 1.8B, 7B, 20B variants to match different hardware budgets
  • · Deep thinking mode — Long chain-of-thought reasoning for complex math and logic tasks
  • · Long context window — Up to 1M token input, ideal for long-document processing

Llama 2

59.6k · Python
Stale C

Meta's open-source Llama 2 foundational LLM with pretrained and fine-tuned models from 7B to 70B parameters, supporting chat and text completion as a cornerstone of the open LLM ecosystem.

llmllamameta +3
  • · Multiple parameter sizes — 7B, 13B, 34B, and 70B parameter variants
  • · Base and chat models — Both pretrained base and instruction-fine-tuned Chat versions available
  • · Commercial-friendly license — Free for both research and commercial use

Agently

1.6k · Python
Active A

A GenAI application development framework that simplifies agent interaction with structured data and chained-calls syntax, using event-driven flow for complex logic.

agentpythonframework +1
  • · Structured output control with framework-guaranteed schemas, required field extraction, and retry validation
  • · Runtime Skills system for discovering, installing, and executing MCP/script capabilities on demand
  • · TriggerFlow event-driven workflows with fan-out, pause/resume, save/load, and sub-flow support