跳转至

开源基础设施全景:DeepSeek 之外的选择

更新日期:2026-04-17

C8 的上一篇介绍了 DeepSeek 的 6 个开源项目。本篇覆盖其他公司/社区的关键基础设施。


一、EP 通信库对比

1.1 为什么 EP 通信是独立赛道

MoE 的 All-to-All 通信和 Dense 模型的 AllReduce 完全不同:AllReduce 是"所有节点归约到同一个结果",All-to-All 是"每个节点把不同数据发给不同目标"。通用通信库(NCCL)对 All-to-All 的优化远不如 AllReduce。

1.2 主要方案

1.3 DeepEP vs UCCL-EP

UCCL-EP 的定位很明确:如果你在云上跑 MoE,用 UCCL-EP 代替 DeepEP——接口完全相同,只需改 import。参考 UCCL-EP (2025)

1.4 Hybrid EP(NVIDIA)

NVIDIA 提出的 Hybrid Expert Parallel:在 DeepSeek-V3 的 256 专家场景下,比 DeepEP 快约 14%。核心思想是把节点内和节点间的 EP 通信拆成两阶段分别优化。参考 NVIDIA Hybrid EP Blog

1.5 TorchTitan EP(Meta/PyTorch)

Meta 用 纯 PyTorch 原生 实现了 MoE 训练,在 1024 块 AMD MI300X 上验证。参考 TorchTitan MoE on AMD (2025)。 意义:DeepSeek/NVIDIA 的方案都深度依赖 CUDA + NVLink。TorchTitan 证明了 AMD GPU 也能高效训 MoE——对芯片多元化很重要。

1.6 Nous Research 的 DeepEP 实测

Nous Research 的 Field Notes (2025):在实际部署 DeepEP 时遇到的工程问题和调优经验。 关键发现:

  • EP 从 8 扩到 32 时,不用 DeepEP 的吞吐从 2000 TPS 暴跌到 750 TPS;用 DeepEP 保持在 ~2000 TPS

  • 通信占比从 60%+ 压到 ~18%


二、分布式训练框架对比

2.1 三大框架

2.2 每个框架的"为什么选它"

Megatron-LM:NVIDIA GPU 的极限压榨

为什么快?因为 Megatron 的 TP 和 PP 实现是手写 CUDA kernel 级别的优化——不是在 PyTorch op 上包一层,而是从通信到计算的整个 pipeline 都针对 NVLink 拓扑调优。代价是代码复杂、改动难。 适合:有 NVIDIA GPU 集群、追求最高 MFU、训百亿+ 模型。

DeepSpeed:内存是主要瓶颈时

为什么省内存?ZeRO-3 把模型权重 + 梯度 + 优化器状态全部分片到所有 GPU——每张卡只存 1/N。ZeRO-Offload 甚至把部分状态放到 CPU/NVMe。代价是通信量增大(需要 AllGather 权重)。 适合:GPU 内存紧张(如 A100 40GB 训 70B)、异构硬件、想快速实验不想改代码。

FSDP:不想学新框架时

为什么方便?FSDP 是 PyTorch 原生 API(torch.distributed.fsdp),不需要安装额外库。HuggingFace Trainer 直接支持。性能介于 Megatron 和 DeepSpeed 之间。 适合:中小团队、HuggingFace 生态、不需要极致性能。

2.3 能否组合使用?

可以。 Megatron-DeepSpeed 是官方组合——用 Megatron 的 TP/PP + DeepSpeed 的 ZeRO。微软的 Megatron-Turing NLG 530B 就是这样训的。

2.4 选型决策

flowchart LR
    start{"团队规模 / 模型规模"}
    small["< 32 GPU<br/>< 13B 模型"]
    mid["32-512 GPU<br/>13-70B 模型"]
    large["> 512 GPU<br/>> 70B / MoE"]

    small --> hf["HF Trainer + DeepSpeed ZeRO-3"]
    small --> torchrun["torchrun + FSDP"]
    mid --> fsdp["FSDP / DeepSpeed"]
    mid --> mega1["Megatron-LM"]
    large --> mega["Megatron-LM / NeMo"]
    large --> combo["Megatron-DeepSpeed 组合"]

    start --> small
    start --> mid
    start --> large

    classDef stage fill:#fff,stroke:#cc785c,color:#1a1a1a;
    class start,small,mid,large,hf,torchrun,fsdp,mega1,mega,combo stage
框架 优势 适合
HF Trainer + DeepSpeed 上手快、生态成熟 中小团队 / 微调 / 中型预训练
FSDP(PyTorch 原生) 无需额外库 中等规模 / 不极致追求速度
Megatron-LM TP/PP/CP 完整 大规模 dense + MoE
Megatron-DeepSpeed TP/PP + ZeRO 超大规模混合策略
NeMo Automodel PyTorch 模型 → 自动并行 不想锁死在 Megatron API

三、Megatron Core MoE 专项(2025 技术报告)

Scalable Training of MoE with Megatron Core (2025) 是 NVIDIA 最新的 MoE 训练技术报告。 关键贡献:


四、NeMo Automodel(NVIDIA 的"一键训练")

NeMo Automodel 让你用 PyTorch 原生代码写模型,自动获得 Megatron 的并行策略。不需要手写 Megatron 的 model parallel 包装。

# 传统 Megatron 方式: 需要用 Megatron 的 API 重写模型
model = megatron.model.GPTModel(...)  # 被 Megatron 锁定

# NeMo Automodel 方式: 标准 PyTorch 模型 → 自动并行化
import torch
model = MyCustomTransformer(...)  # 标准 PyTorch
from nemo.automodel import parallelize
parallel_model = parallelize(model, tp=8, pp=4, dp=64)


五、其他值得关注的项目

项目 开发者 用途 链接
vLLM UC Berkeley LLM 推理框架 GitHub
SGLang UC Berkeley 高性能推理+结构化生成 GitHub
llm.c Karpathy 纯 C 训练 GPT-2(教学用) GitHub
NanoGPT Karpathy 最简 PyTorch 训练 GitHub
Colossal-AI HPC-AI Tech 多种并行策略 GitHub
Alpa UC Berkeley 自动并行化 GitHub
TransformerEngine NVIDIA FP8 训练支持 GitHub

六、EP 库性能对比

数据来自 Nous Research Field NotesNVIDIA Blog


七、追问

问题 方向
Megatron 和 DeepSpeed 代码质量对比? Megatron 更工程化(NVIDIA 工程师维护),DeepSpeed 更学术(论文先行)
AMD 能达到 NVIDIA 的 MFU 吗? TorchTitan 在 MI300X 上的 MFU 接近 H100 水平
哪个框架最容易加新的并行维度? DeepSpeed 最灵活,Megatron 最难改
多云训练(AWS + Azure 混用)? UCCL 系列在做这个

参考文献

  • [1] NVIDIA Hybrid EP. 博客

  • [2] UCCL-EP. 2025. 论文 | 博客

  • [3] Scalable MoE Training with Megatron Core. 2025. 论文

  • [4] TorchTitan MoE on AMD. 2025. 博客

  • [5] Nous Research DeepEP Field Notes. 博客

  • [6] NeMo Automodel. 博客

  • [7] DeepSpeed Training. 文档

  • [8] Megatron-DeepSpeed. GitHub

  • [9] X-MoE. 2025. 论文


上级 · C8. 开源训练/推理基础设施