Generalized Tensor Parallelism: Many Parallelisms, One Framework

Published:

Treating parameter re-materialization as a preprocessing step on one input of a GEMM improves compute-communication overlap, letting a 2T-parameter MoE train at 1,060 TFLOP/s per GPU on 12K GB300 GPUs.

Read the technical report · Code in Megatron-LM · User guide

Authors: Shiqing Fan, Deepak Narayanan, Jimmy Zhang, Jiangfei Duan, Prajwal Singhania, Haoran Zhang, Wanying Wang, Philip Monk, Xuwen Chen, Jared Casper, Jun Yang, Mohammad Shoeybi, Bryan Catanzaro, Vijay Anand Korthikanti

Overview

Modern LLMs are getting bigger, with up to trillions of parameters, and are pretrained on ever more tokens. Their parameters, optimizer state, and activations far exceed the memory of a single GPU, and training them in a reasonable time requires thousands of GPUs working efficiently together. Distributed pretraining thus has two key requirements: each GPU’s share of this state must fit in its memory, and GPUs should stay busy, with communication hidden behind computation.

Existing parallelization schemes each compromise on one of these requirements. Data parallelism (DP) replicates every parameter on every GPU; tensor parallelism (TP) communicates activations in every layer; pipeline parallelism (PP) leaves GPUs idle while the pipeline fills and drains; and fully sharded data parallelism (FSDP) all-gathers parameters for every microbatch (the subset of a training step’s sequences processed in one forward and backward pass), usually a whole Transformer block at a time.

Generalized tensor parallelism (GTP) starts from a simple observation. For a linear layer, DP, TP, FSDP, sequence parallelism, and context parallelism differ only in how they split and gather the layer’s two inputs. This unified view gives us two things:

  • More knobs. Parameters and activations can each be sharded to a different degree, trading communication against memory. Expert weights in mixture-of-experts (MoE) layers can also be sharded differently from dense weights. The GPUs that all-gather a weight and the GPUs that split a sequence can also be chosen independently, so parameter all-gathers can stay within a fast NVLink domain while a long sequence spans several domains.
  • Better overlap. A parameter all-gather becomes a preprocessing step on one input of a GEMM, so it can be scheduled per GEMM rather than per Transformer block, hiding communication behind computation without holding more weights in memory than needed.

GTP: One linear layer, two inputs

Each linear layer is a GEMM between two inputs: an activation matrix X, with one row per token, and a parameter matrix W. Distributing the layer comes down to deciding how to split and store each of them.

A GEMM whose activation rows are partitioned across c GPUs and whose parameter columns are partitioned across t GPUs. Below, each input can be stored as a finer shard and all-gathered before the GEMM.

Figure 1. In GTP, parameters are partitioned along a hidden dimension across t GPUs (as in TP) and activations along the token dimension across c GPUs (as in DP and context parallelism). Either input can additionally be stored as a smaller shard and all-gathered just before the GEMM: activations for sequence parallelism (SP), parameters for FSDP.

In this view:

  • TP partitions W; DP and context parallelism (CP) partition X, by whole sequences or by parts of each sequence.
  • SP re-materializes X with an all-gather before the GEMM; FSDP re-materializes W the same way.
  • Re-materializing W over a subset of GPUs, a weight group, gives hybrid sharding (HSDP), and composing it with TP gives the rest of the space.

When both inputs are fully sharded, per-GPU memory for parameters, optimizer state, and activations shrinks in proportion to the number of GPUs. Expert weights in MoE layers can also use a different sharding degree than dense weights.

Scheduling parameter all-gathers per GEMM

Re-materializing parameters is not free. Each microbatch all-gathers the parameters in the forward and backward passes and reduce-scatters their gradients, 1.5× the volume of DP’s once-per-step gradient synchronization. Unlike TP’s activation communication, though, a parameter all-gather does not depend on any preceding computation, so it can be issued early and hidden. The question is when.

Issued too late, an all-gather leaves its GEMM waiting. Issued too early, the gathered weights occupy memory long before they are used, increasing the memory footprint. Existing FSDP implementations answer this one module at a time, often a whole Transformer block: the block’s first GEMM waits for every parameter all-gather in the block. Inside a fused MoE layer, this means the first expert GEMM (GFC1) also waits for the second one’s weights (GFC2).

Two timelines of the backward pass. With unit-level readiness, the first consumer waits until all of the unit's weights arrive. With per-consumer readiness, each GEMM starts as soon as its own weight arrives.

Figure 2. (a) Unit-level scheduling: consumer Ca waits for the whole unit’s all-gathers. (b) GTP: each GEMM waits only for its own weight, and later weights are prefetched in the background.

In GTP, a parameter all-gather is instead a preprocessing step on one input of a GEMM (Figure 1), so we schedule all-gathers per GEMM rather than per block, using three policies:

  1. Separate prefetch chains. Dense weights prefetch the next weight; expert weights, whose all-gathers may cross NVLink domains, prefetch a full MoE block ahead.
  2. Per-consumer waits. Each GEMM waits only on its own all-gather, never on unrelated communication queued behind it.
  3. Coalesced expert all-gathers. All local expert weights feeding one grouped GEMM share a single collective, while GFC1 and GFC2 keep separate ones.

On a DeepSeek-V4-Pro proxy model, removing all three policies costs 19.8% of throughput.

Results

All results are on NVIDIA GB300 GPUs in 72-GPU NVLink domains.

