Text-to-Image Model Training on a Full Domestic Compute Stack: Engineering Practices and Challenges

    This article examines the engineering implications of training text-to-image models end to end on a domestic AI compute stack rather than training on mainstream GPUs and adapting only the inference side. It outlines the core components of text-to-image systems, discusses operator coverage, distributed training, data engineering, and training stability on non-mainstream hardware, reviews inference deployment and user experience considerations, and offers selection guidance for developers and enterprises evaluating full-stack domestic training.

    1. Why End-to-End Domestic Training Is a Dividing Line for Text-to-Image Models

    Over the past few years, the typical path for most open-source or commercial text-to-image models has been to complete training on mainstream GPU clusters and then, if domestic deployment requirements must be met, perform a separate round of inference-side operator adaptation and migration. This “train on A, infer on B” model has several long-overlooked problems:

    1. Inconsistent numerical behavior between training and inference. Training frameworks and inference engines often differ in operator implementations and precision strategies such as mixed FP16/BF16/FP32 execution. After migration, this can cause slight drift in generation quality and make random seeds irreproducible.
    2. High secondary adaptation cost. Incomplete operator coverage, communication library compatibility, and rewritten distributed strategies can turn migration into an independent engineering project.
    3. Limited optimization space. On the inference side, the work is limited to adapting the model as closely as possible to the original training behavior. It cannot redesign training strategies for the target hardware.

    The significance of full-process domestic training is that data processing, model training, evaluation, and inference deployment are completed in a closed loop within the same software and hardware stack. This means every part of the model—from data cleaning rules to loss function implementations, from distributed parallelism strategies to sampler implementations—can be natively optimized for the target hardware rather than being a “translated” version.

    2. Core Technical Components of Text-to-Image Models

    To understand the difficulty of full-stack training, it is useful to break down the technical layers of a typical text-to-image system:

    1. Text encoder. It maps Chinese and English prompts into semantic vectors. Chinese-language scenarios place higher demands on tokenization, vocabulary coverage, and long-text understanding. This is a key difference between Chinese text-to-image models and English-dominated models.
    2. Diffusion backbone. Mainstream approaches are based on diffusion models, which generate images through step-by-step denoising. In recent years, a major evolution direction has been replacing traditional U-Net architectures with Transformer-like architectures to achieve better scalability and text-image alignment.
    3. Variational autoencoder (VAE). It converts between pixel space and latent space, and its reconstruction quality directly affects the detail fidelity of the final image.
    4. Sampler and scheduler. They determine the balance between inference steps and generation quality and are a key optimization target for inference acceleration.

    3. Key Technical Points for Training Text-to-Image Models on a Domestic Compute Stack

    End-to-end training of these models on a non-traditional GPU system requires solving several categories of problems.

    3.1 Operator Coverage and Custom Implementations

    Diffusion model training involves many specialized operators: attention mechanisms, especially FlashAttention-like optimizations for long sequences; group normalization; sinusoidal positional encoding; diffusion scheduling computation; and others. The compute software stack for domestic chips must provide high-performance implementations of these operators. When an operator is missing, it must be replaced by combinations of basic operators and verified for numerical precision.

    A typical practice is to first run operator-level alignment tests on a small-scale model, compare errors in intermediate tensors, and then scale up to full training after confirming there are no anomalies. An illustrative verification flow is shown below:

    1. # Pseudocode: operator precision alignment verification flow
    2. for op in critical_ops: # attention, normalization, scheduler, etc.
    3. ref_out = reference_impl(op, test_inputs)
    4. local_out = local_hardware_impl(op, test_inputs)
    5. assert max_diff(ref_out, local_out) < tolerance

    3.2 Distributed Training Strategies

    Text-to-image models have large parameter counts, and training data mainly consists of image-text pairs. Common parallel combinations include data parallelism, tensor parallelism, pipeline parallelism, and sequence parallelism for attention computation. Domestic clusters may have communication libraries and network topologies that differ from mainstream solutions, so retuning is required:

    • The overlap ratio between communication and computation must be recalibrated based on actual bandwidth.
    • The combination of gradient accumulation and mixed precision must be adjusted according to the hardware’s BF16 support.
    • Checkpoint resume and fault tolerance mechanisms are essential for high-throughput, long-cycle training.

    3.3 Data Engineering

    The cleaning, deduplication, scoring, and annotation system for Chinese image-text pair data determines the model’s response quality to Chinese semantics. The benefit of full-stack autonomy is that the data pipeline can run directly on domestic compute, including large-scale image-text matching filtering, aesthetic scoring, and sensitive content processing. This avoids dependence on heterogeneous compute during data preparation.

    3.4 Training Stability

    Diffusion model training is sensitive to loss weights, noise schedules, and EMA (exponential moving average) strategies. On a new hardware stack, any small numerical difference can be amplified over a long training cycle. Common practices include:

    • Using segmented learning rate warmup and cosine decay.
    • Monitoring loss curves, gradient norms, and sample generation quality in real time across multiple dimensions.
    • Building a fixed-seed regression evaluation set and performing quality regression comparisons at fixed step intervals.

    4. Inference Deployment and Actual Experience

    From a user’s perspective, the final experience of a text-to-image model trained on a full domestic stack is determined by the following factors:

    1. Prompt adherence. Whether Chinese prompts are understood naturally and whether “translation-style” prompt engineering is required is the most direct point of perception for Chinese users.
    2. Generation quality and diversity. This includes detail performance in styles such as realism, illustration, and design sketches, as well as performance in classically difficult scenarios such as hands and text rendering.
    3. Inference latency and concurrency. Relying on inference optimizations for domestic chips—such as graph compilation, operator fusion, and quantization—can the system provide acceptable latency and throughput in production environments?
    4. Collaboration with multimodal systems. When a text-to-image model serves as a capability module within a larger model system, such as an understanding-generation integrated multimodal assistant, the standardization of interface protocols and context passing determines integration cost.

    From an engineering integration perspective, accessing such a model usually follows a standard HTTP inference service pattern, as illustrated below:

    1. # Pseudocode: text-to-image service call example
    2. resp = client.generate(
    3. prompt="国风水墨,远山如黛,一叶扁舟",
    4. style="ink_painting",
    5. width=1024, height=1024,
    6. steps=30,
    7. seed=42
    8. )
    9. image = decode(resp["image_base64"])

    5. Selection Advice for Developers and Enterprise Users

    1. Pay attention to the “training-inference consistency” commitment. If the business has domestic-compliance requirements, prioritize models that are natively trained on a full stack rather than only adapted for inference. The former provides stronger guarantees for effect consistency and long-term maintenance.
    2. Evaluate the depth of Chinese-scenario adaptation. Vocabulary coverage, Chinese long-prompt understanding, and Chinese character rendering capability should be verified through a self-built evaluation set rather than relying only on general leaderboards.
    3. Value engineering support. Model weight formats, inference framework compatibility, quantization schemes, and containerized deployment support determine the distance from demo to production.
    4. For cloud deployment, consider common capabilities provided by mainstream cloud platforms. These include GPU/domestic compute instances, object storage for training data hosting, container platforms for training job orchestration, and monitoring and alerting. The complexity of model training and service operations can be left to the infrastructure layer.

    6. Conclusion

    The value of a text-to-image model trained through a full domestic process is not only that it is “usable.” More importantly, it validates a complete technical loop: from operator-level numerical alignment to distributed training strategy reconstruction, and then to data engineering and inference optimization, all completed within an autonomous and controllable software and hardware system. For developers, this means that high-quality image generation capabilities can be built in the future without depending on a specific overseas compute ecosystem. For enterprise users, compliance and supply chain security gain a practical additional option. As the domestic AI compute software stack continues to mature, the model of “training is adaptation, deployment is native” is expected to become one of the mainstream industry practices.