Training a Trillion-Parameter Open-Source Model on Domestic AI Accelerators: Key Adaptation Steps

    A practical guide to adapting a 2.8-trillion-parameter open-source model for training on domestic AI accelerator hardware. Covers memory estimation, FSDP2 sharding configuration, acceptance criteria for native adaptation, multimodal training pipelines, checkpoint resharding, gradient synchronization, and a troubleshooting checklist for engineering teams.

    Background: When a Trillion-Parameter Model Meets Domestic Accelerators

    A flagship large model with 2.8 trillion parameters was recently released as open source. Around the same time, a domestic AI hardware vendor announced that it had completed training adaptation for the model using its own training-and-inference accelerator cards and accompanying software stack. Since neither party is named in the original materials, this article focuses only on the technical path, without evaluating any specific vendor or product.

    What matters for engineering teams is a verifiable chain: model loading, sharded scheduling, forward and backward computation, gradient synchronization, and checkpoint saving. Each step can be validated independently, and this article walks through them in that order.

    Estimate Memory First, Then Choose a Parallelism Strategy

    The first step before training is estimating memory. Using mixed-precision training as an example, each parameter corresponds to roughly the following state:

    • Parameters themselves: stored in BF16 at 2 bytes per parameter, so 2.8 trillion parameters require about 5.6 TB.
    • Gradients: also stored in BF16 at 2 bytes per parameter, about 5.6 TB.
    • Optimizer state: with Adam, this includes an FP32 master copy of the parameters, first-order momentum, and second-order variance, totaling 4+4+4 = 12 bytes per parameter, about 33.6 TB.
    • Activations: these depend on batch size, sequence length, and layer count. They are not part of parameter state and must be estimated separately for the specific configuration.

    The first three items total roughly 44.8 TB, which is the theoretical lower bound for parameter state. With 80 GB of memory per card, even if the state were perfectly sharded, you would need at least around 560 cards to hold it—excluding activations, communication buffers, and memory fragmentation. In practice, the card count will be higher. If gradients are stored in FP32, or the optimizer uses low-bit state variants, these numbers change accordingly; always rely on the actual configuration.

    The software stack is another class of constraint. Open-source models typically assume the CUDA ecosystem for operators, communication primitives, and scheduling logic. Adaptation requires finding equivalent operator libraries, collective communication libraries, and compiler optimization capabilities on the target platform. The first thing to inventory is operator coverage: list every operator used in the model’s forward and backward passes and confirm whether the target platform implements each one. For unimplemented operators, define a fallback path—such as composing existing operators or writing custom kernels—and evaluate the impact on performance and numerical accuracy.

    FSDP2 Sharding: Definition, Configuration, and Prerequisites

    What FSDP2 Is

    Fully Sharded Data Parallelism (FSDP) shards model parameters, gradients, and optimizer state across data-parallel processes. During forward and backward passes, the parameters needed by the current layer are gathered on demand via all-gather and released after use. Peak memory is therefore determined by the few layers active at any moment, not by the entire model.

    FSDP1 and FSDP2 differ in sharding granularity. FSDP1 shards at the module level, flattening a module’s parameters into a single flat tensor before sharding. FSDP2 shards at the individual parameter level: parameters are represented as DTensors, and each process holds its own shard of each parameter. This yields three immediate differences:

    1. Memory can be accounted for precisely per parameter, making per-shard usage easier to predict.
    2. Mixed precision and CPU offloading can be configured per module.
    3. Composition with other DTensor-based parallelism approaches, such as tensor parallelism, is more natural.

    The entry point for FSDP2 is the fully_shard function, whose import path may vary across PyTorch versions. Verify the import path in your environment before use and follow the official documentation for your version. The target platform must also support DTensor-related device meshes and collective operations, otherwise FSDP2 cannot be used directly.

    Here is illustrative code, where model.layers is an assumed module structure:

    1. import torch
    2. from torch.distributed.fsdp import fully_shard, MixedPrecisionPolicy, CPUOffloadPolicy
    3. mp_policy = MixedPrecisionPolicy(
    4. param_dtype=torch.bfloat16, # parameter precision used in forward and backward passes
    5. reduce_dtype=torch.float32, # gradient reduction precision; higher accuracy but more communication
    6. )
    7. # Shard layer by layer first, then the root module, so each layer's parameters
    8. # can be gathered independently and released after use
    9. for layer in model.layers:
    10. fully_shard(layer, mp_policy=mp_policy)
    11. fully_shard(model, mp_policy=mp_policy)
    12. # Enable offloading only if memory is still insufficient; the cost is host-device bandwidth overhead
    13. # fully_shard(model, mp_policy=mp_policy, offload_policy=CPUOffloadPolicy())

    Acceptance Criteria for “Native Adaptation”

    “Native” in the original announcement means the sharding scheduler aligns directly with the underlying communication topology, rather than running through a translation layer or compatibility shim. Such a claim needs verifiable criteria. Consider accepting along four dimensions:

    • Operator coverage: every operator in FSDP2’s gather, shard, cast, and reduction paths is natively implemented on the target platform. Report the coverage rate and list any fallback operators.
    • Communication paths: use profiling tools to confirm that all-gather and reduce-scatter go through the target platform’s collective communication library, not a fallback path through host memory or a slow network.
    • Precision alignment: fix random seeds, initial weights, and data order, then compare loss and gradient norms against a reference platform for the first few steps. The relative error should stay within a threshold agreed on in advance by the team. If no reference platform is available, align first on a small-scale configuration in an already-validated environment.
    • Convergence and efficiency: run a longer training job with the same configuration and compare loss curve trends and endpoint metrics. Also record the effective per-card compute utilization, and the gap between peak memory and the theoretical estimate.

    Three Stages of the Multimodal Training Pipeline

    Multimodal models typically consist of a vision encoder, a projection layer, and a language backbone, with training data containing both text and images. The training pipeline must handle three stages: model loading, sharded scheduling, and gradient synchronization.

    Online Resharding: Loading Distributed Checkpoints

    Weights of very large models are usually stored sharded across multiple files. If loading reads the full weights into one node before resharding, that node’s memory will be instantly exhausted. Online resharding reads only the required portions directly according to the target topology:

    1. Read the checkpoint metadata to obtain each tensor’s global shape, data type, and location in the storage files.
    2. Based on the target parallel topology (data parallel, tensor parallel, and pipeline parallel dimensions), compute the global index range each process needs.
    3. Read only the required byte ranges, performing dtype conversion during the read.
    4. Place the shard into device memory, release host-side caches, then process the next block.

    PyTorch’s torch.distributed.checkpoint supports loading a saved distributed checkpoint with a new process count and can serve as the base tool for this step. After loading, perform three checks: each parameter’s global shape matches the model definition; each shard range is covered by exactly one process, with no gaps or overlaps; and after loading, a forward pass produces output identical to the reference output from before saving, with a tolerance set according to the data type.

    Choosing Parallelism per Module

    The vision encoder, projection layer, and language backbone have very different computational characteristics, so applying one parallelism scheme uniformly is unwise. The table below provides a starting point; final decisions should be based on profiling data.

    Module Parameter and Compute Characteristics Recommended Parallelism Rationale
    Vision encoder Relatively few parameters, highly variable input resolutions, significant activation fluctuation FSDP2 parameter sharding with data parallelism; enable activation checkpointing when activations are large When parameters fit on a single card, tensor parallelism’s communication overhead is usually not worth it
    Projection layer Few parameters, small compute, called frequently Merge into the same data-parallel group as adjacent modules; do not shard separately Sharding it separately generates many small communications that slow overall throughput
    Language backbone The vast majority of parameters, many layers FSDP2 as the primary strategy; add pipeline parallelism to split stages when there are too many layers for one node; apply tensor parallelism to attention and feed-forward layers when individual layers are too wide Tensor parallelism depends on high-speed intra-node interconnects; use data parallelism or pipeline parallelism for cross-node communication

    Pipeline parallelism’s 1F1B scheduling and FSDP’s sharding are two independent dimensions. They can be combined but cannot replace each other.

    Gradient Synchronization and Communication Overlap

    After backward propagation, all data-parallel processes must reduce gradients. In FSDP2, each layer’s reduce-scatter is triggered automatically by the framework. What you can control is overlapping communication with computation to reduce waiting. The pseudocode below shows execution order only and cannot be run directly; interface names should follow your framework:

    1. # Pseudocode: communication-computation overlap order during the backward phase
    2. handles = []
    3. for i in reversed(range(len(layers))):
    4. if i > 0:
    5. prefetch_all_gather(layers[i - 1]) # prefetch parameters for the next layer's backward pass
    6. grad = backward(layers[i]) # compute this layer's gradients
    7. handles.append(async_reduce_scatter(grad, bucket_mb=BUCKET_MB)) # asynchronous reduction
    8. for h in handles:
    9. h.wait() # all must complete before the optimizer step
    10. optimizer.step()

    Three points deserve attention when tuning. First, bucket size affects the number of communications and the volume per communication. DDP’s default bucket size is 25 MB, a reasonable starting point to adjust based on measurements. Second, the communication backend name is provided in the vendor’s documentation; confirm how it integrates with your framework. Third, with gradient accumulation, run the reduction only on the last micro-batch; earlier micro-batches only accumulate local gradients, reducing communication count. To verify overlap effectiveness, measure the fraction of time the compute stream spends waiting on communication—the lower the fraction, the better the communication is hidden.

    Common Errors and Troubleshooting

    Symptom Common Cause What to Check First
    Out of memory (OOM) Sharding does not cover all layers, no activation checkpointing, batch too large Gap between each process’s peak memory and the theoretical estimate; whether every layer is wrapped by sharding
    Communication hang A process exited early, inconsistent parallel topology configuration across processes, different collective call ordering The last collective operation in each process’s logs; whether world size and device mesh match
    Checkpoint resharding failure Inconsistent global shapes, incorrect index computation after parallel dimension changes Shapes and dtypes in the metadata; whether the target topology’s shard ranges cover everything
    Precision overflow or abnormal loss Low-precision accumulation error, insufficient reduction precision, learning rate mismatched with gradient scale Gradient norm curves; reduce_dtype settings; the specific step where anomalies appear

    Adaptation Checklist

    • Memory estimated separately for parameter state and activations, and compared against measured peaks.
    • Operator coverage counted; fallback operators and their paths listed.
    • Communication paths confirmed via profiling; all-gather and reduce-scatter not taking fallback paths.
    • Loss and gradient norms for the first few steps aligned with reference results, with thresholds agreed in advance.
    • Checkpoints resharded under the new topology, with coverage checks passing.
    • Per-module parallelism choices backed by profiling data, not just experience.
    • After a training interruption, training can resume from a checkpoint with a continuous loss curve.

    Conclusion

    To reproduce a complete training pipeline after an open-source model’s release, three conditions must hold simultaneously: training data and recipes, an available cluster with a stable software stack, and enough tuning time and budget. Missing any one slows progress. To judge the maturity of a domestic accelerator’s adaptation, apply the acceptance criteria and checklist above and report measured results item by item, rather than relying on generalized conclusions.