Adapting Domestic AI Accelerators for Trillion-Parameter MoE Multimodal Training

    This article examines why adapting domestic AI accelerators for trillion-parameter Mixture-of-Experts (MoE) multimodal training is harder than comparing peak single-GPU compute. It presents a practical engineering approach based on scaled-down configurations, key distributed training components, memory budgeting, numerical stability checks, and a pre-full-scale acceptance checklist.

    Adapting Domestic AI Accelerators for Trillion-Parameter MoE Multimodal Training

    Why Training Pipeline Adaptation Is Harder Than Single-GPU Peak Performance

    When discussing whether domestic AI accelerators can support large-model training, a common misconception is to equate “peak single-GPU compute” with “training capability.” For trillion-parameter models, MoE architectures, and native multimodal models, the real difficulty is not running one matrix multiplication on one GPU. The challenge is whether the entire distributed training pipeline can run stably, reproducibly, and controllably during scaling.

    The main adaptation difficulties fall into three areas:

    • High architectural complexity: MoE uses dynamic sparse activation. Each forward pass activates only a subset of experts, such as Top-8 routing. This creates irregular compute, communication, and load distribution. Native multimodal training adds a vision tower and cross-modal projection layers, so gradients flow back and forth between language branches, vision branches, and modal alignment layers.
    • Communication and memory bottlenecks: Experts are distributed across devices, making All-to-All communication a major overhead. At the same time, parameters, gradients, optimizer states, visual activations, and cross-modal intermediate representations accumulate, causing memory pressure to grow nonlinearly.
    • Fragile numerical stability: Mixed attention, dynamic routing, and low-precision computation can cause numerical overflow, gradient explosions, or routing instability during backpropagation. In multi-GPU environments, a NaN/Inf or synchronization failure on one device can block or interrupt training.

    Therefore, to judge whether a domestic accelerator is capable of large-model training, the key question is not just whether it can run a workload. It is: Can the entire distributed training pipeline run stably and reproducibly while remaining controllable during scaling?

    Common questions

    • Can domestic GPUs train trillion-parameter MoE models?
      Peak compute alone is not enough. You also need operator coverage, collective communication, memory bandwidth, sharding strategy, and numerical stability. Running the pipeline is only the first step. Stable scaling is the critical part.

    • How should scaled-down configurations be designed?
      Preserve structural components such as MoE routing, vision towers, and cross-modal projection modules. Reduce layers, number of experts, and sample count. Focus on validating the pipeline rather than chasing convergence metrics.

    • How do you troubleshoot collective communication failures?
      First run a single-step communication benchmark. Then check topology, network interfaces, timeout settings, and logs. If necessary, isolate the issue step by step: within a single machine, between machines, and across node boundaries.

    Scaled-down configuration: validate the pipeline before pursuing scale

    For trillion-parameter models, full-scale pretraining is expensive, hard to debug, and slow to fail-fast. In engineering practice, a scaled-down configuration is commonly used as the first validation step. Its purpose is not merely to train a smaller model. It is to preserve structural risk points while reducing scale.

    The examples below are internal method examples. They are provided to illustrate the validation approach and do not constitute a commitment regarding the performance or adaptation capability of any specific domestic accelerator. When reproducing the process, replace them with actual hardware, software versions, datasets, and model configurations.

    1. Internal example configuration

    Item Example configuration
    Hardware One node with 8 domestic GPUs, 64 GiB memory per GPU
    Software Training framework 1.6, collective communication library 2.0, driver 1.7
    Model 13-layer language backbone, 16 routed experts, Top-8 activation
    Multimodal Full vision tower and cross-modal projection modules retained
    Dataset Image-text question-answering sample dataset, about 100,000 samples
    Training steps 600 steps
    Peak memory About 44.8 GiB
    Measurement Cross-check between the training framework’s memory counter and system memory monitoring

    The design logic of this scaled-down configuration includes three points:

    1. Preserve structure rather than scale: MoE routing logic, dynamic sparse operators, and hybrid attention structures must be genuinely present. Otherwise, key risks cannot be validated.
    2. Preserve the modules most prone to failure: Vision branches, cross-modal projection layers, routing scores, and expert aggregation are common sources of numerical instability and should not be casually removed.
    3. Shorten the feedback loop: After reducing the scale, hundreds of steps can be validated in a smaller configuration, quickly exposing operator, communication, memory, and numerical issues.

    2. Example validation metrics

    A scaled-down validation run can focus on the following metrics:

    1. Training loss: 8.93 (early segment average) → 2.18 (late segment average) # Convergence trend
    2. Validation loss: 6.53 → 4.69 # Generalization health
    3. Peak memory: ~44.8 GiB # Within budget
    4. Vision branch: Participating in parameter updates (not frozen) # Multimodal pipeline is genuinely running
    5. Gradient norm: Stable downward trend, no persistent spikes # Numerical stability is controllable

    It is important to emphasize: Convergence in a scaled-down configuration can only show that training functionality, loss trends, and pipeline connectivity are basically correct. It is not equivalent to successful full-scale pretraining. Full-scale training can amplify communication, memory, parallel strategy, and numerical sensitivity issues. Therefore, step-by-step scaling and rollback mechanisms must be in place.

    Key engineering elements

    The decisive factor is whether the pipeline can be established through systematic coordination of the following engineering areas.

    1. MoE sparse routing and hybrid attention operators

    The weak point in domestic accelerator adaptation is often not general matrix computation, but the forward and backward implementations of newer operators. Dynamic sparse attention, expert routing, and cross-modal fusion modules require focused validation:

    • Are routing scores and Top-k selection differentiable in the forward pass and correct in the backward pass?
    • Are expert dispatch/combine operations numerically close to the reference implementation?
    • Are softmax, normalization, and residual connections stable under mixed precision?
    • Do MoE auxiliary losses participate in gradient backpropagation, and are they tracked separately from the main loss?
    • Is expert load severely skewed? Does routing instability occur?

    The acceptance criteria should be strict: Operators should not only align in the forward pass; their backward gradients should also match the reference implementation within tolerance. For fp16/bf16 training, relative error and maximum error thresholds can be defined. If backward gradients occasionally behave abnormally, preserve the original inputs, routing decisions, and intermediate gradients for diagnosis.

    2. Distributed sharding training strategy

    Trillion-parameter models cannot fit into a single GPU. They require sharding of parameters, gradients, and optimizer states across ranks. Common approaches include ZeRO and FSDP. The core goal of ZeRO/FSDP is to split model states across multiple ranks to reduce per-GPU memory usage, but this introduces additional communication.

    The following is a simplified conceptual illustration. It does not correspond to the API of a specific framework:

    1. # Conceptual illustration: parameters, gradients, and optimizer states are all sharded by rank
    2. for step in range(num_steps):
    3. # Forward: aggregate parameters layer by layer, then compute
    4. for layer in model.layers:
    5. layer.params = all_gather(layer.shard_params)
    6. layer.output = layer.forward(layer.input)
    7. # Backward: parameters still need to be aggregated; gradients are reduced and scattered
    8. for layer in reversed(model.layers):
    9. layer.params = all_gather(layer.shard_params)
    10. layer.grad = layer.backward(layer.output_grad)
    11. reduce_scatter(layer.grad, owner_rank)
    12. layer.output_grad = layer.grad_to_input(layer.output)
    13. optimizer.step() # Update only the local optimizer shard
    14. optimizer.zero_grad()
    15. release(layer.params, layer.grad)

    In engineering practice, note the following:

    • Parameters may need to be aggregated in both forward and backward passes. Do not aggregate only during the forward stage.
    • Gradients must be reduced and scattered to the ranks that own the optimizer states.
    • Optimizer states themselves should also be managed according to the sharding strategy.
    • The timing of activation release, parameter aggregation, and communication bucket size affects peak memory usage.
    • After changing the sharding strategy, numerical alignment must be revalidated. It is not enough to validate only that training can run.

    3. Collective communication

    MoE All-to-All, All-Gather/Reduce-Scatter in sharded training, and Reduce-Scatter/All-Reduce in tensor parallelism all rely on collective communication libraries. Key adaptation points include:

    • Topology awareness across nodes and GPUs: prefer high-bandwidth links and avoid unnecessary cross-node detours.
    • Communication-computation overlap: hide communication as much as possible inside backward computation or parameter aggregation.
    • Observability of communication failures: record timeouts, stuck ranks, communication bucket sizes, and error logs.
    • Bucketing strategy: buckets that are too large increase memory usage; buckets that are too small reduce bandwidth utilization.
    • Benchmarking: before training, separately validate the throughput and stability of All-to-All, All-Gather, and Reduce-Scatter.

    If a training step hangs for a long time, suspect communication synchronization issues first. A recommended troubleshooting order is: single-GPU operator validation → intra-node multi-GPU communication → inter-node communication → full-pipeline training.

    4. Memory management

    Under limited memory, it is necessary to combine techniques such as activation recomputation, memory pooling, optimizer state offloading, and communication bucket tuning. The following is an example memory budget table. It only illustrates the estimation method and does not represent the actual memory usage of all models.

    Component Estimation method Example value Control measure Enablement condition
    Parameter weights Parameter count × weight bytes 4.0 GiB Sharding, low precision, quantization Prioritize sharding when parameters dominate memory
    Gradients Parameter count × gradient bytes 4.0 GiB Sharding, gradient accumulation Optimize together with parameters
    Optimizer states Adam momentum, variance, master weights 16.0 GiB Optimizer state sharding, CPU/NVMe offloading Enable offloading when state usage exceeds 40%
    Activations Layers × sequence length × hidden dimension × micro-batch 14.5 GiB Activation recomputation, checkpointing Enable recomputation when activations exceed 30%
    Communication buffers All-to-All / All-Gather buckets 2.5 GiB Adjust bucket size, overlap communication Tune when communication buffers exceed 10%
    Fragmentation and reserved memory Allocator cache, alignment overhead 3.8 GiB Memory pooling, defragmentation, reserved-memory limits Optimize the allocator when fragmentation exceeds 10%
    Total Sum of the above items 44.8 GiB Overall memory budget Peak usage should be below 90% of the hardware budget

    Memory management is not simply enabling every optimization. It requires an explainable budget table. If memory is insufficient, the following order is recommended:

    1. Reduce micro-batch size.
    2. Enable activation recomputation.
    3. Adjust communication bucket sizes and parameter aggregation granularity.
    4. Enable optimizer state sharding or CPU offloading.
    5. Consider more aggressive sharding or more complex pipeline parallelism last.

    Numerical stability and gradient checks

    What distinguishes pipeline validation from merely getting training to run is strict checking of numerical health. At a minimum, engineering checks should include:

    • Loss curve checks: The training loss should generally decrease without obvious divergence, prolonged plateau oscillation, or sudden jumps.
    • Gradient norm monitoring: Track the global gradient norm to identify gradient explosion or vanishing.
    • Numerical overflow detection: Monitor the frequency and location of inf/nan occurrences under mixed precision.
    • Alignment validation: Compare layer by layer against a reference framework under the same seed and configuration.
    • MoE-specific checks: routing distribution, expert load, auxiliary loss, routing flip rate.

    The following is a runnable pseudocode example for single-step gradient checking. Actual thresholds should be set based on model scale, precision, parallel strategy, and training stage.

    1. import math
    2. import torch
    3. MAX_GRAD_NORM = 1.0 # Illustrative value; adjust according to model, precision, and parallel strategy
    4. def check_numerics(model, batch, loss_fn, max_grad_norm=MAX_GRAD_NORM):
    5. device = next(model.parameters()).device
    6. batch = {
    7. k: v.to(device) if torch.is_tensor(v) else v
    8. for k, v in batch.items()
    9. }
    10. model.train()
    11. model.zero_grad(set_to_none=True)
    12. outputs = model(
    13. batch["input_ids"],
    14. pixel_values=batch.get("pixel_values"),
    15. )
    16. loss = loss_fn(outputs, batch["labels"])
    17. named_params = [
    18. (name, p)
    19. for name, p in model.named_parameters()
    20. if p.requires_grad
    21. ]
    22. params = [p for _, p in named_params]
    23. grads = torch.autograd.grad(loss, params, allow_unused=True)
    24. grad_list = []
    25. for (name, _), grad in zip(named_params, grads):
    26. if grad is None:
    27. continue
    28. grad_f = grad.detach().float()
    29. if not torch.isfinite(grad_f).all():
    30. raise RuntimeError(f"NaN/Inf detected in gradient: {name}")
    31. grad_list.append(grad_f)
    32. grad_norm = math.sqrt(sum((g ** 2).sum().item() for g in grad_list))
    33. if grad_norm > max_grad_norm:
    34. raise RuntimeError(f"Gradient explosion detected: grad_norm={grad_norm:.3f}")
    35. return float(loss.detach().cpu().item()), float(grad_norm)

    For MoE models, additional checks are also needed:

    • Does routing selection flip frequently?
    • Is expert load severely unbalanced?
    • Do auxiliary losses conflict with the main loss?
    • Are routing scores saturated under low precision?
    • Are vision branch gradients overwhelmed by language backbone gradients?

    Pre-full-scale pretraining checklist

    Before moving from a scaled-down configuration to full-scale training, it is recommended to verify each item in the following checklist. The checklist should include pass criteria, failure symptoms, diagnostic methods, owners, and rollback actions.

    Check item Pass criterion Failure symptom Diagnostic method Owner Rollback action
    MoE operator alignment Forward and backward errors are within tolerance Loss does not decrease or gradients are abnormal Single-operator tests, comparison with reference implementation Operator/framework engineer Roll back the operator version
    Vision branch validation Vision parameters participate in updates Multimodal branch gradients are zero Parameter gradient statistics Algorithm engineer Fix the freeze strategy
    Sharding equivalence Results match single-GPU results for a small model Multi-GPU loss deviates Fixed-seed comparison Framework engineer Disable sharding or roll back the parallel strategy
    Collective communication Communication benchmarks are stable with no timeouts Training hangs or ranks time out Communication logs, topology checks Platform/communication engineer Reduce parallel degree or change topology
    Memory budget Peak usage is below 90% of budget OOM or frequent memory fluctuations Memory statistics, budget table Training engineer Enable recomputation, offloading, or reduce batch size
    Numerical health No NaN/Inf; gradient norm is stable Loss spikes or divergence Gradient monitoring, numerical alignment Algorithm engineer Roll back to a checkpoint and reduce learning rate
    Scaling validation Trend from small scale to full scale is consistent Performance drops sharply after scaling Scale up in stages Project manager/all team members Roll back to the previous stable checkpoint

    Before full-scale training, the following engineering assets should also be retained:

    • Stable checkpoints: Save recoverable checkpoints at fixed step intervals.
    • Version snapshots: Framework, driver, communication library, operator library, and model configuration versions.
    • Experiment records: Parallel strategy, batch size, sequence length, learning rate, random seed.
    • Monitoring dashboards: Throughput, memory, communication, gradient norm, loss, MoE load.
    • Rollback plan: When loss diverges, communication fails, or memory anomalies occur, quickly recover to the previous stable configuration.

    Conclusion

    Adapting domestic AI accelerators for trillion-parameter MoE multimodal training cannot rely only on comparing peak single-GPU compute. It requires a complete engineering methodology spanning scaled-down validation and full-scale pretraining. Scaled-down configurations are useful for quickly exposing operator, communication, memory, and numerical issues, but their convergence cannot replace full-scale validation.

    Only after completing MoE sparse routing operator alignment, distributed sharding correctness validation, collective communication stability testing, memory budget management, and gradient numerical health checks can an organization determine whether the entire training pipeline has a reproducible, scalable, and rollback-ready engineering foundation.