# Multimodal LLM Training on Domestic AI Accelerators: Adaptation and Troubleshooting Guide
This guide walks through what it takes to train trillion-parameter multimodal models on domestically developed AI accelerator platforms — the hardware and software stacks that sit outside the mainstream CUDA ecosystem. It explains why adaptation has to be solved before scaling up, how to verify operator coverage and numerical parity against a reference implementation, how to organize a native FSDP training path with working pseudocode, and how to choose among DDP, FSDP, ZeRO-3, tensor parallelism, and pipeline parallelism. It also covers end-to-end pipeline wiring (data loading, shard scheduling, gradient synchronization), memory and throughput optimizations with their applicability conditions, and a troubleshooting checklist for OOM, NaN/Inf, stalled loss, communication hangs, checkpoint recovery failures, and per-module bottlenecks. You will come away with the checklists, measurement conventions, and debugging workflow needed to move from "it runs" to "it runs stably and fast."
1. Why Adaptation Comes First in Large-Scale Multimodal Training
Once model parameters grow from tens of billions to the trillions, the binding constraint is no longer “do we have enough compute.” It becomes “can a fixed pool of hardware carry the entire training path end to end.” On domestically developed AI accelerator platforms — accelerator hardware and software stacks that sit outside the mainstream CUDA ecosystem — adaptation work usually comes from three sources.
First, memory is badly mismatched against parameter count. Assume a model with 1 trillion parameters. The parameters alone take roughly 2TB of memory at FP16. If you use an Adam-family optimizer, it typically carries two states — momentum and variance — each equal in size to the parameter count. Estimating with FP16 parameters and FP32 optimizer states, the optimizer states alone come to about 8TB, roughly 4x the FP16 parameter memory; if momentum and variance are also kept in FP16, that drops to about 2TB. Real memory use must also add gradients, activations, communication buffers, and temporary tensors. You cannot estimate from “parameter memory” alone — you have to state the measurement convention you are using.
Second, the software and hardware ecosystem differs. Mainstream frameworks, communication libraries, and operator implementations are usually tightly coupled to a specific hardware architecture. Domestic accelerators may not fully match the mainstream platform in instruction set, operator coverage, memory management, collective communication primitives, or precision handling. A single uncovered operator, a different implementation, or a different reduction order can all lead to a crashed run, anomalous loss, or a precision drift.
Third, multimodal model architectures are highly heterogeneous. A multimodal model typically contains a vision encoder, a text decoder, cross-modal projection layers, and other submodules. Their parameter counts, compute profiles, memory footprints, and parallelism needs differ substantially. Apply one rigid strategy and some modules end up communication-bound while others run out of memory — the weakest module becomes the bottleneck for the whole job.
So adaptation is not simply “get the model to run.” It means establishing a training path across heterogeneous hardware and a unified framework that is verifiable, schedulable, and recoverable.
2. Aligning Operators and Validating Precision
The first step of adaptation is mapping the model’s computation graph onto an operator sequence that the target software stack can actually execute. A practical order of work:
1. Build an operator coverage inventory. Enumerate every operator involved in the forward pass, backward pass, optimizer step, gradient clipping, and loss computation. Mark each as available, missing, requiring a substitute implementation, or requiring a custom implementation. For missing operators, look for an equivalent composition first. If a custom implementation is unavoidable, verify that its backward gradient matches the reference implementation.
2. Establish a precision baseline. Do not wait for a large-scale run to discover numerical problems. Start with a small model, a fixed random seed, fixed inputs, and a fixed data slice, then compare forward outputs, backward gradients, and key intermediate tensors between the target platform and the reference implementation. Pay particular attention to reduction operators — sum, mean, normalization, softmax, layer norm — because different accumulation orders can introduce errors that are hard to notice.
3. Define acceptance criteria that can be explained. Precision thresholds should not be a single fixed number copied from elsewhere; set them against business tolerance, training length, and model sensitivity. In practice, record metrics such as maximum absolute error, relative error, cosine similarity, and changes in gradient norm, and localize them layer by layer. If error is concentrated in a few operators, replace or fix those first. If error accumulates with depth, examine reduction order and numeric types.
4. Localize failures. If loss is anomalous or NaN appears early in training, narrow the search space by bisection: keep only the vision encoder, then only the text decoder, then inspect the projection layers. You can also swap custom operators back to the reference implementation one at a time and watch whether the problem disappears. This is far more efficient than repeated trial and error on the full model.
3. Organizing a Native FSDP Training Path
Fully Sharded Data Parallel (FSDP) is one of the common paths for training very large models. The core idea: shard the model parameters, gradients, and optimizer states across the compute nodes, gather them temporarily during computation, and release them afterward.
The basic flow:
- Forward pass: each node holds only a shard of the parameters. When computation reaches a given layer, an all-gather temporarily reconstructs the full parameters for that layer; once the layer is done, they are released, lowering the memory peak.
- Backward pass: once a layer’s gradients are computed, a reduce-scatter reduces the gradients across shards and scatters them back, so each node keeps only the gradients it owns.
- Optimizer step: each node updates only its own parameter shards, with optimizer states sharded the same way, avoiding a full duplicate of optimizer state on every card.
The term “native FSDP path” emphasizes organizing the training pipeline directly with sharded data parallelism, minimizing extra wrapper layers, conversion layers, and complex intermediate state. For domestic accelerator platforms, the value of this route is that the path is more direct, making it easier to bring up model loading, shard scheduling, and gradient synchronization step by step.
Below is illustrative pseudocode. Note carefully: this code does not correspond to any specific framework API. It exists only to express the engineering structure of the training path. Before real use, replace it with the interfaces your target framework actually supports.
Recommended preconditions:
- Framework and version: use PyTorch or a compatible domestic framework with FSDP-style interfaces, at a version that supports full sharding, automatic wrapping, mixed precision, and sharded optimizers.
- Environment scale: validate on a single node with multiple cards first, then extend to multi-node. Multi-node setups require attention to high-speed interconnect and collective communication stability.
- Communication backend: select the collective communication library supported by the domestic platform, and confirm that driver, firmware, and runtime versions are consistent.
- Memory estimation assumptions: the example below assumes a trillion-parameter-class model with parameters estimated at FP16. Optimizer states, gradients, activations, and communication buffers must be counted separately.
# 1. Build the multimodal model and the sharding/wrapping policymodel = build_multimodal_model(config) # vision, text, projection submodulessharding_policy = auto_wrap_policy( # different wrapping granularity per submoduletransformer_block=DecoderLayer,vision_block=VisionEncoderLayer,)# 2. Wrap the model with fully sharded data parallelism# Parameters, gradients, and optimizer states are all managed as shardsmodel = fully_shard(model,policy=sharding_policy,mixed_precision=mp_policy, # e.g. bf16 or a platform-supported mixed precision policy)# 3. Create a sharded optimizer# Each node updates only the parameter shards it holds locallyoptimizer = sharded_optimizer(model.parameters(),lr=base_lr,)# 4. Main training loopfor step, batch in enumerate(dataloader):with autocast(dtype=bf16): # mixed precision forwardloss = model(batch)["loss"]# Backward pass: sharded reduce and scatter happen once gradients are computedloss.backward()# Gradient clipping must happen after backward and before the parameter updateclip_grad_norm_(model.parameters(), max_norm=1.0)# Each node updates its local parameter shardsoptimizer.step()# Clear gradients after the update so the next iteration does not carry stale onesoptimizer.zero_grad(set_to_none=True)
The easiest place to get this wrong is the ordering of gradient clipping and gradient clearing. After loss.backward() the gradients exist, so clip_grad_norm_ at that point actually constrains real gradients. Call optimizer.step() first and clipping no longer does anything useful. Run optimizer.zero_grad() too early and the gradients get cleared before the update, producing incorrect parameter updates.
For multimodal models, a key FSDP advantage is that you can set a different sharding granularity per submodule. When the vision encoder’s parameter count is comparatively manageable, a coarser wrapping granularity reduces the number of communication calls. When the text decoder is large, finer-grained sharding keeps the memory peak under control. Both can coexist in a single training path, balancing throughput against stability.
4. Choosing a Parallelism Strategy: FSDP, DDP, ZeRO, Tensor Parallelism, Pipeline Parallelism
Training very large models rarely relies on a single parallelism strategy. Selection should weigh memory, communication, implementation complexity, and the hardware interconnect you actually have. A comparison of the common options:
| Strategy | Memory characteristics | Communication characteristics | Applicability boundary |
|---|---|---|---|
| DDP | Each card typically holds full parameters, gradients, and optimizer states | Relatively simple communication; suits small and medium models | Cannot directly carry trillion-parameter models |
| FSDP | Parameters, gradients, and optimizer states are sharded | Relies on all-gather and reduce-scatter; communication-intensive | Suits very large models; makes per-module sharding granularity adjustable |
| ZeRO-3 | Similar sharding of parameters, gradients, and optimizer states | Higher communication and scheduling complexity; depends on mature frameworks | Suits large-model training scenarios close in spirit to FSDP |
| Tensor parallelism | Splits the matrix computation of a single layer across multiple devices | Frequent communication; high bandwidth demand | Suits very large hidden layers, very large matrices, or cases where a single card cannot hold one layer’s computation |
| Pipeline parallelism | Splits layers across devices; lower memory pressure | Pipeline bubbles; needs careful partitioning and scheduling | Suits very deep models that must be split across many devices |
In real engineering, these are usually combined. For example, a multimodal model can be sharded globally with FSDP, with tensor or pipeline parallelism applied inside the text decoder, balancing memory against communication. On domestic accelerator platforms, validate the basic FSDP path first and add more complex parallelism incrementally — problems are much easier to localize that way.
5. Wiring Up an End-to-End Multimodal Training Pipeline
Multimodal adaptation is not only about the model. It also means connecting data, scheduling, communication, and numerical stability into one chain.
First, unify data loading and preprocessing. Multimodal training usually has to handle images, text, labels, and other inputs at the same time. The data pipeline needs to decode, tensorize, split, batch, and convert formats efficiently. If data loading becomes the bottleneck, no amount of compute will be used. Set sensible prefetch depth and caching, configure data-parallel groups, and measure data throughput separately.
Second, balance load across shards. Submodule parameter counts differ substantially. With unreasonable wrapping granularity or sharding policy, some nodes end up carrying too much communication and computation at once and become the bottleneck. Adjust sharding granularity dynamically according to each module’s parameter count, compute volume, and memory footprint, and use profiling to observe communication share and wait time.
Third, treat gradient synchronization as a stability and overlap problem. At scale, gradient synchronization generates a large volume of collective communication. Beyond adapting the communication library itself, overlap communication with computation wherever possible to hide latency. Under mixed precision, watch loss scaling, gradient overflow, and gradient clipping. With FP16, confirm that dynamic or static loss scaling is actually working; with BF16, continue monitoring the numeric range anyway.
Fourth, establish an adaptation checklist for domestic platforms. Before starting training, check at least the following:
- Operator coverage inventory: are the forward pass, backward pass, optimizer, loss, norm, and reduce operators all covered?
- Precision baseline: has a small-sample forward, backward, and gradient comparison been completed?
- Communication library versions: are driver, firmware, runtime, and collective communication library versions consistent?
- Data throughput baseline: can data loading continuously feed the GPU/NPU, or is there IO wait?
- Checkpoint consistency: have sharded save and restore been validated under the same version and the same parallelism strategy?
- Long-run stability testing: have multiple iterations, gradient norm monitoring, and loss curve inspection been performed?
6. Memory and Efficiency Optimizations: Applicability and Measurement
Once the training path is working, further optimization usually targets three areas: memory, communication, and compute efficiency.
1. Activation checkpointing (activation recomputation)
When it applies: activation memory is too high, limiting batch size or sequence length.
Cost: adds some computation — you trade recomputation for memory.
Recommendation: enable it first on memory hotspots such as Transformer blocks and the vision encoder, and use profiling to judge whether the tradeoff pays off.
2. Overlapping communication with computation
When it applies: parameter gathering and gradient reduction cause visible communication stalls.
Approach: overlap all-gather and reduce-scatter with the surrounding forward and backward computation as much as possible.
Caveat: platforms differ in their support for asynchronous communication, stream management, and dependency control, so validate each piece.
3. Mixed precision strategy
When it applies: the platform’s support for FP16, BF16, and FP32 differs.
Recommendation: prefer the precision that is numerically more stable. If the platform supports BF16, it usually needs less loss scaling than FP16, but NaN/Inf monitoring is still required.
4. Sharded checkpoint storage
When it applies: trillion-parameter training runs are long and need frequent saves and fast recovery.
Recommendation: persist training state as shards to reduce single-point access pressure; on restore, verify metadata, parallelism strategy, and version consistency.
5. Dynamic batching and gradient accumulation
When it applies: memory is insufficient for a large batch.
Recommendation: use gradient accumulation to emulate a large batch while monitoring effective batch size, learning rate scaling, and throughput changes.
When measuring the effect of these optimizations, do not stop at “it runs.” Record peak memory, per-card usable batch size, tokens/s or steps/s, communication share, GPU/NPU utilization, and recovery time — otherwise you cannot tell whether the optimization actually helped.
7. Troubleshooting Checklist
| Symptom | Likely cause | Actions |
|---|---|---|
| OOM immediately at startup | Parameters, optimizer states, activations, or communication buffers exceed memory | Check that sharding is actually in effect; confirm optimizer states are sharded; reduce batch size; enable activation recomputation; look for large temporary tensors |
| NaN/Inf during training | Operator precision issue, loss scaling failure, exploding gradients, bad inputs | Check input data; enable gradient clipping; inspect custom operator backward passes; compare gradients against the reference implementation; monitor loss scaling |
| Loss stays flat for a long time | Unreasonable learning rate, data errors, gradients not synchronized correctly | Inspect the loss curve; check data labels; confirm gradient reduction completed; verify parameters are actually being updated |
| Communication timeout or hang | Version mismatch, network fault, mismatched collectives | Verify driver, firmware, and communication library versions; shrink the parallelism scale to reproduce; check inter-node networking; set timeouts and enable logging |
| Checkpoint cannot be restored | Inconsistent sharding policy, missing metadata, version mismatch | Validate checkpoint metadata; confirm parallelism degrees match; restore with the same version; rehearse recovery at small scale |
| One multimodal module computes slowly | Sharding granularity too coarse, data preprocessing bottleneck, load imbalance | Profile each module separately; adjust wrapping granularity; optimize the data pipeline; check whether some rank waits too long |
8. Conclusion
Adapting large-scale multimodal models to domestic AI accelerator platforms is not a matter of swapping individual operators. It is systems engineering that spans operator alignment, precision validation, FSDP sharding, memory estimation, gradient synchronization, data scheduling, and failure recovery. For developers, the important thing is not adopting the most sophisticated parallelism scheme. It is establishing reproducible preconditions, numerical baselines, and a debugging workflow first.
When a training team can state its memory measurement convention clearly, verify the ordering of gradient clipping, keep shard load balanced, and monitor precision and communication stability, large-model training on domestic accelerator platforms has a realistic path from “it runs” to “it runs stably and fast.”
