Scaling modern large language models beyond tens of billions of parameters quickly exhausts the physical memory and compute throughput of individual graphics processing units. A 70-billion-parameter model stored in 16-bit floating-point (FP16 or BF16) requires 140 GB of VRAM solely for model weights. During full-precision training with the Adam optimizer, parameter states, gradients, and optimizer momentum terms demand approximately 16 to 18 bytes per parameter (amounting to 1.12 TB to 1.26 TB for a 70B checkpoint), completely detached from the dynamic memory required to store forward-pass activation tensors.
When model weights cannot fit onto a single accelerator, practitioners rely on multi-dimensional distributed parallelism. Tensor Parallelism (TP) shards individual weight matrices within each transformer layer across multiple GPUs connected via high-bandwidth interconnects. Pipeline Parallelism (PP) partitions layers sequentially across devices along the network depth.
Understanding the mathematical decomposition of matrix multiplications, the communication algebra of conjugate operators, Sequence Parallelism extensions, and the scheduling dynamics of 1F1B pipeline execution is essential for designing distributed training and inference architectures.

The Memory Footprint of Distributed Transformer Training
To understand why multi-dimensional parallelism is necessary, consider the exact memory breakdown of training a transformer parameterized by weights with hidden dimension , sequence length , batch size , and layer count .
Static Memory: Weights, Gradients, and Optimizer States
In mixed-precision training using standard 32-bit Adam optimization:
- Model Weights (FP16/BF16): 2 bytes per parameter ().
- Gradients (FP16/BF16): 2 bytes per parameter ().
- Master Weights (FP32): 4 bytes per parameter ().
- First Momentum Vector (FP32): 4 bytes per parameter ().
- Second Momentum Vector (FP32): 4 bytes per parameter ().
The baseline static memory footprint per parameter is:
For a model with parameters, . On standard 80 GB NVIDIA H100 GPUs, static states alone require a minimum of 14 GPUs without accounting for intermediate activations, workspace buffers, or memory fragmentation.
Dynamic Memory: Activation Scaling
Activation memory stores the intermediate tensors produced during the forward pass that are retained for gradient computation during backpropagation. For a standard transformer layer with multi-head attention and a 4-multiple feed-forward network (FFN), the activation memory per layer scales linearly with sequence length , batch size , and hidden dimension :
where is the number of attention heads. As sequence lengths expand to 32,768 or 128,000 tokens, activation memory exceeds static weight memory by multiples.
Megatron-LM 1D Tensor Parallelism
Introduced by Shoeybi et al. (2019) at NVIDIA, 1D Tensor Parallelism splits the linear projection matrices of Multi-Head Self-Attention (MHA) and Multi-Layer Perceptron (MLP) blocks across parallel processing units while minimizing inter-device synchronization.
Column-Parallel Linear Layer
Consider a linear transformation , where represents input activations and is the weight matrix. In column-parallel linear layers, the weight matrix is sliced along its column dimension across GPUs:
Each GPU holds the full input tensor and independently computes its local partition of the output:
Because the transformation produces partitioned columns without requiring cross-partition reduction, an element-wise non-linear activation function (such as GeLU or SwiGLU) can be applied directly to each shard locally:
Column parallelism eliminates communication prior to or across the activation function.
Row-Parallel Linear Layer
In a row-parallel linear layer, the subsequent weight matrix is sliced along its row dimension across GPUs:
Each GPU computes the matrix product of its local input partition and its local weight slice :
The complete mathematical output requires summing across all local outputs:
This summation is performed by an (sum) collective communication operation across the tensor parallel ranks.
Column-Parallel: X ──┬──> [ A_1 ] ──> Y_1 ──> GeLU ──> [ B_1 ] ──┬──> [ All-Reduce Sum ] ──> Z
├──> [ A_2 ] ──> Y_2 ──> GeLU ──> [ B_2 ] ──┤
└──> [ A_t ] ──> Y_t ──> GeLU ──> [ B_t ] ──┘
(Column Slicing) (Row Slicing)Self-Attention Layer Decomposition
In multi-head attention, the query (), key (), and value () projection matrices are partitioned using column parallelism. The attention heads are divided uniformly across GPUs ( heads per rank):
- Projection Phase: Each GPU computes , , and .
- Attention Computation: Local heads evaluate attention maps independently:
- Output Projection: The output projection matrix is partitioned using row parallelism. Each GPU multiplies its concatenated local attention head outputs with .
- Synchronization: A single collective sums the outputs across all ranks before the residual connection.
Conjugate Communication Operators
Megatron-LM defines two conjugate communication primitives, and , to manage forward and backward execution:
- In Column-Parallel Layers: The forward operator is an identity mapping (no-op), while the backward operator computes an (sum) of the incoming gradients .
- In Row-Parallel Layers: The forward operator executes an (sum) across output shards, while the backward operator is an identity mapping.
Each transformer layer contains exactly one Attention block and one MLP block, requiring:
- Forward Pass: 2 operations.
- Backward Pass: 2 operations.
Using a ring-based algorithm, the communication volume per rank for a message of size elements is . For an activation tensor of shape , the total bytes transmitted per layer per step equals:
Because of the high frequency of communication (two synchronizations per transformer layer), Tensor Parallelism is strictly restricted to intra-node NVLink domains (), where unidirectional bandwidth exceeds 450 to 900 GB/s per GPU.
Sequence Parallelism
While 1D Tensor Parallelism shards the GEMM weights and self-attention operations across GPUs, standard TP replicates LayerNorm, Dropout, and residual connection activations across all ranks. In modern transformer architectures, these replicated activations account for up to 10 bytes per layer.

