Trillion-Parameter Multimodal Model Training on Domestic AI Chips: A Practical Adaptation Guide

    This article uses the recent training adaptation of a 2.8 trillion-parameter open-source multimodal model on domestic AI hardware as a case study, and abstracts it into the engineering challenge of training ultra-large-scale multimodal models on heterogeneous compute platforms. It explains why this kind of adaptation is difficult—linear memory growth that forces full sharding, heterogeneous operator distributions, complex communication patterns, and a long software stack—then walks through a hardware-software collaborative approach and the key steps from model loading to gradient synchronization, including operator adaptation, memory optimization, FSDP2 sharding, and fault recovery. It closes with implementation steps, a table of common issues, and cloud deployment considerations. Readers will come away with a general methodology for adapting large-scale multimodal training to new hardware.

    Note: The parameter counts referenced in this article come from public reports. The code snippets are illustrative pseudocode used to explain general design ideas and do not represent the actual interfaces of any hardware or framework.

    1. Why Trillion-Parameter Multimodal Training Is Harder to Adapt

    1.1 Memory demand scales linearly, making full sharding mandatory

    In the standard mixed-precision training scheme, each parameter carries not only a half-precision copy but also a half-precision gradient and a single-precision optimizer state. Taking Adam as an example, the first and second moments each require their own copy, and together with the single-precision master weights, a single parameter costs about 16 bytes of overhead.

    1. Memory overhead ≈ parameter count × 16 bytes
    2. 2.8 × 10¹² × 16 B ≈ 44.8 TB

    Just the parameters, gradients, and optimizer states require a cluster with tens of terabytes of aggregate memory. Activations, communication buffers, and temporary tensors push the peak memory even higher. This is why memory sharding is the starting point of trillion-parameter training, not an optional optimization.

    1.2 Heterogeneous compute graphs with a long-tail operator distribution

    A multimodal large model typically consists of a vision encoder (often a convolutional network or a vision Transformer), a projection layer that connects vision and language, and a language backbone that carries most of the parameter count.

    • Uneven operator distribution: Convolutional operators make up a large share in the vision encoder, while the language backbone is dominated by matrix multiplications, normalization, and attention. These two classes of operators do not run with the same efficiency on the hardware.
    • Dense long-tail operators: Normalization, positional encoding, cross-entropy loss, and similar operators are numerous in the language backbone but individually compute-light, so they tend to be constrained by memory bandwidth and launch overhead.
    • Modality fusion: Text, image, video, and audio are mapped into a shared representation space, and sequence lengths differ dramatically across modalities.

    If any operator class shows precision deviation or a performance collapse on the domestic hardware, it becomes a bottleneck for overall training throughput.

    1.3 Complex communication patterns act as a hidden ceiling on compute

    Trillion-parameter models span many parallelism dimensions, and collective communication runs through the entire iteration:

    • Gradient reduction for data parallelism
    • Parameter gathering and gradient scattering for Fully Sharded Data Parallel (FSDP)
    • Activation exchange for tensor parallelism
    • Point-to-point transfers for pipeline parallelism

    Multimodal training layers on additional synchronization from feature projection, extra communication from long visual sequences, and the All-to-All expert-routing communication common in mixture-of-experts models. Whether communication can fully overlap with computation often determines end-to-end throughput more than single-card peak compute does.

    1.4 A long software stack makes adaptation a systems-engineering effort

    From model code to hardware execution, the path passes through the framework layer, the communication library, the operator library, the runtime, and the driver layer. The operator coverage, numerical behavior, and communication-library implementation of domestic hardware may all differ from mainstream hardware.

    The essence of adaptation is to align the semantics of every layer in this chain with mainstream implementations, or to smooth over the differences at the framework layer in a reasonable way—not to patch a single point in a single layer.

    2. A Hardware-Software Collaborative Approach to Adaptation

    The core practice behind this adaptation can be summarized as “hardware + software stack” collaboration: a flagship training-and-inference AI card provides compute and memory, a self-developed unified computing software stack provides runtime, operators, and communication capabilities, and a native FSDP2 multimodal training path is built at the framework layer. This path operates directly on sharded parameters, eliminating the extra overhead introduced by traditional wrapper-style sharding schemes.

    1. ┌───────────────────────────────────────────────────────────┐
    2. │ Model layer: multimodal model definition and weight loading │
    3. ├───────────────────────────────────────────────────────────┤
    4. │ Framework layer: FSDP2, parallelism strategy, training loop │
    5. ├───────────────────────────────────────────────────────────┤
    6. │ Operator library: fused attention, normalization, loss │
    7. ├───────────────────────────────────────────────────────────┤
    8. │ Communication library: AllGather / ReduceScatter │
    9. ├───────────────────────────────────────────────────────────┤
    10. │ Hardware layer: accelerator cards, intra-card & cross-node │
    11. └───────────────────────────────────────────────────────────┘

    The “native” support at the framework layer is especially critical. Only when sharding, gradient synchronization, and optimizer updates are all performed within the framework under a unified semantic can model code migrate to new hardware with almost no changes, while keeping cross-hardware training results numerically consistent. For users, the endpoint of hardware adaptation is transparency at the framework level: model developers do not need to perceive underlying hardware differences and can focus back on the model and data themselves.

    3. Key Steps from Model Loading to Gradient Synchronization

    3.1 Model loading: fitting trillions of parameters and getting them to move

    The full weights of a trillion-parameter model can reach several terabytes. Using traditional loading approaches, you must first read the complete weights into host memory and then upload them to the device, which easily leads to host memory exhaustion or loading timeouts. A more robust approach has three steps:

    1. Offline conversion: On general-purpose compute nodes, convert the weights into a format the target hardware recognizes, completing parameter renaming, layout, and precision conversion.
    2. Meta-device construction: Build the model skeleton on a “meta device”, recording parameter shapes and device mapping, to avoid allocating real memory all at once.
    3. Layered loading: Read weights layer by layer and write them directly to the target device, minimizing peak host memory and device memory usage.

    Multimodal models also need to verify that the weights of the vision and language submodules match completely, preventing an individual submodule from being missing or mismatched and only surfacing after long training.

    1. # Illustrative pseudocode: meta-device construction + layered loading
    2. with meta_device(): # Build structure logically only, without allocating real memory
    3. model = MultimodalLLM(config) # Vision encoder + projection layer + language backbone
    4. loader = ShardedWeightLoader(ckpt_dir) # Weight shards generated by the offline conversion script
    5. for name, tensor in model.named_parameters():
    6. tensor.data = loader.load(name).to(device) # Load layer by layer to the target device
    7. del tensor if False else None

    3.2 Operator adaptation: focus on the long tail and numerical consistency

    Adaptation work mainly centers on three classes of operators:

    • Attention: Use a fused implementation to reduce memory usage and avoid explicitly constructing large attention matrices.
    • Normalization: Mean and variance computations in half precision are prone to overflow or bias, so statistics are usually gathered in single precision and then converted back to low precision.
    • Loss computation: When the vocabulary is huge, vocabulary parallelism combined with block-wise computation avoids materializing the entire logits tensor at once.

    When implementing new operators, follow the order of “correctness first, performance second”:

    1. Compare each operator against a general reference implementation with unit tests, keeping the error within a reasonable threshold;
    2. Verify forward-backward consistency and numerical stability at the gradient level;
    3. Then use profiling tools to locate bottlenecks and apply fusion and memory-access optimizations.
    1. # Illustrative pseudocode: normalization and loss computation in low precision
    2. def rms_norm(x, weight, eps=1e-6):
    3. xf = x.float() # Gather statistics in single precision to avoid overflow
    4. normed = xf * torch_rsqrt(xf.pow(2).mean(-1, keepdim=True) + eps)
    5. return (normed.to(x.dtype) * weight)
    6. def vocab_parallel_loss(hidden, weight_t, labels, group):
    7. """Split the vocabulary along rows and compute cross-entropy in blocks to avoid building the full logits."""
    8. losses = []
    9. for w_shard, offset in zip(weight_t, group.offsets):
    10. logits = hidden @ w_shard # Logits on the current vocabulary shard
    11. losses.append(cross_entropy_block(logits, labels, offset))
    12. return reduce_loss(losses) # Reduce within the vocabulary-parallel group

    3.3 Memory optimization and parallelism strategy: there is no single right answer

    • Activation recomputation: Keep only some intermediate activations and recompute the rest during the backward pass, trading extra compute for memory.
    • Sequence parallelism: Split operations such as normalization and Dropout along the sequence dimension to share the activation overhead of long visual sequences.
    • Combining parallelism: When FSDP is combined with pipeline and tensor parallelism, the sharding strategy and the gradient accumulation cycle must be tuned jointly to avoid frequently re-gathering parameters across the pipeline.

    The choice of parallelism strategy depends on model structure, sequence length, and cluster interconnect bandwidth. On platforms with limited interconnect bandwidth, raising compute density and reducing cross-node communication is usually more worthwhile than blindly adding parallelism dimensions.

    3.4 Sharding scheduling and gradient synchronization: the core of the training pipeline

    A key design of FSDP2 is to fully shard parameters within each shard group and to distinguish data parallelism, tensor parallelism, pipeline parallelism, and other dimensions via a DeviceMesh.

    A full iteration proceeds as follows:

    1. Forward pass: Before a module executes, AllGather collects the parameter shards and reconstructs the full parameters; once the module finishes, they are released immediately, keeping memory usage on par with a single module’s size.
    2. Backward pass: Collect the required parameters again and combine with activation recomputation to compute gradients.
    3. Gradient reduction: ReduceScatter directly produces gradients already sharded, matching the parameter shard layout one-to-one.
    4. Optimizer update: Each shard owner updates only its local parameters, so memory overhead drops as the number of shards grows.
    1. # Illustrative pseudocode: an FSDP-style training iteration
    2. for step, batch in enumerate(loader):
    3. with autocast(dtype=bf16):
    4. out = model(batch) # Forward: AllGather parameter shards on demand
    5. loss = compute_loss(out, batch.labels)
    6. loss.backward() # Backward: ReduceScatter synchronizes gradient shards
    7. clip_grad_norm_(model.parameters(), max_norm)
    8. optimizer.step() # Each shard updates only its local parameters
    9. optimizer.zero_grad(set_to_none=True)
    10. if step % log_interval == 0:
    11. log_metrics(step, loss, throughput) # Report training metrics such as throughput and memory

    Cross-hardware numerical consistency verification: Once the sharding scheme is in place, run a controlled experiment with a “fixed random seed + small-scale data” to check the results. First run the same code with both the general reference implementation and the target implementation, then compare the loss curve and gradient norm step by step to ensure the adaptation has not changed the mathematical semantics of training.

    3.5 Fault recovery and observability

    Trillion-parameter models often train for weeks, and hardware failures, node dropouts, and job preemptions are almost inevitable:

    • Checkpoints: Save sharded-format checkpoints (local shards or globally aggregated), writing them regularly to a highly reliable parallel file system or object storage. Record the current step, data-read position, and random-number state to guarantee that the data order and training trajectory stay consistent after recovery.
    • Elastic fault tolerance: With a job orchestration system that supports elastic scheduling, automatically rebuild the process group after a failure and resume from the most recent checkpoint.
    • Observability: Collect logs and metrics into a unified logging service and monitoring/alerting system, and set threshold alerts for training throughput, memory watermark, per-step time, and communication wait time to catch performance regressions in time.

    4. Implementation Steps and Common Issues

    Implementation steps

    1. Establish a baseline: On general hardware, run the full pipeline with a small-scale proxy model, recording the loss curve and per-step time as a reference for later alignment.
    2. Validate hardware and software stack: Check that driver, runtime, operator library, and communication library versions match, and use a collective-communication benchmark to verify bandwidth and correctness.
    3. Validate module by module: Run forward and backward passes separately for the vision encoder, projection layer, and language backbone in that order to pinpoint the problematic module.
    4. Run a small-scale end-to-end trial: Run the complete training pipeline on a few nodes to verify sharding, gradient synchronization, and checkpoint recovery.
    5. Scale up gradually: Expand the node count and parallelism dimensions level by level, continuously optimizing with profiling tools.

    Common issues

    Symptom Common cause Approach
    Out of memory early in training Parameters not gathered or resharded on demand; activations not recomputed Enable post-forward resharding and apply activation recomputation to modules with repeated computation
    Throughput drops as node count grows Communication fails to overlap with computation; insufficient cross-node bandwidth Tune the bucket strategy and overlap depth, and place high-communication-density parallelism within a node where possible
    Loss curve deviates from the reference implementation Operator precision differences; inconsistent data order Compare operator precision one by one, and verify the data-read order and random-number state
    Sudden interruption after long training Hardware failure or job preemption Increase checkpoint frequency and enable elastic recovery and automatic rescheduling

    5. Deployment and Operations on the Cloud

    For most teams, there is no need to build the entire underlying hardware and software environment. On cloud platforms such as Baidu AI Cloud, this adaptation experience can be applied to general cloud product capabilities:

    • Training job orchestration: With container services and elastic compute resources, organize distributed training jobs by node count, interconnect bandwidth, and memory specifications, with support for automatic rescheduling after failures.
    • Data and checkpoint storage: Massive multimodal corpora and checkpoints can be stored in object storage or a parallel file system, paired with data caching to accelerate reads.
    • Observability: Combine logging services, monitoring and alerting, and tracing capabilities to continuously observe training throughput and hardware metrics.
    • Security and compliance: Use data encryption, access control, and auditing capabilities to safeguard the full lifecycle of training data.

    6. Summary

    The fact that a 2.8 trillion-parameter open-source multimodal model can complete training adaptation on domestic compute shows that hardware-software collaboration already has the foundational capability to support ultra-large-scale multimodal training. For developers and enterprises, what matters more is the methodology behind the adaptation: using sharding and parallelism design to resolve memory and communication bottlenecks, using per-operator verification to guarantee numerical consistency, and using checkpoints and observability to keep long-cycle training stable—ultimately encapsulating hardware differences at the framework layer so that model development can focus on the model and data themselves.