Engineering Practices for Training Multimodal Large Models on Domestic AI Chips
This article examines the engineering practices behind training multimodal large models end to end on domestic AI chips. Rather than focusing on a single release or a single metric, it frames the work as building a verifiable, reproducible, and continuously iterable training system across data, operators, frameworks, parallelism, precision, monitoring, and recovery. It walks through a typical multimodal image generation pipeline, a three-layer evaluation of hardware, framework, and model, the main challenges with troubleshooting checklists, an illustrative training skeleton, observability metrics, and the rationale for open-sourcing this kind of work. It closes with a step-by-step path for teams—from single-card validation to long-cycle training—and an FAQ covering compatibility, parallelism, precision mismatches, and checkpoint recovery.
1. Key Takeaways: The Core Is an Engineering Closed Loop
Recently, some domestic teams have started to train and open-source multimodal generative models end to end on domestic AI chips. For developers and enterprises, the focus of this kind of work should not stop at a single release or a single metric. It should center on the engineering method behind it: training multimodal large models on domestic chips is not a simple hardware swap, but the construction of a verifiable, reproducible, and continuously iterable training system built around “data — operators — framework — parallelism — precision — monitoring — recovery.”
Three core conclusions sum this up. First, complete small-scale compatibility validation before scaling up to multi-card, multi-node, and long-cycle training. Second, ensure numerical stability and recoverability before pursuing throughput and scale. Third, establish version manifests, precision baselines, monitoring metrics, and checkpoint mechanisms before evaluating whether a domestic compute foundation can support business needs.
2. Can Domestic Chips Train Multimodal Large Models: The End-to-End Pipeline
Domestic chips can participate in multimodal large model training, but only when the key stages of the training pipeline can run in a stable closed loop on domestic hardware, domestic frameworks, and adaptation libraries. “End to end” here means that the key stages of the pipeline run on domestic compute and the domestic software stack as much as possible, rather than replacing only one module locally.
A typical multimodal image generation training pipeline includes:
- Data preprocessing and loading: image decoding, resizing, cropping, text tokenization, image-text alignment, caching, and sampling.
- Forward computation: image encoding, text encoding, cross-modal fusion, and the diffusion network or generation head.
- Backpropagation: gradient computation, gradient synchronization across devices, and parameter updates.
- Mixed-precision training: FP16, BF16, and FP32 combinations, loss scaling, gradient clipping, and numerical stability control.
- Distributed parallelism: data parallelism, tensor parallelism, pipeline parallelism, and memory optimization strategies.
- Monitoring and recovery: throughput, memory, loss, gradient norm, checkpoint recovery, and fault localization.
To keep “whether domestic chips can train” from being reduced to a slogan, teams should establish a verification checklist before starting a project. The table below can be used for internal review and for environment checks when reproducing in an open-source community.
| Verification item | Focus | Suggested output |
|---|---|---|
| Driver and framework versions | Whether driver, framework, compiler, and runtime versions are fixed | An environment version table |
| Framework adaptation layer or acceleration library version | Whether operator libraries, compilation acceleration libraries, and mixed-precision support libraries are fixed | Record the name and version of the adaptation layer |
| Collective communication library | Whether required collective communication primitives are supported, and topology adaptation | Record the communication backend, topology, and version |
| Operator coverage | Whether forward, backward, optimizer, and mixed-precision operators are complete | An operator coverage list |
| Precision comparison | Output differences versus the reference framework under the same input and random seed | Record error ranges and acceptance thresholds |
| Checkpoint recovery | Saving and loading model, optimizer, random number states, and data progress | Complete a recovery drill |
| Log metrics | Whether throughput, memory, communication, loss, and gradient norm can be collected | A monitoring dashboard |
Precision comparison should not stop at “basically consistent.” It is better to use an actionable criterion: under the same input, same random seed, and same batch configuration, compare the forward outputs, loss, and gradient norm layer by layer; set relative loss deviation and relative gradient error thresholds for the end-to-end pipeline according to the task, and note that mixed precision introduces reasonable deviation. If a public evaluation does not provide model size, data volume, chip model, framework version, throughput definition, and precision baseline, it is not appropriate to simply conclude that it “reaches an advanced level.” A more prudent statement is: the practice may reach a usable level with the ability to keep iterating, but the specific capability boundaries should be based on official technical reports, public code, and reproducible experiments.
3. Choosing a Full-Stack Autonomous Setup: Hardware, Framework, and Model Layers
Understanding end-to-end training on domestic chips starts with three technical layers.
The first is the hardware layer, the compute foundation. It determines matrix operations, tensor operations, memory capacity, inter-card interconnect bandwidth, cluster scaling, and overall stability. Hardware is the basis of training capability, but it is not the only determining factor.
The second is the framework layer, the software middle layer. The framework handles operator scheduling, automatic differentiation, graph optimization, distributed communication, and mixed-precision support. The same chip can show marked differences under different framework adaptations, and this difference depends on operator coverage, compilation optimization, interconnect bandwidth, parallelism strategy, and model size, rather than a single hardware parameter.
The third is the model layer, the carrier of capability. Model architecture, data mixture, training strategy, loss function, and cross-modal alignment all affect the final result. Compared with pure text models, multimodal models also need to handle representation alignment, fusion, and generation consistency between images and text.
These three layers are tightly coupled. Hardware sets the capability ceiling, the framework affects how efficiently that capability is realized, and the model determines the final experience. If any layer has a weak point, it can become an overall bottleneck. Therefore, a full-stack autonomous setup does not pursue the single strongest point at every stage, but stable coordination, maintainability, and reproducibility across layers.
4. Key Challenges and a Troubleshooting Checklist for Multimodal Image Generation Training
Compared with pure text training, multimodal image generation training places higher demands on memory, communication, data throughput, and numerical stability. The main challenges fall into the following categories.
First, framework adaptation and operator coverage. To support large model training, the framework must provide a complete, stable, and optimizable operator library. Common issues include missing custom operators, unsupported backpropagation, mixed-precision incompatibility, and precision deviations in fused operators. From an engineering standpoint, it is recommended to build an operator compatibility checklist:
| Check item | Questions to confirm |
|---|---|
| Basic operators | Are convolution, matrix multiplication, LayerNorm, Dropout, RoPE, etc. supported? |
| Fused operators | Do FlashAttention, fused layer norm, and optimizer fusion exist? |
| Backward support | Do custom operators have backward implementations? |
| Precision behavior | Do overflow or deviation occur under FP16/BF16? |
| Performance behavior | Are there inefficient fallback paths? |
| Failure path | Do missing operators produce clear errors? |
Second, mixed precision and numerical stability. Large model training commonly uses mixed precision to save memory and improve throughput, but in multimodal training the distributions of image features, text features, and fusion features differ, and low precision more easily amplifies numerical anomalies. Common practices include loss scaling, gradient clipping, keeping critical layers at higher precision, monitoring the number of overflows, and saving the scene promptly when NaN or Inf appears.
Third, distributed parallelism strategy. Multimodal image generation models usually have large parameter counts that a single card cannot handle, requiring a combination of data, tensor, and pipeline parallelism. The applicable scenarios for different strategies are as follows:
| Parallelism | Applicable scenario | Main benefit | Main risk |
|---|---|---|---|
| Data parallelism | Model fits on a single card, large sample count | Simple throughput scaling | Gradient synchronization communication pressure |
| Tensor parallelism | Single-layer parameters too large to fit on one card | Lower per-card memory | High interconnect bandwidth demand |
| Pipeline parallelism | Many model layers, splittable into stages | Lower overall memory | Pipeline bubbles, complex scheduling |
| Combined parallelism | Large models across multiple cards and nodes | Balance memory and throughput | High tuning complexity |
Fourth, memory and communication bottlenecks. High-resolution, long-sequence multimodal data makes both memory usage and inter-card communication bottlenecks. Common optimizations include gradient checkpointing, operator fusion, overlapping communication with computation, mixed precision, gradient accumulation, memory reuse, and dynamic batch size. But optimization should not be piled up blindly; it is better to first establish a baseline, then verify the benefit of each item one by one.
Fifth, data and storage. Multimodal training is not only a GPU or NPU problem but also a data system problem. High-frequency image decoding can make the CPU a bottleneck; data versions and sample ordering affect reproducibility; and shared storage bandwidth, task queuing, and faulty node isolation also affect long-cycle training stability. It is recommended to define the data version number, sampling order, caching strategy, and fault retry mechanism before training.
5. Training Skeleton Example: From a Discriminative to a Generative Pipeline
The pseudocode below illustrates the general skeleton of multimodal image generation training on domestic AI chips. It is not production code and cannot run directly; the focus is on showing key steps such as initialization, parallelism setup, mixed precision, gradient checkpointing, logging and monitoring, and checkpoint saving. The example uniformly uses torch_npu, HCCL, and the NPU device type; other domestic chips need to be replaced with the corresponding vendor’s acceleration library, communication backend, and device type.
# Illustrative pseudocode: shows only the skeleton of multimodal image generation training on domestic AI chips# Depends on torch_npu; other domestic chips need to be replaced with the vendor's adaptation library and communication backendimport randomimport numpy as npimport torchimport torch.distributed as distimport torch_npudef main():# Example key training parametersuse_amp = Truemax_norm = 1.0save_interval = 500use_cfg_dropout = Truecfg_dropout = 0.1# 1. Initialization: distributed environment, random seeds, device, configdist.init_process_group(backend="hccl") # Other domestic chips need to be replaced with the corresponding communication librarytorch.manual_seed(2026)np.random.seed(2026)random.seed(2026)if torch_npu.npu.is_available():device = torch.device("npu")torch.npu.set_device(torch.npu.current_device())else:raise RuntimeError("NPU is not available. Check the driver, torch_npu, and device status.")# 2. Build model and optimizermodel = build_model().to(device)vae = build_vae().to(device)vae.eval()for p in vae.parameters():p.requires_grad = Falseoptimizer = build_optimizer(model.parameters())lr_scheduler = build_lr_scheduler(optimizer)scaler = torch.amp.GradScaler("npu", enabled=use_amp)# 3. Build data loader, noise scheduler, and loss functiondataloader = build_dataloader()noise_scheduler = build_noise_scheduler()loss_fn = torch.nn.MSELoss()step = 0for batch in dataloader:images = batch["image"].to(device)cond = batch["text"].to(device)# 4. Forward: VAE encoding, timestep sampling, noise addition, generative model predictionwith torch.amp.autocast(device_type="npu", enabled=use_amp):with torch.no_grad():posterior = vae.encode(images)latents = posterior.latent_dist.sample() * vae.config.scaling_factorbsz = latents.shape[0]timesteps = torch.randint(0,noise_scheduler.config.num_train_timesteps,(bsz,),device=device,dtype=torch.long,)noise = torch.randn_like(latents)noisy_latents = noise_scheduler.add_noise(latents, noise, timesteps)# Optional: during classifier-free guidance training, drop text conditions by ratioif use_cfg_dropout:drop_mask = torch.rand((bsz,), device=device) < cfg_dropoutdrop_mask = drop_mask.view(-1, 1, 1)null_cond = torch.zeros_like(cond)cond = torch.where(drop_mask, null_cond, cond)pred = model(noisy_latents, timesteps, cond)# This example uses noise prediction; if the model uses velocity or flow-matching objectives, replace per the model definitiontarget = noiseloss = loss_fn(pred, target)# 5. Backward: mixed-precision loss scalingoptimizer.zero_grad(set_to_none=True)scaler.scale(loss).backward()# 6. Gradient clipping and update: fix the undefined variable issuescaler.unscale_(optimizer)total_norm = torch_npu.npu.utils.clip_grad_norm_(model.parameters(),max_norm,)scaler.step(optimizer)scaler.update()lr_scheduler.step()# 7. Exception handling: save the scene and exit on NaN/Infif not torch.isfinite(loss):save_debug_snapshot(step, batch, model, optimizer, scaler)raise RuntimeError("Detected a non-finite loss; the scene has been saved.")# 8. Monitoring: throughput, memory, loss, gradient normif step % 50 == 0:metrics = {"step": step,"loss": float(loss.detach().cpu()),"grad_norm": float(total_norm),"samples_per_second": get_samples_per_second(),"memory_used": torch.npu.max_memory_allocated(device),}log_metrics(metrics)# 9. Checkpoint: save model, optimizer, scaler, scheduler, random states, and data progressif step % save_interval == 0:save_checkpoint(step,model,optimizer,scaler,lr_scheduler,python_rng=random.getstate(),numpy_rng=np.random.get_state(),device_rng=torch.npu.get_rng_state(),dataloader_state=getattr(dataloader, "state_dict", lambda: {})(),)step += 1if __name__ == "__main__":main()
In real engineering, this also needs supporting infrastructure such as data version management, environment images, object storage, log collection, alerting, containerized scheduling, and fault recovery. Without this infrastructure, long-cycle training can easily become impossible to reproduce after a single failure.
6. Observability Metrics and a Common Errors List
To make the training process diagnosable, it is recommended to collect at least the following metrics.
Throughput metrics include samples/s, images/s, or tokens/s. For multimodal autoregressive models that use tokens as the sequence unit, tokens/s can be recorded; for diffusion-based image generation models, it is better to use samples/s or images/s. MFU can be approximated by the ratio of achieved compute to peak hardware compute, that is, MFU = actual model computation / training time / chip peak compute.
Stability metrics include loss, grad_norm, param_norm, and the number of overflows. Memory metrics include allocated memory and reserved memory. Communication metrics include allreduce time and wait time. Data metrics include dataloader wait time. Recovery metrics include checkpoint save time and load time.
On this basis, a common errors list can be established:
| Error type | Typical symptom | Possible cause | Suggested handling |
|---|---|---|---|
| Missing operator | Errors at startup or fallback to an inefficient implementation | Framework coverage gap, version mismatch | Upgrade framework, add operators, find equivalent implementations |
| Numerical overflow | loss becomes NaN, gradient explosion | Mixed precision, data anomalies, learning rate too high | Adjust loss scaling, gradient clipping, data filtering |
| Communication bottleneck | Multi-card throughput below expectations | Insufficient interconnect bandwidth, communication not overlapped | Optimize parallelism strategy, communication fusion, topology awareness |
| Checkpoint failure | loss anomaly or performance drop after recovery | Incomplete saving of optimizer state, random number states, data progress | Add recovery drills, improve state saving |
| Data bottleneck | Low compute utilization, high CPU usage | Slow image decoding, insufficient storage bandwidth | Add caching, optimize decoding, adjust worker count |
The value of this kind of list is to turn a vague “training doesn’t go smoothly” into locatable, trackable, and fixable engineering problems.
7. Why Open-Source Models Trained on Domestic Chips: Ecosystem Value and Engineering Quality Requirements
Choosing to open-source helps turn an internal engineering practice into a public sample the community can verify. Its value shows mainly in three aspects.
First, verifiability. Open-source code and weights let external teams reproduce the training pipeline and reduce information asymmetry. Second, collaboration efficiency. Different teams can optimize operators, supplement documentation, and fix compatibility issues around the same foundation, avoiding reinventing the wheel. Third, a positive ecosystem cycle. More usage feedback drives frameworks, chips, and the community to iterate together, forming a closed loop where hardware, frameworks, models, and the developer community support one another.
However, open-sourcing also means higher engineering quality requirements. Whether the code is installable, whether the environment is reproducible, whether the configuration is clear, whether the training scripts are complete, and whether the metrics are comparable all affect community participation. For an enterprise, open-sourcing is not just a release action but a process of building credibility and ecosystem influence.
8. A Practical Path for Developers: From Single-Card Validation to Long-Cycle Training
For teams that want to reproduce or learn from end-to-end training on domestic chips, the following path can be followed:
- First validate operators and precision: lock the driver, framework, adaptation library, communication library, and data version, and complete forward, backward, and optimizer runs on a single card or a small-scale cluster.
- Build a small-sample baseline: record loss, gradient norm, and output results under fixed input and random seed, forming precision acceptance criteria.
- Scale up in stages: from single card to multi-card, from data parallelism to tensor parallelism, then to pipeline parallelism, verifying throughput, memory, and communication changes at each step.
- Complete recovery drills: verify whether checkpoint saving, loading, and continued training are consistent, and assess the storage cost of frequent saving.
- Record experiment logs: keep the configuration, metrics, and failure reasons for each adjustment, and prepare an isolated canary validation plan if driver or firmware changes are needed.
For enterprise decision-makers, the recommendation is not to look only at promotional claims but at whether version manifests, reproduction steps, precision baselines, and fault recovery plans are provided. “Operator coverage list + precision baseline + recovery drill + version locking” can be used as an evaluation sheet for domestic frameworks and chips. Truly replicable autonomous technical capability usually comes from long-term, stable, and verifiable engineering accumulation, rather than a one-off news event.
9. FAQ: Common Questions About Multimodal Training on Domestic Chips
Q: Can domestic chips train multimodal large models?
A: They can, but only after completing end-to-end validation of driver, framework, operators, communication, mixed precision, parallelism strategy, and checkpoint recovery. Running a single point does not equal stable training; long-cycle training also depends on fault recovery and data reproducibility.
Q: How should you choose a parallelism strategy for a multimodal image generation model?
A: If the model fits on a single card, prefer data parallelism; if single-layer parameters are too large, consider tensor parallelism; if the model has many layers and memory is insufficient, consider pipeline parallelism; large multi-card, multi-node models usually adopt combined parallelism and need careful evaluation of interconnect bandwidth and scheduling complexity.
Q: What if the precision doesn’t match?
A: First confirm whether the input data, random seed, and version configuration are consistent, then compare forward outputs, loss, and gradients layer by layer. If it is a mixed-precision difference, check loss scaling, critical-layer precision, and gradient clipping; if it is an operator difference, produce an operator coverage list and look for equivalent implementations.
Q: How do you troubleshoot checkpoint recovery failures?
A: Focus on checking whether the model, optimizer, scaler, learning rate scheduler, random number states, current step, and data loading progress were saved. After recovery, compare loss, gradient norm, and throughput before and after to confirm whether the training trajectory is consistent.
End-to-end training of multimodal large models on domestic chips is, on the surface, a model training and open-source release, but in essence it is a test of the full-stack coordination capability of “chip — framework — model.” For developers and enterprises, what is more worth attention is the reusable method: build checklists, improve monitoring, value precision, strengthen recovery, and continuously optimize operators and parallelism strategies. Understanding and participating in the construction of this autonomous technology stack is more valuable in the long term than chasing short-term hot topics.