Korthikanti et al. (2022) introduced Sequence Parallelism (SP) in Megatron-LM to shard activations along the sequence length dimension during non-tensor-parallel operations.
Splitting All-Reduce into Reduce-Scatter and All-Gather
Operations such as LayerNorm and Dropout operate independently along the hidden dimension for each token in the sequence. By partitioning the sequence length into chunks of size , each GPU processes only tokens during LayerNorm and Dropout.
Sequence Parallelism replaces the standard communication operators with and pairs:
- Row-Parallel Exit: The row-parallel GEMM produces local partial sums of size . Instead of performing an to create a replicated full tensor, the runtime executes a operation. This simultaneously sums the partial products and shards the result along the sequence dimension, leaving each GPU with an tensor.
- Normalized Execution: LayerNorm, residual additions, and Dropout execute locally on tensors.
- Column-Parallel Entry: Before entering the next column-parallel GEMM (which expects the full sequence to multiply against column-sharded weights), the runtime executes an operation, reconstructing the activation tensor.
Mathematically, because , the total communication volume of Sequence Parallelism is strictly identical to standard Tensor Parallelism:
Sequence Parallelism reduces the activation memory footprint from:
to:
Every single activation tensor in the transformer block is sharded by without adding network communication overhead.
Pipeline Parallelism and 1F1B Scheduling
When a model's depth exceeds what can be accommodated within a single node (even with ), Pipeline Parallelism (PP) partitions the layers of the network across sequential pipeline stages located on different machines.
The Pipeline Bubble in GPipe
In naive pipeline parallelism (GPipe, Huang et al., 2019), a global batch is split into microbatches (). The execution flows linearly through stages :
Stage 4: [F1][F2][F3][F4] [B4][B3][B2][B1]
Stage 3: [F1][F2][F3][F4] [B4][B3][B2][B1]
Stage 2: [F1][F2][F3][F4] [B4][B3][B2][B1]
Stage 1: [F1][F2][F3][F4] [B4][B3][B2][B1]
Time ───> | Warmup | Steady State | Cooldown |During startup (warmup) and drain (cooldown), downstream and upstream devices remain idle. The fraction of execution time lost to idle hardware (the pipeline bubble fraction ) is given by:
When , the bubble fraction approaches . However, in GPipe, all forward microbatches must be completed before backward passes begin, forcing stage 1 to store activations for all microbatches simultaneously:
For large , activation memory overwhelms physical device capacity.
1F1B (One Forward, One Backward) Schedule
To bound activation memory while maintaining pipeline throughput, Megatron-LM implements the 1F1B (One Forward, One Backward) scheduling paradigm (Narayanan et al., 2021).
In 1F1B, after a stage completes a warm-up phase of forward passes equal to its remaining downstream depth ( microbatches for stage ), it enters a steady-state regime where it executes exactly one forward pass followed immediately by one backward pass for the oldest completed microbatch:
Stage 4: [F1][B1][F2][B2][F3][B3][F4][B4]
Stage 3: [F1][F2][B1][F3][B2][F4][B3][B4]
Stage 2: [F1][F2][F3][B1][F4][B2][B3][B4]
Stage 1: [F1][F2][F3][F4][B1][B2][B3][B4]Under 1F1B:
- Outstanding forward activations are retired as rapidly as they are generated.
- The maximum number of concurrently stored activation microbatches in any stage is capped at , independent of total microbatch count :
This decoupling allows engineers to scale the number of microbatches arbitrarily high to suppress the pipeline bubble without increasing GPU memory consumption.
Interleaved 1F1B Schedule
To further minimize the bubble fraction without increasing batch size , Megatron-LM supports interleaved virtual stages. Instead of assigning a contiguous block of layers to each device, each physical GPU manages virtual stages (chunks).
For example, with physical GPUs and , GPU 1 holds Chunk 1 (Layers 1 to 2) and Chunk 5 (Layers 9 to 10). A microbatch passes through GPU 1 to GPU 2 to GPU 3 to GPU 4, then back to GPU 1 to GPU 2 to GPU 3 to GPU 4.
The resulting bubble fraction shrinks by a factor of :
The trade-off is an increase in point-to-point peer communication over the network by a factor of , requiring dedicated high-speed inter-node links.
3D Parallelism Grid and Interconnect Topology
State-of-the-art frontier model training orchestrates Tensor Parallelism, Pipeline Parallelism, and Data Parallelism (DP) into a cohesive 3D grid across GPUs:
Parallelism Dimensions Overview
- Tensor Parallelism (TP + SP): Splits intra-layer GEMMs and sequence tokens. Uses Reduce-Scatter and All-Gather collectives. Demands extremely high bandwidth (>450 GB/s) and is mapped to intra-node NVLink/NVSwitch domains.
- Pipeline Parallelism (PP): Splits model depth ( layers). Uses point-to-point non-blocking send/receive operations. Requires moderate bandwidth (10 to 50 GB/s) and is mapped across inter-node InfiniBand/RoCE links.
- Data Parallelism (DP / ZeRO): Splits the batch dimension (). Uses All-Reduce or Reduce-Scatter/All-Gather over parameter and gradient shards. Requires periodic bulk bandwidth (50 to 100 GB/s) across the cluster fabric.
Network Topology Mapping
Modern GPU cluster architectures (e.g., NVIDIA SuperPODs with H100/H200 nodes) feature 8 GPUs per server connected via high-bandwidth NVLink crossbar switches (900 GB/s per GPU), while inter-node communication is routed over 400 Gbps or 800 Gbps InfiniBand interfaces.
Engineers align the 3D parallelism topology directly with physical network bandwidth:
- Set : Confine all Tensor and Sequence Parallelism communication within the intra-node NVLink domain. Crossing PCIe or InfiniBand links with Tensor Parallelism degrades arithmetic intensity and causes severe GEMM pipeline stalls.
- Set across nodes: Pipeline Parallelism only transmits boundary layer activation tensors of shape between adjacent stages, incurring minimal point-to-point network traffic.
- Set across the remaining cluster: Data Parallelism distributes the outer batch dimension across nodes, overlapping gradient synchronization collectives with backward compute passes.
By decomposing dense matrix projections, sharding non-GEMM activations across sequence dimensions, and interleaving microbatch schedules, distributed transformer systems achieve linear compute scaling across tens of thousands of GPUs.
Sources
- Shoeybi, M., et al. (2019). Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism. arXiv:1909.08053. https://arxiv.org/abs/1909.08053
- Narayanan, D., et al. (2021). Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM. arXiv:2104.04473. https://arxiv.org/abs/2104.04473
- Korthikanti, V., et al. (2022). Reducing Activation Recomputation in Large Transformer Models. arXiv:2205.05198. https://arxiv.org/abs/2205.05198
- Huang, Y., et al. (2019). GPipe: Efficient Training of Giant Neural Networks using Pipeline Parallelism. arXiv:1811.06965. https://arxiv.org/abs/1811.06965
- Rajbhandari, S., et al. (2020). ZeRO: Memory Optimizations Toward Training Trillion Parameter Models. arXiv:1910.02054. https://arxiv.org/abs/1910.02054
- NVIDIA Corporation. (2024). Megatron-LM GitHub Repository and Documentation. https://github.com/NVIDIA/Megatron-LM



