Engineering Practices for Full-Stack Image Generation Model Training on Domestic Compute

    This article explores the engineering practices of full-stack domestic compute training for image generation models, covering the entire pipeline from data preprocessing to weight export. It translates user experience into reproducible engineering challenges by addressing task boundaries, technical routes, data alignment, training system validation, evaluation metrics, migration pitfalls, and pre-launch testing, ensuring reliable and reproducible model training.

    Full-stack domestic compute training means that data preprocessing, model training, evaluation, and weight export are all completed on a single set of domestic accelerator chips and deep learning frameworks, rather than merely shifting inference or fine-tuning to local clusters. For multimodal tasks like image generation, compute, communication, operator coverage, and numerical stability simultaneously become bottlenecks. The following translates “how good the experience is” into reproducible engineering problems: what the model actually learned, whether training can be resumed, whether metrics hold up, and whether the post-launch cost is acceptable.

    Defining Task Boundaries First

    Image generation typically encompasses three types of capabilities: text-to-image, image-to-image or local editing, and controllable generation bound to text understanding. Multimodal does not mean simply concatenating a vision encoder with a language model. Training objectives, condition injection methods, and evaluation sets must be designed together; otherwise, “SOTA” is merely a slice on a specific leaderboard.

    It is recommended to specify four things during project initiation. First, condition format: pure text, text plus reference image, or text plus layout/mask. Second, output specifications: maximum resolution, aspect ratio, and consistency requirements for batch generation. Third, failure definition: text rendering errors, anatomical structure collapse, style drift, and prompt ignoring. Fourth, resource limits: acceptable card-hours for a single training run, maximum recovery time after a fault restart, and inference latency budget. When boundaries are unclear, subsequent hyperparameter tuning will continuously expand the scope, making it impossible to determine whether the issue lies with the model or the task definition.

    Common Technical Routes and Trade-offs

    Mainstream industry routes generally include iterative generation like diffusion or flow matching, as well as autoregressive or hybrid discrete generation. Iterative models are often more stable for textures and lighting, where training and sampling steps directly determine throughput. Autoregressive routes facilitate the reuse of language model tokenization and alignment methods but are more sensitive to sequence length and error accumulation at high resolutions. There is no universally superior route; only the route that matches the data distribution, resolution, and deployment latency.

    Condition control usually feeds text encoding, image latent variables, and optional structural conditions into the same backbone. Cross-attention, adaptive normalization, or additional control branches all work. The difference lies in whether the operators are fully supported by the target framework, memory usage, and multi-card communication frequency. During full-stack domestic training, prioritizing structures with more regular operator graphs and standard collective communication patterns is more realistic than pursuing the latest but niche modules from papers.

    Latent space generation can reduce pixel-level computation but relies on high-quality autoencoders. The reconstruction error of the autoencoder directly becomes the generation limit: detail loss, color deviation, and text stroke adhesion often cannot be compensated by the diffusion or autoregressive backbone alone. If the business heavily relies on small text, lines, and UI screenshots, reconstruction metrics should be accepted separately, rather than just looking at the subjective aesthetics of the final generated image.

    Data and Alignment

    Multimodal data includes at least images, text descriptions, and optional masks, bounding boxes, and style labels. The focus of cleaning is not “the more images the better,” but whether the descriptions truly correspond to the visuals. Common noise includes: entity errors caused by machine translation, watermarks and borders, duplicate or near-duplicate samples, resolution and compression artifacts, and unsafe or infringing content. Duplicate data will cause the model to memorize specific compositions, looking “very stable” during evaluation but failing when the distribution changes.

    Description text should be layered: short titles, fine-grained descriptions, and negative constraints (elements that should not appear). Mixing conditions of different lengths during training ensures that the user prompt distribution during inference will not severely deviate from the training set. For editing tasks, paired original images, instructions, and target images should be saved, and it should be recorded whether masks were generated by automated tools. Systematic biases from automated masks will be learned by the model, manifesting as blurry edges or unchanged regions that should have been modified.

    Copyright and safety filtering should be completed before entering the data lake, rather than patched after training. In object storage, it is recommended to partition by dataset version, license type, and sensitivity level, and training jobs should only mount approved versions. This prevents newly crawled, unreviewed data from mixing into old experiments when reproducing them.

    Training System: Chips, Frameworks, and Jobs

    Full-stack training must validate more than just “can run a single step.” It must at least include: numerical alignment of operators on the target framework, mixed precision strategies, equivalence of gradient accumulation and large batches, complete checkpoint saving and cross-node recovery, and ensuring data loading is not a bottleneck.

    Numerically, generative models are highly sensitive to normalization, attention, and noise schedules. When migrating from a general GPU framework to another framework, use the same mini-batch and random seed for forward and backward comparisons, first aligning the trend of the loss curve before discussing final image quality. Floating-point errors are allowed, but loss explosions, systematic color channel shifts, or constant outputs from a certain layer are not. Mixed precision should record the loss scaling range and overflow fallback strategy; otherwise, the “same configuration” on different clusters is actually not the same experiment.

    In terms of communication, the choice of data parallelism, tensor parallelism, and pipeline parallelism depends on single-card memory and sequence or latent variable length. Image models have large activation volumes. Gradient checkpointing can trade time for memory but will lengthen step time. Fault recovery relies on periodically saving optimizer states, not just model weights; saving only weights means that subsequent training after a breakpoint requires re-warmup, causing the cost of large experiments to spiral out of control.

    For scheduling, use a container platform to submit jobs, place data in object storage or a parallel file system, and route logs and metrics to a logging service and monitoring alerts. Alerts should cover at least: sudden step time spikes, loss becoming NaN, node disconnection, data read failure rate, and checkpoint write failures. These signals can detect “training is actually broken” earlier than final sample images.

    An illustrative training configuration should remain neutral and portable, expressing only hyperparameter meanings without binding to a specific vendor’s interface:

    1. train:
    2. precision: mixed
    3. grad_accum_steps: 4
    4. ckpt_every_steps: 1000
    5. resume: latest_complete_ckpt
    6. data:
    7. resolution_buckets: [512, 768, 1024]
    8. caption_dropout: 0.1
    9. eval:
    10. every_steps: 2000
    11. fixed_prompts: prompts/holdout.txt
    12. seeds: [0, 1, 2, 3]

    Fixed prompts and fixed seeds ensure the curves are comparable. If random prompts are changed every evaluation round, subjective “improvements” cannot be attributed.

    How to Define “Actual Effects”

    Break the experience into measurable dimensions rather than single random draws.

    Fidelity: Whether the objects, quantities, attributes, and spatial relationships in the prompt appear. A manual comparison table can be used, assisted by detection or classification models for rough recall, but automated metrics cannot replace fine-grained relationships, such as “red cup on the left, blue cup on the right.”

    Structure and Geometry: Whether limbs, perspective, and symmetrical objects collapse. At high resolutions, good local details with wrong global structure is a common failure mode. The evaluation set should intentionally include scenarios with multiple people, hands, text, and straight lines.

    Text Rendering: If the business requires in-image text, build a separate set, count character-level or word-level accuracy, and distinguish between specific font style requirements and “just readable.”

    Editing Consistency: Areas not requested for modification should maintain identity, background, and lighting. Reconstruction error outside the mask can be used as an auxiliary, but manual review is still needed to see if semantics have been altered.

    Diversity and Mode Collapse: Multiple samplings with the same prompt should neither be completely identical nor randomly drift to unusable styles. Record differences under different seeds to avoid only showing the best one.

    Efficiency: Training step time, sample throughput, card-hours required to achieve acceptable quality, inference steps or equivalent computation, and peak memory. Quality comparisons without efficiency constraints cannot guide whether it is worth putting into production.

    Safety and Refusal: There should be a filtering or refusal strategy for obviously inappropriate content, and false rejections should be evaluated separately. The “increase in capability” of generative models is sometimes accompanied by an increase in risk. The launch checklist should place filtering at the gateway layer outside the model, making it easy to update rules without retraining.

    The evaluation set must be isolated from the training set, and the construction date should be recorded. Using popular prompts seen during training for demonstration will systematically overestimate the effects.

    Common Pitfalls When Migrating to Domestic Frameworks

    First, inconsistent data preprocessing. Different scaling algorithms, color spaces, and normalization means will cause “weights unchanged, style changed.” Preprocessing should be versioned and documented alongside the weights.

    Second, random numbers and data order. If multi-machine data shuffling relies on a specific library’s implementation, the sample order will change after resuming training, causing steps in the loss curve. Important experiments should fix the sharding rules.

    Third, silent operator fallback. When an operator is not accelerated and falls back to a slow path, the result may still be correct, but throughput drops by an order of magnitude. During troubleshooting, this might be mistaken for a communication issue. Monitoring should show the operator time consumption distribution.

    Fourth, mismatch between sampler and training objective. The noise schedule and time step sampling used in training and the solver used in inference must be recorded in pairs. Simply changing sampling steps to “improve image quality” sometimes just masks the fact that the training objective was not learned well.

    Fifth, resolution extrapolation. Training at a lower resolution and directly pulling it to a higher resolution will destabilize composition and high-frequency details. If multiple resolutions are needed, explicit bucketing should be used during training, rather than temporary upscaling at launch.

    Minimum Closed Loop Before Launch

    Before release, it is recommended to fix a regression suite: dozens to hundreds of prompts covering style, text, number of people, lighting, and editing instructions; three random seeds; two resolutions; a training smoke test resumed from a checkpoint; and an inference service timeout and batch size stress test. Regression results are bound to weights, data version, framework version, and preprocessing version. Any version change requires a re-run, not just updating the example images in the copy.

    In terms of service form, training and inference can be separated: the training cluster produces weights, the online side uses a container platform for elasticity, and object storage stores models and audit logs. Rate limiting, content moderation, and prompt log desensitization are platform capabilities and should not be stuffed into the model weights themselves. This way, policy adjustments do not have to wait for retraining.

    If organizing jobs in a cloud environment like Baidu AI Cloud, you should similarly rely only on general capabilities: object storage for datasets and checkpoints, container platforms for scheduling training and inference, and logs and monitoring for observing step time and failure rates. Do not treat the cloud platform as an explanation for model effectiveness; effectiveness is still defined by data, objectives, and evaluation.

    Conclusion

    Whether domestic chips and frameworks can support frontier image generation does not depend on a single demo image, but on whether the full process is reproducible: clear data versions, alignable numerical values, resumable breakpoints, metrics covering fidelity and efficiency, and risk filtering independent of weights. By turning “actual experience” into fixed-prompt regressions and resource bills, the team can determine whether full-stack training is genuinely usable or merely completed an experiment that could run.