Adapting Trillion-Parameter Multimodal LLMs to Domestic AI Accelerators: A Practical Engineering Walkthrough
A multimodal large model of roughly 2.8 trillion parameters was recently adapted for training on a domestic AI accelerator and its proprietary software stack. This article walks through the full training pipeline of that adaptation—sharded weight loading, hybrid parallelism and shard scheduling, memory budgeting and activation recomputation, mixed precision, computation–communication overlap, the multimodal data pipeline, and checkpointing with fault tolerance. It abstracts a reusable engineering methodology from the case, presents the key stages in pipeline order, and offers troubleshooting guidance for training, continued training, and retraining ultra-large multimodal models on non-mainstream hardware ecosystems.
1. Background: Why Adaptation Is the Critical Step for Trillion-Parameter Deployment
A multimodal large model with roughly 2.8 trillion parameters was recently released to the open-source community. A domestic GPU vendor completed the training adaptation of this model on its flagship train-and-inference compute card and proprietary software stack. The adaptation built a native Fully Sharded Data Parallel (FSDP) multimodal training path, connecting the entire training pipeline from model loading and shard scheduling to gradient synchronization.
For developers and enterprise users, the significance of this kind of work goes beyond “getting one more model to run.” It validates a general path: whether ultra-large multimodal models can be trained, continuously trained, and retrained on a non-mainstream hardware ecosystem. Building on this case, this article abstracts a reusable engineering methodology, walks through the key stages in pipeline order, and provides troubleshooting guidance for common problems.
1.1 Scale characteristics of trillion-parameter multimodal models
| Dimension | Typical characteristics | Main impact on adaptation |
|---|---|---|
| Parameter scale | Hundreds of billions to trillions; a single copy of the weights reaches the TB range | Cannot fit on a single machine; sharded loading and sharded storage are required |
| Model structure | Sparse structures are common, such as Mixture-of-Experts (MoE); multimodal models also include image, video, and audio encoders plus cross-modal fusion layers | Many parallelism dimensions and diverse operators; routing and expert load must be handled specifically |
| Sequence characteristics | Text tokens and tokens produced by images and videos differ greatly in length | Variable-length sequences and load imbalance require sequence/context parallelism |
| Training data | Web pages, code, image-text pairs, video-text pairs, and other multi-source, multimodal data | Complex preprocessing; high demands on I/O throughput and sampling balance |
| Optimizer | Usually first-order and second-order momentum methods | Optimizer states are one of the largest memory consumers and must be sharded |
1.2 What “adaptation” really means: four types of alignment
From an engineering perspective, adaptation is not simply swapping in a different card and reinstalling drivers. It is about producing a numerically equivalent and performance-usable implementation of the same mathematically defined model across different hardware and software ecosystems. The core can be summarized into four types of alignment:
- Operator semantics alignment: Operators on the proprietary card produce results consistent with the reference implementation, including boundary behavior such as mask positions, padding values, and special-value handling.
- Numerical alignment: Differences introduced by the mixed-precision strategy, accumulation order, and reduction methods stay within a controllable range.
- Parallelism alignment: The various sharding schemes preserve the mathematical equivalence of the forward pass and the backward gradients.
- Performance alignment: Throughput approaches the hardware’s theoretical capability at an acceptable overhead.
If any one of these is not aligned, training may “run but not learn,” or “run but too slowly to be usable.”
1.3 A layered view of adaptation work
Adaptation is a systems engineering effort that typically spans the following layers. Diagnosing layer by layer is far more efficient than blind parameter tuning:
- Hardware layer: compute throughput, memory capacity and bandwidth, inter-card and inter-node interconnect bandwidth, and network topology.
- Base software layer: drivers and runtime, operator libraries and the compilation toolchain, and the collective communication library.
- Framework layer: mixed precision, distributed parallelism strategy, native sharding and communication primitives, and checkpointing and fault tolerance.
- Model layer: weight format conversion, sharding rules, and model structure rewriting.
- Data layer: multimodal preprocessing, sampling and packing, prefetching and caching.
- Validation layer: layer-by-layer numerical comparison, loss-curve alignment, and performance and memory profiling.
2. Stage 1: Sharded Weight Loading
2.1 Why not load into memory and then shard
If 2.8 trillion parameters are stored in BF16, a single copy of the weights is about 5.6 TB, exceeding the memory capacity of the vast majority of training nodes. Reading the full weights into memory before sharding would make even the loading stage impossible to complete. The correct approach is to read slices directly from the file according to the sharding plan:
- Read metadata: Parse the weight index, including parameter names, shapes, data types, and file offsets.
- Compute the shard for this card: Based on the parallelism strategy, compute the parameter range each rank is responsible for.
- Load slices on demand: Read only the byte ranges owned by this rank, minimizing redundant reads across nodes and disks.
- Layout conversion: Complete transposition, reordering, or type conversion for parameters that need it during loading.
- Write to device memory: Write into device memory in the shard layout the framework requires.
# Illustrative pseudocode: read only the shard each rank needs directly from the weight file, following the parallel sharding plandef load_shard(rank, meta, shard_plan):state = {}for name, piece in shard_plan.slices_of(rank): # iterate only over shards owned by this rankbuf = mmap_read(meta.file_of(name), # memory-mapped read to avoid loading the whole weight set into memorypiece.offset, piece.length)tensor = reshape_and_cast(buf, piece.shape, target_dtype=bf16)if piece.parallel_dim is not None:tensor = relayout_for_parallel(tensor, piece.parallel_dim) # layout conversion such as transpose/reorderstate[name] = tensormodel.load_state_dict(state, assign=True) # bind device memory directly, avoiding an extra full copy
Two further points matter in practice:
- Consistency checks: Large-model weights are often released as multiple shard files. Before loading, verify the shard count, index integrity, and checksums to avoid “reading halfway through” failures that surface as early training anomalies.
- Loading performance: Use techniques such as multi-process or asynchronous prefetching, memory-mapped reads, and caching of hot data to shorten startup time. Startup time directly affects experiment iteration speed.
2.2 Weight layout and structure mapping
- Tensor parallelism: Linear-layer weights are usually split along the output or input dimension; loading must slice the contiguous weights by rule into each tensor-parallel rank.
- Vocabulary parallelism: The input token embeddings and the output language-model head are often split by vocabulary, and cases of padded vocabularies and tied weights must be handled.
- Expert parallelism: MoE structures contain many experts that must be mapped to different ranks, and the routing (gating) weights must be checked to remain intact.
- Multimodal encoders: The weight structures of vision and audio encoders differ substantially from the backbone, so they need independently defined sharding rules. The fusion modules often sit between the backbone and the encoders, and sharding must keep the front and back dimensions consistent.
3. Stage 2: Hybrid Parallelism Strategy and Shard Scheduling
3.1 Main parallelism dimensions
| Parallelism dimension | Sharding target | Primary communication primitives | Communication characteristics | Suitable scenarios |
|---|---|---|---|---|
| Data parallelism (DP) | Training data | Gradient all-reduce | Volume about 2× the parameter count; can overlap with backward compute | Scaling global batch, raising throughput |
| Fully Sharded Data Parallelism (FSDP) | Data, parameters, gradients, optimizer states | All-gather (parameters), reduce-scatter (gradients) | Volume about 2× the parameter count; once each in forward and backward | When a single card cannot hold the full model; very large parameter counts |
| Tensor parallelism (TP) | Weights within a single layer | All-reduce, or reduce-scatter/all-gather combinations | Both forward and backward require communication; on the critical path; demands low latency and high bandwidth | Reducing per-layer memory and per-card compute |
| Sequence/context parallelism (SP/CP) | Activations and attention along the sequence dimension | All-gather, reduce-scatter, point-to-point | Tightly coupled to the attention implementation | Long sequences, especially long multimodal video contexts |
| Pipeline parallelism (PP) | Model stages split by layer | Point-to-point send/receive | Small communication volume; pipeline bubbles exist | Cross-node scaling, reducing per-node memory pressure |
| Expert parallelism (EP) | Different experts | All-to-all | Two all-to-alls; sensitive to the network | Mixture-of-Experts models |
3.2 Strategy selection principles
Trillion-parameter models rarely use a single parallelism method; the common approach is to combine several:
- Partition communication domains by bandwidth: Tensor and sequence parallelism sit on the critical path of the forward and backward passes and should be confined to the intra-node high-bandwidth interconnect where possible. FSDP, pipeline, and expert parallelism can scale across nodes to relax inter-node network requirements.
- Memory balance: The product of the dimensions forms the global parallelism degree, which combined with the training-data partition yields the global batch. After sharding, each card should retain sufficient headroom—20% to 30% is recommended—for communication buffers, memory fragmentation, and temporary peaks.
- Match communication to topology: Parallel groups should follow the “intra-node first, same-switch first” principle so that high-frequency communication completes over fast links.
3.3 FSDP scheduling mechanism
FSDP shards parameters, gradients, and optimizer states across the data-parallel group. When computing a given layer, it temporarily gathers that layer’s full parameters on demand and releases them immediately after use. During the backward pass it applies reduce-scatter to the gradients, so each rank keeps only the gradients it is responsible for and updates only that portion of the parameters. This “gather when needed, discard when done” approach makes per-card memory demand decrease roughly linearly with data-parallel size.
Two scheduling details are worth attention:
- Gather granularity: Gather at the granularity of a single Transformer layer or module. Too fine a granularity increases the number of communications and launch overheads; too coarse a granularity raises the memory peak.
- Gradient accumulation: With gradient accumulation, trigger gradient reduce-scatter only during the backward pass of the last micro-batch; the intermediate micro-batches accumulate gradients locally, significantly reducing communication count.
# Illustrative config: hybrid parallelism with Fully Sharded Data Parallelparallel:tensor_parallel: 8 # intra-node tensor parallelismpipeline_parallel: 4 # cross-node pipeline parallelismexpert_parallel: 8 # expert parallelism, only for Mixture-of-Experts structures# global parallel degree = TP × PP × EP × DP, where DP is the data-parallel (including FSDP) sizefsdp:sharding: full # shard parameters, gradients, and optimizer states entirelywrap_unit: transformer_layer # use the Transformer layer as the sharding unitbucket_mb: 200 # communication bucket size; tune against measured bandwidthlimit_all_gathers: true # limit in-flight all-gathers to control peak memorycheckpoint:recomputation: selective # selective activation recomputationprecision:compute: bf16master_weights: fp32
4. Stage 3: Memory Budgeting and Activation Recomputation
4.1 The memory ledger
Taking mixed-precision training as an example, a typical first-order and second-order momentum optimizer keeps an FP32 copy of the parameters plus the first- and second-order moments. Memory per parameter can therefore be roughly estimated as:
- Parameters (BF16): 2 bytes
- Gradients (BF16): 2 bytes
- FP32 parameter copy: 4 bytes
- First-order momentum (FP32): 4 bytes
- Second-order momentum (FP32): 4 bytes
That is about 16 bytes per parameter, consistent with the rule of thumb of “16× the parameter count.” For 2.8 trillion parameters, the model states total roughly 44.8 TB. Even fully sharded across 128 cards, each card still carries about 350 GB—far exceeding a single card’s memory capacity. This is exactly why pipeline parallelism, tensor parallelism, and even optimizer-state offloading must be stacked on top.
Memory must also reserve headroom for:
- Activations: proportional to micro-batch size, sequence length, and number of layers.
- Communication buffers: temporary buffers for parameter all-gather and communication buckets.
- Framework and operator overhead: CUDA context, operator workspaces, and memory fragmentation.
4.2 Activation recomputation
Activation recomputation (also called gradient checkpointing) stores only a few activations at checkpoint points and recomputes intermediate results during the backward pass—trading compute for memory. Three engineering recommendations:
- Prefer selective recomputation: Recompute the memory-heavy parts (such as intermediate attention results and intermediate feed-forward layers) and keep the low-benefit, low-cost-to-store parts (such as normalization-layer outputs).
- Keep randomness consistent: If the model uses random operators such as dropout, recomputation must reproduce the forward pass’s random-number state, or the gradients will be incorrect.
- Watch the multimodal branches: At high image resolutions, the vision encoder’s intermediate activations can be larger than those of the text backbone and are easy to overlook; budget for them separately.
5. Stage 4: Mixed Precision and Numerical Stability
BF16 has the same number of exponent bits as FP32 but fewer mantissa bits, giving a dynamic range close to FP32, so it usually does not need loss scaling like FP16. This makes it the mainstream choice for trillion-parameter training. However, “training with BF16” does not mean “computing everything in BF16.” The usual principles:
- Compute-intensive operators such as linear layers and attention run in BF16.
- Accumulation-sensitive operations such as normalization layers, residual accumulation, and loss computation are done in FP32.
- The optimizer holds FP32 parameter copies and FP32 moments, and parameter updates happen in FP32.
- Gradient reduction and accumulation use FP32 to reduce rounding error from summing large numbers of gradients.
- MoE routing-layer gating scores are best computed in FP32 to avoid ranking jitter near boundaries.
Custom operators must integrate correctly with the framework’s automatic mixed-precision mechanism: explicitly list which operators support half precision and which must fall back to FP32, so that precision is not unintentionally lowered without anyone noticing. For a train-and-inference card, the numerical behavior validated on the training side should carry over smoothly to the inference side, reducing precision drift between training and deployment.
6. Stage 5: Overlapping Computation and Communication
Whether FSDP’s communication overhead can be hidden behind computation directly determines scaling efficiency. Common techniques:
- Dual compute-stream design: One stream runs compute such as matrix multiplications while another runs collective communication, with event-based synchronization of dependencies to overlap forward/backward compute with parameter all-gather and gradient reduce-scatter.
- Gradient bucketing: Divide gradients into buckets so that a bucket triggers reduce-scatter as soon as its gradients are computed in the backward pass, rather than waiting for the entire backward pass to finish.
- Backward priority: Let layers that finish first in the backward pass trigger communication first, so communication starts earlier and the overlap rate rises.
- Limit in-flight requests: Cap the number of concurrent parameter all-gathers to avoid large temporary buffers raising the memory peak.
- Pipeline scheduling: Split the layer counts of each stage sensibly and set the micro-batch count to compress pipeline bubbles.
When troubleshooting, first use a profiling tool to separate “compute time” from “communication wait time.” If communication wait dominates, prioritize checking whether the parallel-group partition matches the topology and whether bucket sizes are reasonable, rather than blindly adding cards.
7. Stage 6: The Multimodal Data Pipeline
Trillion-parameter multimodal training places three demands on the data pipeline:
- High-throughput preprocessing: Keep CPU-side operations—image decoding, resizing, cropping, video frame extraction, audio resampling, and spectrogram transforms—in place, using multi-process or dedicated services for preprocessing plus multi-threaded prefetching so data preparation overlaps with GPU compute.
- Variable-length sequence handling: After modality encoding, the token counts of different samples differ greatly. Length-based bucketing and sample packing can raise the effective compute ratio, but attention masks must stay correct to prevent cross-sample “leakage.”
- Balanced sampling: Multimodal data varies greatly in file size and decode cost. If a rank keeps drawing high-cost samples, it becomes the weak link. Balance sampling by estimated decode cost or token count, and periodically measure each rank’s data time.
8. Stage 7: Checkpoint Resume and Fault Tolerance
A single full training run of a trillion-parameter model can last weeks or even months, so fault tolerance directly determines whether training finishes.
- Complete checkpoints: In addition to model parameters, save optimizer states, learning-rate scheduler states, data-loader progress, and random-number states; otherwise the loss curve will jump after resuming.
- Sharded saving and asynchronous write-out: Each rank writes its own shard in parallel, overlapping the save with training compute to shorten downtime.
- Resume consistency: On resume, redistribute parameters and optimizer states according to the parallel sharding plan. If the parallel configuration changes, support resharding or provide a conversion tool.
- Fast fault localization: Combine communication timeouts, rank heartbeat monitoring, and log services to quickly identify card failures, slow nodes, and network jitter, avoiding long idle waits.
9. Validation Methods: From Layer-by-Layer Comparison to Long-Run Stability
After adaptation, one question must be answered: did it “learn correctly”? Validate progressively through the following levels:
- Operator-level comparison: Using FP32 as reference, run random-input tests on newly added or rewritten key operators and check maximum absolute and relative error.
- Single-step training comparison: Fix the data order and random seed, run one step on the same hardware via both the FSDP path and a “single-card, single-process, full-parameters” path, and compare loss and gradient norm.
- Small-model curve alignment: Train a small, isomorphic model on the reference hardware to obtain a loss baseline, then reproduce it on the new card with identical hyperparameters and check whether the curves essentially overlap.
- Long-run stability observation: Continuously monitor loss, gradient norm, learning rate, and throughput. When loss shows sustained spikes or the gradient norm goes abnormal, use log services to determine whether the cause is data, operators, or communication.
It is worth emphasizing that the floating-point accumulation order differs across hardware and parallelism strategies, so loss cannot be bit-identical. Acceptance should use tolerance-based statistical comparison, not a demand for exact equality.
10. Common Problems and Troubleshooting
| Symptom | Possible cause | Troubleshooting direction |
|---|---|---|
| Out-of-memory during loading | Reading the full weights into memory before sharding | Read slices directly from the file per the shard plan; verify the shard plan is correct |
| Out-of-memory in early training | Parallelism config not taking effect, oversized shard unit, too many in-flight gathers | Print per-rank parameter counts, reduce shard granularity, enable the in-flight request limit |
| Multiple cards stuck in collective communication | Inconsistent rank call order, inconsistent sharding rules, a rank exiting abnormally | Align code branches, enable communication timeouts and debug logs, check for slow nodes |
| Abnormal loss decrease or NaN | Normalization/loss not in FP32, gradients not correctly reduced, inconsistent recomputation randomness | Compare activations and gradients layer by layer, unify random-number state management |
| Throughput far below expectations | No computation/communication overlap, buckets too small, data preprocessing becoming the bottleneck | Measure compute, communication, and data-wait time separately, then optimize item by item |
11. Implementation Recommendations and Summary
- Progress in stages: Follow the order “single-card operator validation → single-node parallelism validation → small-scale convergence validation → large-scale long-run training,” with clear acceptance criteria at each stage so problems are not masked by scale.
- Observability first: From day one, integrate log services and monitoring/alerting, and collect loss, gradient norm, memory, throughput, and communication-wait metrics uniformly to form a baseline.
- Pin down by algorithm, track problems as a checklist: Record missing operators, precision deviations, and performance bottlenecks as a checklist, and close the loop with the hardware and software-stack providers to avoid the same problems recurring across different models.
- Codify standardized processes: Turn sharded weight loading, parallelism-strategy templates, mixed-precision conventions, and convergence validation into standard procedures that can be reused for future adaptations of similar models.
This adaptation case reveals an important pattern: competition in trillion-parameter multimodal models has extended from raw “model scale” to the collaborative engineering capability across “model–framework–hardware.” Whoever can maintain training efficiency and convergence stability across more diverse compute ecosystems will convert frontier model capabilities into real business value faster. For enterprise users running on platforms such as Baidu AI Cloud, the same methods apply: use object storage to host massive weights and multimodal data, use a container platform to elastically orchestrate training jobs, and combine logging with monitoring and alerting to build an observability system—enabling large-model training to proceed reliably across diverse compute resources.
