Engineering Practice for Adapting Domestic AI Accelerators to Trillion-Parameter Multimodal Model Training
This article presents a real-world engineering practice of adapting a domestic flagship AI training/inference accelerator card to train a trillion-parameter multimodal model with mixture-of-attention and mixture-of-experts (MoE) architecture. It details the key adaptation points, distributed training design, validation results from a 16-card cluster, and four optimization directions that move the training pipeline from basic functionality to production-grade efficiency. The article also summarizes reusable methodologies for validating training correctness and scaling up on domestic accelerators.
Background: New Challenges for the AI Computing Foundation in Ultra-Large Multimodal Models
With the evolution of large model technology, the industry has seen the emergence of native multimodal models with total parameter counts reaching trillions and support for context windows of up to one million tokens. These models typically employ hybrid attention mechanisms and mixture-of-experts (MoE) architectures, combining language understanding with visual understanding, tool calling, and other composite capabilities. However, this leap in capability also means an exponential increase in training complexity.
From an engineering perspective, training such models faces three core challenges:
1. Operator diversity. The model contains dynamic sparse attention, gated attention, expert routing, and other computation modes simultaneously. Each mode imposes different requirements on operator implementation. For example, dynamic sparse attention requires efficient support for irregular Key/Value retrieval paths, which cannot be directly reused by traditional dense attention operators.
2. Extreme memory pressure. Even with parameter sharding, a model with trillions of parameters consumes a substantial amount of memory per GPU. Together with activations, gradients, and optimizer states, memory management strategy directly determines whether training can run at all.
3. Complexity of multi-GPU and multi-node communication. Expert routing in MoE architectures introduces AllToAll communication, while joint image-text training couples the data flows between the visual and language branches. Both efficiency and correctness of cross-GPU and cross-node communication become critical paths.
This article is based on a real engineering adaptation case, breaking down how a domestic flagship training/inference accelerator card handled the training adaptation for such a model, and offers reusable methodologies.
Model Architecture Characteristics and Adaptation Entry Points
The target model is an open-weight native multimodal model with approximately 2.8 trillion total parameters and a maximum context of 1 million tokens. Its architectural features can be summarized in four points:
- Hybrid attention mechanism: combines dynamic sparse attention with gated attention to balance computational efficiency and expressive power in long-context scenarios.
- MoE (Mixture-of-Experts) architecture: each layer contains multiple routed experts, activated via Top-K routing, decoupling parameter scale from computational load.
- Visual understanding capability: a complete vision tower paired with a cross-modal projection module aligns image embeddings to the language model’s representation space.
- Dynamic computation graph characteristics: expert routing and sparse retrieval introduce data-dependent dynamic behavior, which is unfriendly to static graph optimization and pre-allocated memory strategies.
Given these features, the adaptation work should center on four modules: attention computation, dynamic routing, visual encoding, and cross-modal projection. The core approach is not simply replacing individual operators, but integrating these modules into a complete forward, backward, and parameter update pipeline to ensure an end-to-end training loop.
Distributed Training Design
Preserving the Native Pipeline of Fully Sharded Data Parallelism
In engineering practice, a common mistake is to significantly refactor the training framework code just to fit new hardware. A more robust approach is to preserve the native pipeline of the upper-level training framework as much as possible. By using a fully sharded data parallel strategy, the model parameters, gradients, and optimizer states are distributed across GPUs, keeping single-GPU memory pressure within acceptable limits.
The benefit is that the training framework side (data loading, optimizer scheduling, checkpointing, etc.) remains aligned with the mainstream ecosystem, while hardware-specific differences are confined to the operator and communication library layers, significantly reducing long-term maintenance costs.
Cross-GPU and Cross-Node Communication
Cross-GPU and cross-node communication is handled by the vendor-provided collective communication library. In MoE training, the communication library must support two modes:
- Data-parallel gradient aggregation: typically AllReduce operations.
- Expert-parallel token dispatch and collection: typically AllToAll operations, where communication volume varies dynamically with the number of experts and routing policy.
These two modes have different sensitivities to bandwidth and latency, and communication scheduling needs to be optimized accordingly.
Test Configuration and Training Validation Results
Test Environment
The validation used two servers with a total of 16 accelerator cards forming the training cluster. To focus on functional correctness of the training pipeline, the model was configured in a trimmed form: 13 language backbone layers, 16 routed experts (Top-8 routing), while keeping the full 27-layer vision tower and the cross-modal projection module.
Training data was a public image-text QA dataset. Key hyperparameters:
| Parameter | Value |
|---|---|
| Global batch size | 16 |
| Sequence length | 1024 |
| Training processes | 16 |
| Consecutive optimizer steps | 400 |
Convergence and Stability Indicators
All 16 training processes completed 400 consecutive optimizer steps without numerical overflow or abnormal interruption. The loss trajectory clearly reflects the health of the training loop:
- Training loss: mean value from step 21 to 70 was 8.9365, dropping to 2.1802 over the final 50 steps, showing steady convergence.
- Validation loss: 6.5297 at step 100, down to 4.6873 at step 400, indicating improved generalization.
- Peak memory: device sampling peak was 44.80 GiB, confirming that parameter sharding and activation management effectively controlled single-GPU memory usage.
Gradient Verification of Visual Branch Participation
A subtle but important issue in multimodal training is whether the visual branch is actually participating in training. If the cross-modal alignment logic has defects, image data may simply “flow through” the model without producing real gradient updates; the model appears to be training but has effectively zero visual capability.
To address this, the technical team performed layer-by-layer gradient checks on the visual branch, verifying that the image embedding layer, the first and last layers of the vision tower, and the cross-modal projection module all received non-zero gradients and updated their parameters accordingly. This validation method is worth promoting in all multimodal adaptation efforts — use gradients as evidence, not data flow.
It should be noted that this validation used a randomly initialized trimmed configuration, not a full-scale pre-training run. The goal was to verify functional correctness and stability of the training loop, laying the foundation for subsequent larger-scale training.
Key Optimizations: From “Runs” to “Runs Well”
After completing basic pipeline adaptation, further performance and scaling optimizations were organized around four directions:
1. Parameter sharding coordinated with expert parallelism. When MoE experts are simultaneously split by parameter sharding and expert parallelism, the communication domains of these two distributed strategies need fine-grained separation to avoid communication conflicts and redundant synchronization.
2. Parameter prefetching and gradient communication scheduling. Overlap computation and communication by prefetching required parameter shards during the forward phase, and staggering gradient communication peaks during the backward phase to reduce blocking of the compute pipeline.
3. High-performance sparse attention operators. Dedicated operators are developed for dynamic sparse retrieval attention, optimizing irregular attention masks and Key/Value index lookups at the low level, avoiding degradation to inefficient token-by-token computation.
4. Chunked cross-entropy (Chunk Loss) computation. Loss computation with a large vocabulary causes enormous activation memory on logits. Chunked computation of cross-entropy splits the memory peak across multiple computation blocks. This optimization was already enabled in the 400-step test, and the other three items were also adapted and are ready to support larger training configurations.
The following pseudo-code illustrates the core idea of Chunk Loss:
def chunked_cross_entropy(hidden, weight, targets, chunk_size):total_loss, total_count = 0.0, 0for h_chunk, t_chunk in split(hidden, targets, chunk_size):logits = h_chunk @ weight.T # compute logits in chunksloss = cross_entropy(logits, t_chunk, reduction="sum")total_loss += losstotal_count += t_chunk.numel()return total_loss / total_count
Methodology Summary
Looking back at the entire adaptation process, four lessons can be extracted that are broadly applicable to large-model training on domestic accelerators:
- Preserve the native pipeline of the upper-level framework, localizing hardware differences to the operator and communication layers to reduce long-term maintenance costs.
- Validate functional correctness before pursuing scale and performance — a trimmed configuration that quickly completes 400 consecutive steps is the lowest-risk validation path.
- Use gradient checks to confirm that multimodal branches actually participate in training, avoiding the hidden defect of “data flows but no learning.”
- Optimize in layers — from pipeline bring-up, to communication scheduling, operator optimization, and memory optimization — gradually building a capability stack that supports full-scale training.
For enterprise users, this adaptation practice also highlights that when selecting AI computing infrastructure, in addition to single-card compute metrics, one should evaluate the completeness of the software stack, compatibility with distributed training ecosystems, and the responsiveness of adaptation to cutting-edge model architectures. Whether building an in-house cluster or leveraging cloud-based container platforms and monitoring/alerting capabilities, a training solution that has been validated on real, large-scale models is key to converting computing investment into model capability.