1,060 TFLOP/s per GPU on 12,288 GPUs

With GTP, an internal 2T-parameter MoE model (Internal-2T) trains at 1,060 TFLOP/s per GPU on 12,288 GB300 GPUs, or 13.0 EFLOP/s (13.0 × 1018 floating-point operations per second) in total, with 8K sequences, Muon, and no pipeline parallelism. Weak-scaling efficiency from 4,096 to 12,288 GPUs is 98.2%.

Faster than Megatron-FSDP, and the gap grows with scale

Across three MoE models at 256–1,024 GPUs, GTP achieves 1.05–1.55× the throughput of Megatron-FSDP with 4–16% lower per-GPU memory. GTP’s weak-scaling efficiency from 256 to 1,024 GPUs is about 98% on every model, compared with 79.3% and 86.7% for Megatron-FSDP on the DeepSeek-V4-Pro and Internal-2T proxies. Profiles show why: Megatron-FSDP’s exposed all-gather time in the backward pass grows with scale and varies from step to step as GPUs wait for the slowest GPU in each group, while GTP’s stays nearly flat.

Throughput versus per-GPU memory for GTP and Megatron-FSDP on DeepSeek-V3, a DeepSeek-V4-Pro proxy, and an Internal-2T proxy at 256, 512, and 1,024 GPUs.

Figure 3. Weak scaling of GTP and Megatron-FSDP. Labels show GTP’s speedup at each GPU count.

Faster than tuned 3D parallelism

On the DeepSeek-V4-Pro proxy, GTP achieves 1.27–1.31× the throughput of a tuned 3D-parallel recipe (TP, PP with virtual pipelining, and DP) at 256–1,024 GPUs. GTP spends some of its memory savings on larger microbatches here: at the same microbatch size it uses 11–13% less memory than 3D parallelism, while at the sizes that maximize each method’s throughput it uses 29–48% more.

The interesting part is where the time goes. Per-GPU compute is similar for both methods, but the pipeline’s last stage computes 20% more than the stage mean, and a pipeline runs at the speed of its slowest stage. The other stages spend the difference waiting: 29% of the first stage’s step, compared with an ideal pipeline bubble of 4.5%. GTP has no stages to balance, so its training step is 20% shorter, even though its weight all-gathers and gradient reduce-scatters expose 8% and 5% of the step.

Throughput and memory of GTP and 3D parallelism, normalized step-time breakdowns per pipeline stage, and exposed communication by category.

Figure 4. (a) GTP versus 3D parallelism at 256–1,024 GPUs. (b) Step-time breakdown at 256 GPUs: stage 3 is the slowest, and the other stages wait for it. (c) Exposed communication: pipeline transfers and waiting take 29% of 3D parallelism’s step.

1M-token sequences

Weight groups and sequence partitions are chosen independently, so GTP can split one long sequence across many GPUs without TP. The full Internal-2T model trains with 1M-token sequences on 512 GPUs, using CP128 at 283 GB per GPU. From 8K to 1M tokens at a fixed 4M tokens per step, throughput falls from 1,258 to 883 TFLOP/s per GPU, mostly because softmax attention grows from 3% to 64% of GPU activity.

Balancing memory, communication, and compute

GTP’s generality comes with many configuration choices, and the best one depends on the model, the batch size, and the cluster. Each choice balances memory, communication, and compute efficiency differently.

Hiding parameter all-gathers. Sharding weights trades memory for communication: each GPU stores only a shard of each weight, but all-gathers the full weight for every microbatch. Hiding these all-gathers requires enough computation per microbatch, which for MoE layers means enough tokens per expert. The ways to get more computation cost memory, though: larger microbatches raise activation memory, and prefetching further ahead keeps more gathered weights in memory at once. Part of the memory that sharding saves can therefore be spent to hide its extra communication.

Choosing parallelism degrees and placement. Each parallelism degree trades memory against communication or compute efficiency. A higher TP degree reduces parameter memory and traffic, at the cost of more activation communication and smaller, less efficient GEMMs. A larger weight group shrinks each GPU’s share of the weights, at the cost of all-gathers over more GPUs and, beyond one NVLink domain, over slower links. A higher CP degree reduces activation memory, at the cost of fewer tokens per GPU to hide each all-gather and, at a fixed batch size, more microbatches that each repeat it.

Tradeoffs with pipeline parallelism. GTP and PP have different overheads. PP communicates little, but its GPUs sit idle while the pipeline fills and drains, and wait on the slowest stage when stages are imbalanced. Its first stage also holds activations for every in-flight microbatch. GTP has no stages to balance, and its activation memory shrinks with the number of GPUs. However, its weight all-gathers must be hidden, and gathered weights and their gradients take extra memory. GTP alone is therefore the better choice when activation memory dominates or when each microbatch has enough computation to hide its all-gathers. Adding PP helps when the stages can be balanced and the global batch is large enough to amortize pipeline fill and drain.

Conclusion

DP, TP, SP, CP, and FSDP are all choices about how to partition and re-materialize the two inputs of a GEMM. Treating parameter all-gathers this way lets GTP schedule communication per GEMM instead of per block. With GTP, we were able to train an internal 2T-parameter model at 1,060 TFLOP/s per GPU, or 13.0 EFLOP/s in total, on 12,288 GB300 GPUs.

GTP is open source in Megatron-LM, and our technical report has more details.