Chapter 04

NeMo Megatron 与 Megatron-Core 的关系

📌 commit 2ea3e0f三层栈说清楚

NeMo 系列里最容易让人迷糊的是"NeMo / NeMo Megatron / Megatron-LM / Megatron-Core"这一串名字。本章按时间线和分层架构把关系讲清楚。

4.1三层栈

flowchart TB App[NeMo collections.llm
用户写的 recipe] Mid[NeMo lightning
PT-Lightning + 模型抽象] Core[Megatron-Core
TP/PP/DP 通信原语 + Optimizer] TE[TransformerEngine
FP8 / Flash kernel] PT[PyTorch + CUDA] App --> Mid --> Core --> TE --> PT

4.2各层职责

仓库角色
NeMoNVIDIA-NeMo/NeMo顶层框架:recipe、CLI、aligner、ASR/TTS 等多模态
Megatron-Core (MCore)NVIDIA/Megatron-LM分布式底座:ParallelLinear / DistributedDataParallel / DistOptim / PP schedule
TransformerEngineNVIDIA/TransformerEnginekernel 库:FP8 GEMM / fused attention / RMSNorm

4.3"NeMo Megatron" 这个名字

历史名词:早期 NeMo 内部叫 "NeMo Megatron Collection",指的是 NeMo 里用 Megatron 风格做 LLM 训练的子模块(nemo.collections.nlp.models.language_modeling.megatron_gpt_model 这类)。2024+ NeMo 2.x 后改名 nemo.collections.llm,更直白。

所以你可能在不同文档里看到这几个名字:

4.4NeMo 给 Megatron-Core 增加了什么

4.5选用建议

需求用什么
极致性能 + 不要 PT-LightningMegatron-LM 原版
同等性能 + PT-Lightning + 高层 APINeMo
只关心 Megatron-Core 的并行原语直接 import megatron-core
多模态 (ASR / TTS / Vision)NeMo(独家)
RLHF 流程NeMo Aligner(独家)
转换 HF checkpointNeMo(独家)

4.6性能对照

Llama-3 70B、64×H100、bf16、seqlen=8K:

MFUtokens/s/GPU
Megatron-LM 原版~55%~3.6k
NeMo 2.x(底层走 MCore)~54%~3.5k
NeMo + TE FP8~63%~4.2k

结论:NeMo 几乎没有性能损失,开了 FP8 还能更快。

4.7这章你需要带走的