Engineering Practices for Training Image Generation Multimodal Models on Domestic AI Chips

    This article outlines a practical engineering approach to training image generation multimodal models from scratch on domestic AI accelerators. It covers model architecture selection, operator fusion, tensor layout optimization, parallel training strategies, memory troubleshooting, training stability mechanisms, and evaluation criteria — providing actionable guidance for teams looking to reduce migration costs and improve training efficiency on non-GPU hardware.

    Why Train from Scratch on Domestic Chips

    Multimodal large models place heavy demands on compute resources. Image generation models must process both text conditions and latent or discrete visual sequences, making their compute patterns more complex than pure text models. Many teams first train on general-purpose GPUs and later migrate the model to domestic chips for inference. This post-hoc migration often suffers from low operator execution efficiency, high memory access overhead, and in some cases, out-of-memory errors.

    Designing the model architecture and operator implementations with the target chip in mind from the outset typically reduces migration costs. This requires the team to understand the chip’s compute unit specifications, memory bandwidth, inter-chip and inter-node interconnect topology, and operator library coverage at an early stage.

    Choosing a Model Architecture and Generation Paradigm

    Image generation can be modeled along two main routes. The first is diffusion models, which primarily rely on convolution, normalization, and attention operators. The second approach discretizes images into token sequences and uses autoregressive or masked generation, relying mainly on attention and matrix multiplication. These two routes impose different requirements on operator types; teams should survey the target chip’s operator support list before making a choice.

    If a required operator is missing from the chip’s operator library, custom implementations are needed, which significantly raises development and debugging costs. Therefore, the paradigm choice should weigh both generation quality objectives and the chip’s operator coverage. Semantic alignment between text and images can be enhanced through unified sequence modeling, but this approach itself must be verified for efficiency on the specific chip.

    Operator Fusion, Tensor Layout, and Parallel Strategies

    Operator Fusion

    Operator fusion combines multiple fine-grained operations into a single composite operator — for example, merging normalization, residual addition, and activation functions into one kernel invocation. Fusion reduces kernel launch overhead and intermediate read/write operations.

    Verification methodology:

    1. Use the chip vendor’s profiling tools to compare the number of kernels, per-launch latency, and per-step training time before and after fusion.
    2. Compare fused operator outputs against a reference implementation layer by layer, recording maximum absolute error and setting clear error thresholds under mixed precision.
    3. Keep only fusions that deliver measurable gains. Fusions with negligible benefits should not be incorporated into the main code path, to reduce maintenance overhead.

    Tensor Layout

    Tensor layout determines how data is arranged in memory, with common formats including NCHW, NHWC, and block-based layouts. Different chips support different layouts for convolution and matrix multiplication operators. Layout conversion itself incurs copy overhead, so layout selection should not be based solely on the speed of individual operators.

    The selection process should start with the chip vendor’s official documentation, then proceed to empirical testing with fixed input shapes: measure operator latency and layout conversion overhead under each candidate layout, and select the option with the lowest end-to-end total time.

    Parallel Strategies

    Training typically combines data parallelism, tensor parallelism, and pipeline parallelism. Configuration can follow this order:

    1. Determine the minimum parallelism required for model partitioning based on memory usage of parameters, gradients, optimizer states, and activations.
    2. Decide placement of parallel groups based on interconnect bandwidth. Tensor parallel communication is the most frequent and should be placed among cards with high-bandwidth interconnect within the same node.
    3. Evaluate the configuration using communication time as a share of total per-step time. If this ratio is high, consider adjusting parallel dimensions or overlapping communication with computation. This ratio serves as a starting point for investigation; specific thresholds depend on task scale.

    Troubleshooting Checklist for Out-of-Memory and Memory Access Issues

    When encountering out-of-memory errors or training speeds below expectations, investigate in the following order:

    1. Break down memory usage by category to confirm the respective proportions of parameters, gradients, optimizer states, and activations.
    2. If activations dominate, consider activation recomputation to trade compute for memory.
    3. If optimizer states dominate, consider sharding the optimizer states.
    4. If batch size is constrained, use gradient accumulation to reach an equivalent global batch size.
    5. Check per-card step time variance. Significant discrepancies usually indicate uneven data loading or a performance issue on a specific card.
    6. Inspect memory access patterns to check for frequent small-block copies or non-contiguous accesses.

    Training Stability and Fault Tolerance

    Training tasks above the ten-billion-parameter scale often run for hundreds of hours, and any single point of failure can interrupt training. Stability measures should include:

    • Checkpointing: Save model parameters, optimizer states, random seeds, and data loading positions at fixed intervals to ensure consistent data order after recovery.
    • Failure recovery: After a failure, restore from the most recent complete checkpoint and automatically isolate the node that experienced anomalies.
    • Retry strategy: Set a limited number of automatic retries for transient errors such as communication timeouts. The retry limit prevents faulty cards from continuously slowing down the entire task.
    • Monitoring metrics: Continuously record loss curves, gradient norms, per-card utilization, temperature, per-step duration, and communication timeout counts. Trigger alerts when metrics become abnormal.

    The Role of Cloud Services in Data and Scheduling

    Training data typically consists of massive image-text pairs, and data loading efficiency directly affects training speed. Object storage is suitable for storing raw data, but a large number of small files reduces read throughput. In practice, samples can be pre-packaged into sharded formats and read in parallel by shard.

    Container platforms handle cluster resource scheduling and task orchestration, and can quickly migrate tasks when node failures occur. Logging services and alerting systems are used to record and track the entire training process. These cloud service capabilities are generic; teams should select specific products based on their own data scale and operational capabilities.

    Validating Generation Quality with Business Scenarios

    When evaluating generation quality, use prompt sets drawn from your own business scenarios rather than relying solely on demo samples. The test set can cover the following types:

    • Science-education illustrations, e.g., “solar system diagram, children’s science picture book style” — check planetary positions, proportions, and scientific accuracy.
    • Film-style images, e.g., “sci-fi movie still” — check lighting depth and composition stability.
    • Multiple styles including realistic, illustrative, and design sketches — check style-switching consistency.
    • Mixed Chinese-English prompts — check whether semantic alignment remains stable.

    Recommendations for Evaluating Domestic Computing Solutions

    1. Require technical reports that specify evaluation benchmarks, comparison baselines, and measurement criteria. Without this information, performance claims are difficult to compare.
    2. Distinguish three categories of information: publicly available data, self-reported results from the team, and conclusions awaiting third-party reproduction. These categories should carry different weights in decision-making.
    3. Start with single-card and small-cluster throughput tests, then extrapolate to estimate time and cost for large-scale training.
    4. Before committing resources, run a validation pass using the troubleshooting checklist and stability measures described above, and confirm that the team can independently maintain the migrated training pipeline.

    Conclusion

    Training image generation multimodal models on domestic chips now has a viable engineering path. Teams should focus on operator fusion, tensor layout, parallel configuration, and training stability — areas where improvements can be measured incrementally. Every change should be backed by empirical data, and performance conclusions should await public evaluation and reproduction before being treated as definitive.