Training Trillion-Parameter Models: 5 Key Stages and an Acceptance Checklist

    Training models with trillions of parameters presents significant engineering challenges. This article explores the universal engineering problems encountered when training models at this scale, such as memory estimation, FSDP2 communication patterns, and multimodal sharding strategies. It provides a practical acceptance checklist covering five key stages—from weight loading to fault-tolerant recovery—helping developers validate their environments and ensure reliable training processes.

    1. Boundaries: What Conclusions Cannot Be Drawn Yet

    Public information indicates that an intelligent computing platform has completed training adaptation for a 2.8-trillion-parameter open-source large model. However, cluster size, software version, training throughput, and MFU validation metrics have not been disclosed. Therefore, this article does not evaluate the platform’s performance, nor does it interpret the adaptation completion as performance certification.

    This article discusses the general engineering problems that models of this scale must handle and how each stage should be validated. Readers can use the main text as a checklist; every conclusion should be re-measured in their own environment.

    2. How to Estimate Memory Requirements and What Metrics to Consider for Selection

    Taking weights as an example, storing 2.8 trillion parameters in FP16 or BF16 requires approximately 5.6TB (2.8 × 10^12 parameters × 2 bytes = 5.6 × 10^12 bytes, converted in decimal units). This number includes only the weights themselves, excluding optimizer states, gradients, and activations.

    When using AdamW, momentum and variance are usually stored in FP32, and mixed-precision training may also retain a master copy of FP32 weights. Estimating with a common 16 bytes per parameter (2 bytes for BF16 weights, 2 bytes for BF16 gradients, 4 bytes for FP32 master weights, 8 bytes for FP32 momentum and variance), the total is about 44.8TB. This is merely an order-of-magnitude estimate. Actual peak memory is determined by sharding methods, micro-batch size, and whether recomputation is enabled, and should be based on actual measurements.

    When making selections, it is recommended to include the following dimensions in a table and fill them out item by item using manufacturer spec sheets and measured values:

    Dimension Content to Confirm Impact on Training Acceptance Method
    Single GPU Memory Capacity Available memory after deducting system and framework usage Determines the shard size and micro-batch size per GPU Record peak with torch.cuda.max_memory_allocated and keep a margin
    Memory Bandwidth Sustained bandwidth, not nominal peak Affects actual speed of memory-bound operators Compare with benchmark results of mature operators
    Inter-GPU Interconnect Intra-node and inter-node bandwidth and topology Determines the latency of AllGather and ReduceScatter Measure AllGather and ReduceScatter bandwidth intra-node and inter-node
    Precision Support Hardware and framework support for BF16, FP8 Determines available mixed-precision schemes Run target precision on a small model and check for numerical overflow
    Unified Training and Inference Whether training and inference share drivers and operator libraries Affects compatibility verification cost during deployment switching Compare outputs from training and inference sides on the same batch of samples

    Unified training and inference can reduce procurement categories, but it does not automatically guarantee consistent numerical behavior between training and inference. Before switching deployments, you should compare the outputs of both sides on the same batch of samples.

    3. What is the Communication Pattern of FSDP2? Where Do Common Misunderstandings Lie?

    FSDP2 is a type of Fully Sharded Data Parallel. It shards parameters, gradients, and optimizer states across devices based on the device mesh. During forward computation, the framework uses AllGather to collect the complete parameters needed for the current layer and releases non-local shards after computation. During backward computation, gradients are distributed back to each card’s shards via ReduceScatter. The prefetching mechanism can initiate AllGather for the next layer while computing the current layer, thereby partially hiding communication latency.

    There are a few commonly confused points here:

    • Gradient synchronization in FSDP2 mainly relies on ReduceScatter; it is not AllReduce as in traditional data parallelism, nor is it All-to-All.
    • All-to-All typically appears in expert parallelism, used to distribute tokens among different experts. When the model contains a MoE (Mixture of Experts) structure, both types of communication will exist simultaneously and need to be timed separately.
    • FSDP2 uses modules as the calling boundary. After calling fully_shard on a module, it becomes a sharding unit. Parameters are represented as DTensors and sharded according to the shard group. FSDP1 uses FlatParameter, concatenating multiple parameters within a sharding unit into a flat tensor.

    The following table lists the main differences between the two:

    Comparison Item FSDP1 FSDP2
    Sharding Interface FullyShardedDataParallel wrapping model fully_shard called per module
    Parameter Representation FlatParameter DTensor
    Sharding Granularity By wrapped module By called module, can be refined layer by layer
    Communication Scheduling Depends on wrapping strategy and prefetch settings Can be controlled via module structure and prefetch-related settings

    The benefits of FSDP2 over FSDP1 depend on the model structure and network conditions; you should rely on your own benchmark results.

    4. How to Troubleshoot the Five Key Stages and What to Look for in Acceptance

    The table below lists the troubleshooting points and acceptance metrics for the five stages:

    Stage Troubleshooting Points Acceptance Metrics
    Weight Loading Check weight file integrity, dtype conversion, and shard reading order; confirm each parameter is loaded only once Loaded parameter count matches the manifest; sampled parameters are compared element-wise with source files, with errors within agreed precision; record loading time and peak host memory
    Shard Configuration Verify device mesh shape, sharding granularity, and mixed-precision strategy; confirm the shard location of each parameter Sum of sharded parameters across all GPUs equals total parameters; peak GPU memory of a single forward step is lower than available memory per GPU with margin retained
    Gradient Synchronization Confirm ReduceScatter appears in backward computation as expected, and check the precision used for gradient reduction On a small model, relative error between distributed gradients and single-GPU reference gradients is within agreed threshold; record the proportion of communication time per step to total time
    Fault-Tolerant Resume Confirm the ability to recover from the latest Checkpoint after failure; optimizer steps, learning rate schedule, random seeds, and data reading positions are correct after recovery After manually terminating a node and recovering, the loss curve for several steps after recovery is within agreed range of the uninterrupted baseline
    Checkpoint Read/Write Check atomicity of saving, checksum, version info, and rollback path Read/write time recorded; checksum verification passed; complete at least one recovery drill and record time

    The focus of gradient synchronization troubleshooting is reduction precision. If the precision used for gradient reduction is lower than the accumulation precision, errors will gradually accumulate during long-sequence training. During acceptance, compare the distributed gradients with the single-GPU reference gradients on a small model and record the relative error.

    The key to fault-tolerant resume is to completely restore the state to the exact same step. The items that need to be restored include model and optimizer states, learning rate scheduler, random seeds, and the data loader’s reading position. If any item is missing, the post-recovery training trajectory will deviate from the original.

    Checkpoint read/write needs to prevent data corruption. When saving, first write to a temporary file. After the checksum passes, rename it to the official file. This way, even if power is interrupted midway, there won’t be a half-written file left. Each version should record the framework version, shard configuration, and checksum. Retain the latest several versions so that you can roll back to the previous valid version if recovery fails. After each modification to the storage or shard configuration, a complete recovery drill should be executed.

    5. How to Organize Sharding for Multimodal Models

    The following code is only for illustrating the structure and cannot be directly reproduced. It shows how the vision encoder and language model call the sharding interface separately.

    Prerequisites are as follows:

    • Use PyTorch 2.x, and the version supports fully_shard and MixedPrecisionPolicy in torch.distributed.fsdp. Refer to the official documentation for the exact version.
    • Launched via torchrun, each process bound to one GPU, and NCCL communication works normally.
    • Have access to model weights and training data, and have run the same pipeline on a small-scale model.
    • Attribute names like vision_encoder.blocks and language_model.layers depend on the specific model implementation and need to be replaced with actual attributes.
    1. import torch
    2. import torch.nn as nn
    3. from torch.distributed.device_mesh import init_device_mesh
    4. from torch.distributed.fsdp import fully_shard, MixedPrecisionPolicy
    5. def shard_multimodal_model(vision_encoder: nn.Module,
    6. projector: nn.Module,
    7. language_model: nn.Module,
    8. world_size: int):
    9. # 1D device mesh: all processes form a single shard group
    10. mesh = init_device_mesh("cuda", (world_size,))
    11. mp = MixedPrecisionPolicy(param_dtype=torch.bfloat16,
    12. reduce_dtype=torch.float32)
    13. # Vision encoder: shard individual blocks first, then the whole module
    14. for block in vision_encoder.blocks:
    15. fully_shard(block, mesh=mesh, mp_policy=mp)
    16. fully_shard(vision_encoder, mesh=mesh, mp_policy=mp)
    17. # Projector has fewer parameters, shard it separately
    18. fully_shard(projector, mesh=mesh, mp_policy=mp)
    19. # Language model: shard layer by layer, then the whole module
    20. for layer in language_model.layers:
    21. fully_shard(layer, mesh=mesh, mp_policy=mp)
    22. fully_shard(language_model, mesh=mesh, mp_policy=mp)
    23. # The outer container model also needs to call fully_shard
    24. return vision_encoder, projector, language_model
    25. def forward_multimodal(pixel_values, input_ids,
    26. vision_encoder, projector, language_model):
    27. # Forward order must match the sharding call logic: vision encoder -> projector -> language model
    28. image_feat = vision_encoder(pixel_values)
    29. image_tokens = projector(image_feat)
    30. return language_model(input_ids, image_tokens)

    The vision encoder and language model have large structural differences, and their computational loads and activation sizes differ. Therefore, the sharding strategy should be designed separately for the two sub-modules and adjusted based on measured peak memory and communication latency.

    During acceptance, three metrics should be checked:

    • Peak memory: Call torch.cuda.max_memory_allocated after forward and backward computation respectively to record the peak, and confirm it is lower than the agreed proportion of available GPU memory per card.
    • Communication latency: Use torch.profiler to track the time proportion of AllGather and ReduceScatter.
    • Output consistency: Fix the random seed, compare the outputs of the distributed model and the single-GPU reference implementation on the same batch of inputs, and record the maximum absolute error and relative error. The threshold should be determined on a small model first before being applied to the full model.

    These metrics serve only as an acceptance framework. Specific thresholds need to be determined based on the precision used, model structure, and hardware conditions.