Generalized Tensor Parallelism(GTP)是什么?
它和 TP、ZeRO-3 差在哪,all-gather 怎么藏?
先弄清楚:每个概念是什么
- GTP_remat
- 把 TP 切完的那片 weight 再切一次,每卡平时只存一小片。GEMM 之前用 all-gather 拼回完整的 TP slice,算完就释放。remat 来自 rematerialize。
- Prefetch chain
- weight 按 forward 的顺序连成一条链。算当前层时,提前把下一层的 all-gather 发出去。
- Deferred finalize
- weight gradient 的 reduce-scatter 的结果推迟一步才并进
main_grad。这里的一步是 backward 往前走一层,不是一个 training step。
看图:all-gather 和上一层的 GEMM 同时跑
30 秒回答
GTP equals TP times GTP_remat. TP keeps each weight split through the GEMM. GTP_remat splits the TP slice again: each rank keeps one shard, rebuilds the full slice with an async all-gather right before the GEMM, and frees it afterwards. The doc calls it an implementation of ZeRO-3 that shards along a model-parallel axis, not the data-parallel one, and materializes one weight at a time, not a bucket. Each layer's all-gather is prefetched during the previous layer's GEMM, so all but the first are hidden. Weight gradients return through an async reduce-scatter whose finalize is deferred one step. It's still experimental.
TP、GTP_remat、DP 轴上的 ZeRO-3 差在哪
| TP | GTP_remat | DP 轴上的 ZeRO-3 | |
|---|---|---|---|
| 沿哪个轴切 | model-parallel | model-parallel | data-parallel |
| 每卡平时存 | weight 的 1/TP | TP slice 的 1/GTP_remat | weight 的 1/N |
| GEMM 时 | "stays sharded through the GEMM" | 先 all-gather,"the GEMM sees the full TP slice",算完释放 | all-gather 出完整 weight,算完释放 |
| 通信传什么 | activation(见 TP communication) | weight 的 all-gather;weight gradient 的 reduce-scatter | 同左 |
| 粒度 | 不涉及 | 一次一个 weight | 一个 bucket |
文档说 "GTP_remat is an implementation of ZeRO-3"(ZeRO-3 见 DP、ZeRO、FSDP),区别是表里“沿哪个轴切”和“粒度”两行,所以每个 weight 可以单独 prefetch。“TP 切计算、传 activation,GTP_remat 只切存储、传 weight”是按这张表推断的。TP 本身怎么切见 TP Linear。
手算一遍。h = 8192 的方阵 weight 用 bf16 存是 128 MiB。TP = 4 后每卡 32 MiB。再开 GTP_remat = 8,每卡平时只存 4 MiB,GEMM 前 all-gather 回 32 MiB。合起来是 1/32,对应文档的 "32× weight-memory reduction"。同一句里的 "128× wire-bandwidth reduction" 文档没有给推导,面试里只引 32×。
all-gather 和 weight gradient 怎么藏在计算后面
- Forward:文档 1.1 节写 "Layer i's AG overlaps with layer i−1's GEMM.",3.1 节写成 \(\text{AG}(W_{i+1}) \parallel \text{GEMM}(W_i)\)。两处下标错开一位,说的是同一件事
- 链头:第一层前面没有 GEMM,所以 "For an L-layer model, L−1 all-gathers are fully hidden behind compute."
- Cold start:"every weight's very first AG is synchronous",prefetch chain 从第二次 forward 才开始
- Backward:反着走,第 i − 1 层的 all-gather 和第 i 层的 dgrad 重叠
- Weight gradient:reduce-scatter 异步发出,"Finalization is deferred one step",所以第 i 层的 reduce-scatter 能和第 i − 1 层的 backward GEMM 重叠。链头用同步的 reduce-scatter,"since nothing follows it"
Overlap 的一般做法和 exposed communication 怎么算见 overlap。
必答点
- GTP = TP × GTP_remat,每卡存每个 linear weight 的 1/(TP × GTP_remat)
- GTP_remat 是 ZeRO-3 的做法:切开存,用前 all-gather,用完释放,gradient 走 reduce-scatter
- 和 DP 轴上的 ZeRO-3 有两点区别:切在 model-parallel 轴,一次一个 weight
- 第 i 层的 all-gather 和第 i − 1 层的 GEMM 重叠,L 层藏住 L − 1 次
- Weight gradient 用 async reduce-scatter,finalize 推迟一步
- 状态是 experimental,要求 TransformerEngine ≥ 2.19
追问
GTP_remat 里的各个 rank 算的是同一份数据吗?
不是。文档写默认 "all GTP_remat ranks distribute independent samples",开了 sequence sharding 后各 rank 算同一个 microbatch 的不同 sequence 分段。
为什么不直接把 FSDP 的 bucket 缩到一个 weight?
文档的说法是 "FSDP's overlap is bucket-grained by design",bucket 是为了 "avoid paying NCCL launch latency on tiny params"。GTP_remat 不切小 tensor,文档写 LayerNorm、bias、MoE router 这些 "always stay full"。
all-gather 出了 NVLink domain 还藏得住吗?
文档写 "One GEMM of runway covers a gather that stays inside the NVLink domain, but not one that leaves it"。MoE 的 routed-expert weight 属于后一种,文档给它们单独的 one-block-ahead chain。
怎么打开,有什么限制,规模到多大?
--tensor-parallel-num-weight-shards 决定 GTP_remat 的大小,等于 1 时 GTP 不生效。文档写它 "composes orthogonally with TP / SP / EP / DDP / CUDA Graphs",目前要求 num_distributed_optimizer_instances == 1。文档的例子是约 280B 的 hybrid Mamba-MoE proxy 在 GB200 NVL72 上用 GTP64,到 3072 GPU 时 scaling efficiency 仍 "≥93 %"。
来源GTP 文档(开头的 overview 和对照表;1.1 节 prefetch chain、cold start、deferred RS finalize;1.3 节 low precision 的表;1.7 节 scaling;3.1 节 overlap design summary)· core 0.20.0 release notes(GTP 加了 "configurable batch/sequence partitioning, opt-in latent-projection sharding, and MTP support")· 题库条目在 ml-八股 06 的“零、团队最近在做什么”