Adapting Domestic AI Accelerators for Multimodal Large Model Training: An Engineering Practice Guide

    This guide presents an engineering workflow for adapting domestic AI accelerators and their software stacks to large-scale multimodal model training. It starts by freezing a version baseline, then defines verifiable acceptance criteria for functional correctness and training stability. The article shows how to use a trimmed configuration to expose pipeline issues early, how to complete and validate operators and their backward gradients, how to control memory peaks, and how to combine data, tensor, pipeline, expert, and sequence/context parallelism. It also covers verifying communication and topology boundaries, building a minimal observability system with metrics and alerts, and following a phased path from single-card validation to cluster-scale training. Teams will find checklists, comparison tables, and troubleshooting paths for common long-tail issues such as memory leaks, operator mismatches, and communication timeouts.

    1. Applicability and Key Takeaways

    This article is intended for teams working on large model training and compute adaptation that already have officially supported domestic accelerators and a compatible software stack. Before you start, freeze a version baseline that includes at least: the domestic accelerator model and firmware, the driver version, the training framework version, the collective communication library version, the container image, the scheduling platform, and the data pipeline and storage versions. This article targets scenarios with trillion-scale parameters, multimodal data volumes (mixed text, images, video, or audio), and BF16/FP16 mixed-precision training.

    Results depend on the specific card model, interconnect topology, node count, and data distribution, so a single-card conclusion cannot be generalized to the entire cluster.

    Core conclusion: domestic compute adaptation should proceed in the order operator correctness → gradient correctness → trimmed long-run stability → communication scaling → full-scale training. Each stage needs defined pass thresholds, failure criteria, and rollback conditions, rather than relying on a single short training step that happens to run.

    2. Acceptance Goals: Turning “It Runs” into a Verifiable Checklist

    2.1 Functional Correctness Acceptance

    Functional correctness is the foundation of adaptation. Confirm the following items one by one:

    • Operator coverage matrix: list operators such as attention, masking, positional encoding, normalization, expert routing, cross-modal projection, and loss computation, and note the reference implementation, the domestic accelerator implementation, and any differences.
    • Gradient completeness: after the backward pass, confirm that all parameters that should be updated have gradients, and that expert routing weights, the vision branch, the language branch, and the fusion module all participate in updates.
    • Numerical consistency: compare domestic accelerator results against a small-scale reference implementation, and record the error ranges for loss, gradient norm, and key intermediate tensors.
    • Complete multimodal fields: fix the model input and output fields, including at least text_embeds, visual_embeds, logits, aux_loss, loss_mask, and labels.
    • Mixed-precision stability: check type conversion, overflow handling, loss scaling, and optimizer state updates.

    2.2 Training Stability Acceptance

    Stability is not just about “running one step.” Look at trends and resource changes over a longer number of steps:

    • Loss keeps decreasing, or stays within a reasonable fluctuation range.
    • The gradient norm stays within the configured limit; consecutive anomalies should trigger an alert or a rollback.
    • The optimizer state updates normally, with no parameters stalled over the long term.
    • Results are reproducible across different random seeds, at least reproducing the key trends.
    • Memory does not grow continuously over long runs, with no communication timeouts or abnormal process exits.

    2.3 Trimmed Configuration Validation: Exposing Pipeline Issues at Minimal Cost

    The goal of a trimmed configuration is not to evaluate model capability, but to expose pipeline issues early. The trimming principle is: keep the key structure, reduce the compute scale, and preserve the real training path. You can keep a portion of the language backbone layers, a small number of experts, the vision tower, and the cross-modal projection module, so that the multimodal structure still participates in computation and gradient updates.

    The following pseudocode illustrates a short-pipeline training validation under a trimmed configuration, assuming step starts from 0:

    1. # Pseudocode: short-pipeline training validation under a trimmed configuration
    2. gradient_accumulation_steps = 8
    3. log_interval = 20
    4. optimizer.zero_grad(set_to_none=True)
    5. for step, batch in enumerate(train_loader):
    6. outputs = model(batch)
    7. # outputs should contain multimodal fields, e.g. logits, text_embeds, visual_embeds, aux_loss, loss_mask
    8. loss = loss_fn(
    9. logits=outputs["logits"],
    10. labels=batch["labels"],
    11. aux_loss=outputs.get("aux_loss"),
    12. loss_weights=train_cfg["loss_weights"]
    13. )
    14. (loss / gradient_accumulation_steps).backward()
    15. if (step + 1) % gradient_accumulation_steps == 0:
    16. torch.nn.utils.clip_grad_norm_(model.parameters(), train_cfg["grad_clip"])
    17. optimizer.step()
    18. optimizer.zero_grad(set_to_none=True)
    19. if step % log_interval == 0:
    20. logger.log(
    21. step=step,
    22. loss=loss.item(),
    23. grad_norm=compute_grad_norm(),
    24. memory_peak=get_peak_memory(),
    25. throughput=get_throughput(),
    26. )

    The trimmed validation stage should produce a checkable checklist:

    • Operator coverage matrix: confirm that every key operator has a domestic accelerator implementation and a reference comparison.
    • Gradient norm limit: set grad_clip and record the grad_norm baseline. If it exceeds the upper bound of the baseline or stays anomalous for several consecutive steps, move into investigation.
    • Memory peak collection method: reset statistics before training and record the peak per step; distinguish framework cache, device memory, and temporary buffers.
    • Communication timing fields: record rank, op_name, dtype, num_bytes, p50, p99, and retry_count.
    • Failure criteria: NaN loss, gradient explosion, memory overflow, communication timeout, and process crashes should all be treated as failures.
    • Rollback conditions: after a failure, roll back to the most recent stable checkpoint, and keep the failure logs, memory snapshot, and communication logs.

    3. Key Engineering Capabilities: Fix Operators First, Then Control Memory, Then Scale

    3.1 Completing Operators and Verifying Backward Gradients

    The most common risk in domestic accelerator adaptation is not the model structure, but inconsistent behavior of low-level operators under special shapes, special data types, or the backward path. A runnable forward pass does not mean a trainable backward pass. You must verify the following operators:

    • Multi-head attention: scaled dot product, masking, positional encoding, variable-length sequences.
    • Expert routing: index selection, weight normalization, capacity limits, auxiliary loss.
    • Normalization layers: mean/variance statistics, backward computation, mixed-precision stability.
    • Cross-modal projection: alignment of vision and language tensors, activation functions, gradient backpropagation.
    • Collective communication: parameter synchronization, gradient reduction, expert routing exchange, activation exchange.

    It is recommended to build unit-level verification at the operator layer, covering input shape, data type, backward conditions, and the reference implementation. If operator results disagree, first locate whether the difference comes from numerical error, mask handling, type conversion, or the order of collective communication.

    3.2 Controlling Memory Peaks and Avoiding Long-Run Stability Risks

    For trillion-scale models, memory pressure comes from parameters, gradients, optimizer states, activations, and temporary buffers. Common techniques include:

    • Sharding parameters, gradients, and optimizer states.
    • Enabling activation recomputation for some layers.
    • Reusing temporary buffers to reduce frequent allocation and release.
    • Binning or dynamically trimming variable-length inputs.
    • Monitoring memory fragmentation to avoid allocation failures after long runs.

    Note: buffer reuse and temporary-buffer reuse are not risk-free. If cache keys are unclear, temporary directories are not cleaned up, or checkpoint writes are incomplete, you can end up with cache pollution, corrupted checkpoints, or lost training state after a container restart. It is recommended to give caches versioned names, expiration cleanup, and validation checks; write checkpoints atomically and keep the most recent several usable versions; and run a consistency check before recovery.

    3.3 Combining Distributed Parallelism Strategies

    Trillion-scale multimodal models usually require combining several forms of parallelism. The choice should be based on the model structure, inter-node bandwidth, memory capacity, and communication cost, rather than simply stacking strategies.

    Strategy Memory pressure Communication cost Applicable scenario Domestic accelerator validation focus
    Data parallelism High if not sharded, since each card keeps the full parameters Significant gradient synchronization Improving throughput; suitable when the model fits on a single card or is combined with sharding Collective communication, gradient reduction, sharded optimization
    Tensor parallelism Can reduce per-layer parameter and activation pressure High frequency, dense intra-layer communication Heavy single-layer compute or memory pressure Operator fusion, intra-group reduction, numerical consistency
    Pipeline parallelism Can reduce memory usage Mainly point-to-point communication Many layers, hard to fit on a single card Pipeline bubbles, scheduling efficiency, long-tail waiting
    Expert parallelism Distributing experts reduces per-card expert pressure Noticeable AllToAll or routing communication MoE sparse expert structures Routing hotspots, load balancing, communication timeouts
    Sequence or context parallelism Relieves long-sequence activation pressure Sequence splitting and reordering communication Long context, long multimodal inputs Variable-length inputs, masking, cross-modal alignment

    For domestic accelerator platforms in particular, verify the support for communication primitives under different parallelism strategies, as well as the stability of the collective communication library in cross-node scenarios.

    3.4 Verifying Domestic Accelerator Communication and Topology Boundaries

    Distributed training bottlenecks are often not in compute but in communication. Domestic accelerator adaptation must explicitly verify the following boundaries:

    • Whether the card model, firmware, driver version, and collective communication library version pass compatibility verification.
    • Whether the topology binding is explicit, including NUMA binding, NIC affinity, in-container device mapping, and cross-node interconnect domain identification.
    • Whether there is a measured baseline for cross-node bandwidth thresholds. If actual bandwidth stays below the baseline, trigger a topology or network investigation.
    • Whether communication timeout and retry policies are explicit. A collective communication timeout should record rank, op, bytes, the timeout value, and the error code.
    • Whether high-communication-density parallel groups are bound to the high-speed interconnect domain.
    • Whether intra-node and inter-node communication are observed separately.
    • Whether long-tail nodes can be identified, so a single node does not slow down the whole training run.

    For troubleshooting, start from the bottom: first verify intra-node P2P and collective communication, then verify cross-node bandwidth, and finally verify the communication patterns of the complete training job. Logs should contain at least: node name, rank, process ID, communication operator, data type, data size, p50/p99 latency, retry count, error code, and topology domain.

    3.5 Minimal Observability Metrics and Alerts

    Once the training pipeline becomes complex, the loss curve alone cannot tell you the health of the system. Build a minimal observability system:

    Metric Collection frequency Threshold basis Alert / handling
    Loss not decreasing Per step or per log cycle Based on a sliding baseline; not decreasing for several consecutive cycles Check data, learning rate, gradients, operators
    grad_norm over threshold Every optimizer update Not exceeding grad_clip, or not exceeding the historical baseline mean plus a reasonable offset Lower the learning rate, check anomalous layers, roll back the checkpoint
    Memory peak and fragmentation Every N steps or triggered by a memory event Peak above baseline, or reserved memory not released over the long term Adjust batch size, sharding, recomputation, clear cache
    P99 communication latency Aggregated and recorded per step Above baseline or close to the timeout threshold Check topology, slow nodes, communication library version
    Checkpoint time Every checkpoint Over the job budget Asynchronous save, sharded save, compressed storage

    If some low-level metrics cannot be collected directly, use alternatives such as vendor monitoring tools, device utilization, host-side logs, process-level monitoring, or an offline profiler. However, alternatives must record a baseline, otherwise you cannot tell whether something is abnormal.

    4. Phased Implementation Path: From Operator Validation to Cluster Training

    Stage Goal Pass condition Failure condition Rollback condition
    Single-card and single-node validation Confirm the basic training pipeline Forward and backward work, gradients propagate, memory is controllable Missing operators, broken gradients, loss not decreasing Roll back to the most recent runnable version
    Multi-card communication validation Move from a single node to multiple nodes Sharding and gradient synchronization are correct, collective communication is stable Communication timeout, inconsistent results, hotspot nodes Reduce the parallel scale or fall back to a single node
    Trimmed long-run stability validation Observe convergence and stability Smooth loss, memory not growing, reliable checkpoints Abnormal grad_norm, continuously growing memory, long-tail communication Roll back the checkpoint and keep the failure snapshot
    Full-scale training Support real model scale Parallelism strategy fits, stable throughput, recoverable Resource leaks, sudden throughput drop, job cannot recover Switch to the most recent stable checkpoint and baseline configuration

    5. Engineering Recommendations and Common Troubleshooting Paths

    1. Do not skip operator-level validation. Many problems come from special shapes, special data types, or the backward path, rather than the model structure itself.

    2. Do not look only at single-card peak performance. The key to domestic compute adaptation is the overall efficiency and stability of multi-card, multi-node, long-run training.

    3. Do not ignore observability. Without logs, metrics, and alerts, the cost of locating problems in a complex training pipeline rises significantly.

    4. Do not treat trimmed validation as equivalent to full-scale training. The trimmed configuration is used to expose pipeline issues; in the end, full-scale training is still needed to verify performance, stability, and convergence quality.

    5. Do not ignore ecosystem coordination. The training framework, runtime, driver, communication library, scheduling platform, and monitoring system all need to be adapted together.

    Common long-tail issues can be approached as follows:

    • How to choose a parallelism strategy? First check whether memory can hold the model, whether communication bandwidth matches, and whether the model structure is suitable for splitting, then combine data, tensor, pipeline, and expert parallelism.
    • How to troubleshoot a memory leak? Compare memory peaks, reserved memory, and fragmentation metrics across different steps, and check buffer reuse, temporary buffers, and memory reclamation in long-running jobs.
    • What to do about operator inconsistency? First do a single-operator comparison, then check masking, data type, positional encoding, expert routing, and the order of collective communication.
    • How to locate a communication timeout? Inspect rank, communication operator, data size, node topology, cross-node bandwidth, and retry logs, and verify level by level from a single node up to multiple nodes.

    6. Conclusion

    The core of training trillion-scale multimodal models is not only scaling up the model, but also a concentrated demonstration of training systems engineering capability. For domestic accelerators to support complex training workloads, teams must complete the loop of operator completion, gradient verification, memory management, parallelism strategies, communication optimization, and observability.

    For teams looking to advance domestic compute adoption, aim for the goals of “functionally correct, stably trainable over the long run, elastically scalable, and clearly observable.” Use trimmed configurations to expose issues early, control risk with phased acceptance, and improve troubleshooting efficiency with metrics and alerts. This makes it easier to make the engineering leap from single-card “it runs” to cluster-level training that is trainable, scalable, and rollback-capable.