Training Trillion-Parameter Multimodal Models on Heterogeneous Compute: An Implementation Guide
This article provides an implementation guide for training trillion-parameter multimodal models on heterogeneous compute. It covers memory and communication estimates, the roles of FSDP, TP, PP, and EP, model loading and sharding steps, gradient synchronization and startup checks, adaptation to heterogeneous GPU types, and checkpointing and failure recovery. Readers can use these practices to plan parallelism, validate bandwidth and memory assumptions, and improve training stability and recovery readiness.
The 2.8-trillion-parameter model discussed here does not have a specific source in the original material. The numbers below are estimation examples only. For an actual model, use its public configuration.
1. Estimate Memory and Communication Before You Start
Memory estimation: With BF16 weights, BF16 gradients, FP32 master weights, and two FP32 Adam states, each parameter takes about 16 bytes. For a 2.8-trillion-parameter model, parameter-related states total about 44.8 TB. If pure FSDP is used and these states are sharded evenly across N GPUs, 1024 GPUs require about 44 GB per GPU. This is a lower bound. Activations, communication buffers, and temporary space for gathering parameters must be reserved separately. These vary with sequence length, micro batch size, and recomputation strategy, so they need to be measured on a single GPU.
Communication estimation: With the ring algorithm, FSDP performs three collective communications per step per GPU: forward All-Gather, backward All-Gather, and gradient Reduce-Scatter. Each transfers about one copy of the parameters. At BF16, 2.8 trillion parameters total about 16.8 TB. Assuming a single-GPU unidirectional network bandwidth of 50 GB/s (400 Gb/s), an ideal network with no congestion and no latency, each step requires about 336 seconds for communication. This time does not decrease as the number of GPUs increases. Adding GPUs only divides compute; communication time remains unchanged. Overlapping compute and communication can hide some overhead but cannot eliminate it. Protocol overhead, congestion, and retransmission in real training will only make it longer, so this number should be treated as a theoretical lower bound.
MoE models must be estimated separately. Expert parameters and non-expert parameters should be calculated separately for memory and communication. The number of parameters actually activated per token is much smaller than the total parameter count, so compute should be estimated by activated parameters, while memory should be estimated by total parameters.
2. What FSDP, TP, PP, and EP Each Handle
FSDP: Shards parameters, gradients, and optimizer states, mainly solving memory problems. Its communication consists of parameter aggregation and gradient reduction. It can be used across nodes, but communication volume is large and depends on compute overlap.
Tensor parallelism (TP): Shards matrices in attention and feed-forward layers. Communication occurs within every layer and is frequent, so TP should be placed within a single node and relies on high-bandwidth interconnects such as NVLink. It is not suitable for cross-node deployment.
Pipeline parallelism (PP): Splits the model into stages by layer and distributes them across different node groups. Only activations are transferred between nodes, so communication volume is much smaller than parameter synchronization, making PP suitable for cross-node deployment. The cost is pipeline bubbles, which can be reduced by increasing the number of micro batches and using interleaved schedules.
Expert parallelism (EP): Used only when MoE layers are present. Expert parameters are distributed across multiple GPUs along the EP dimension. After each token is routed to selected experts, it is sent via All-to-All to the GPUs holding those experts and sent back after computation. This step is sensitive to latency and load balancing.
A basic constraint must be satisfied when combining them: the total number of GPUs equals the product of the parallelism degrees. For example, TP × PP × data parallel degree = total GPUs. EP usually reuses the data parallel dimension, and the exact relationship depends on the framework used. A common practice is to place TP within a node and PP and data parallelism across nodes.
EP also needs two control parameters. The capacity factor limits the number of tokens each expert can receive in one step; excess tokens are dropped or handled through overflow handling, and the value should be determined experimentally. Load balancing is controlled through auxiliary loss or router bias, with the goal of making the number of tokens received by each expert roughly balanced.
3. Model Loading and Sharding Scheduling Steps
Step 1: Check the environment. CUDA, drivers, NCCL, and training framework versions must be consistent across all nodes. Use benchmarking tools such as nccl-tests to measure actual All-Gather and Reduce-Scatter bandwidth separately and compare it with hardware nominal values. The precondition is a consistent environment and measured bandwidth reaching a reasonable proportion of the expected value.
Step 2: Convert weights. Convert the original weights into a distributed checkpoint format supported by the framework. This format supports reloading after re-sharding for different GPU counts, avoiding each process reading the full weights into memory.
Step 3: Initialize parallel process groups. Create process groups along the TP, PP, and data parallel (EP) dimensions, and print each rank’s group membership to confirm that the mapping matches the design.
Step 4: Set the sharding strategy. Wrap FSDP by Transformer block; a single very large layer can be sharded separately. Non-expert parameters are sharded by FSDP, and MoE experts are sharded along the EP dimension.
Step 5: Configure scheduling. Enable parameter prefetch in forward and backward passes so that All-Gather overlaps with compute. Enable selective activation recomputation by layer, applying it only to layers with high memory pressure.
Step 6: Run a small-scale trial. Run several steps with a small amount of data, record peak memory per GPU and time per step, and compare them with the earlier estimates. If the deviation is large, first check whether sharding matches expectations, then adjust parallelism.
4. Gradient Synchronization and Checklist
FSDP gradients are synchronized through Reduce-Scatter, and each GPU keeps only its own shard of gradients. Parameters that are not sharded, such as some replicas or parameters of small modules, are synchronized using All-Reduce. With gradient accumulation, synchronize only on the last micro batch to reduce communication frequency. Gradient clipping requires computing the global norm, so use the framework’s sharding-aware implementation; otherwise, clipping results will be inconsistent across GPUs. Whether to use FP32 or BF16 for gradient reduction should be weighed against numerical stability and communication cost.
After training starts, check the following items one by one:
- Whether peak memory per GPU is within available memory, with margin left for fragmentation and burst allocations.
- Whether per-step communication time is sufficiently overlapped by compute. If communication time clearly exceeds compute time, check the communication bucket size and prefetch settings.
- Whether loss is consistent across ranks and whether NaN or Inf appears.
- Whether gradient norms are consistent across ranks.
- Whether the number of tokens received by each expert is roughly balanced and whether any expert overflows for a long period.
5. Heterogeneous Compute Adaptation Notes
Different GPU types have different memory capacities. Batch size and sharding should be set according to the GPU with the smallest memory to avoid making small-memory GPUs the bottleneck for the whole group.
When interconnect topologies differ across nodes, place TP groups within the same high-bandwidth domain and set PP split points at node boundaries where possible.
Different GPUs have different compute capabilities, so PP stages will have uneven compute loads and produce additional bubbles. Divide layers according to the measured throughput of each GPU rather than simply averaging them.
Mixed-precision support varies by GPU type. Before enabling BF16 or FP8, confirm that both the hardware and framework support it.
Calibration method: measure single-GPU throughput, peak memory, and communication bandwidth separately on each GPU type, and use these results to decide placement rather than directly applying nominal specifications.
6. Checkpointing and Failure Recovery
Checkpoint frequency should be determined by the average interval between failures and the time required for a single save. Saving too frequently slows training, while saving too infrequently loses more progress when a failure occurs.
Asynchronous saving can overlap shard writes with training compute and reduce training pauses. Before using it, confirm that storage bandwidth is sufficient; otherwise, writes will back up.
A checkpoint must include model parameters, optimizer states, random number seeds, and data reading position. If any of these is missing, training after recovery may be inconsistent with the original run.
Do not immediately continue training after recovery. First compare loss before and after recovery on the same batch of data, and continue only when the difference is within an acceptable range.
When a node failure reduces the number of available GPUs, recompute the parallelism to ensure that the product of TP and PP divides the new GPU count. If necessary, reload from the distributed checkpoint using the new GPU count.
