Training Image Generation Models End-to-End on Domestic AI Chips: A Technical Breakdown
This article examines how to run the full image generation pipeline—data preprocessing, tokenization, pretraining, alignment, evaluation, and inference—on domestic accelerators. It explains the hybrid autoregressive-plus-diffusion architecture, the tokenizer and position encoding changes required for arbitrary resolutions, a practical decomposition of Chinese text rendering, and deployment guidance covering memory, consistency, controllability, and compliance.
1. Why End-to-End Training on Domestic Compute Matters
Over the past year, the competition in image generation has shifted from “can it generate at all” to controllability, text accuracy, and resolution flexibility. At the same time, an engineering question keeps coming up: can the training and inference pipeline run completely on domestic accelerator cards, rather than being adapted only at a few stages?
“End-to-end” usually means that data preprocessing, tokenization and encoding, large-scale pretraining, post-training alignment, evaluation, and inference deployment are all completed on the same stack of domestic compute and supporting frameworks. The value is not a lead on any single benchmark. It lies in supply chain control, more room for co-optimizing operators and frameworks, and a unified tuning baseline for cluster scheduling, fault recovery, and communication topology.
To be clear, moving across hardware platforms is not as simple as swapping a backend. The work usually concentrates in three areas. First, operator coverage and numerical stability: high-frequency operators such as normalization, attention, and optimizer state updates need hardware-friendly fused implementations. Second, mixed precision strategy: loss scaling and gradient clipping thresholds must be recalibrated. Third, distributed parallel partitioning: the combination of tensor parallelism, pipeline parallelism, and sequence parallelism has to match the actual interconnect bandwidth.
2. Hybrid Architecture: Autoregression for Understanding, Diffusion for Rendering
One technical route that has been repeatedly validated is chaining a large language model style autoregressive backbone with a diffusion-based decoder.
The autoregressive backbone (typically on the order of billions of parameters) handles semantic understanding, instruction parsing, and global composition planning. It outputs high-level semantic representations or discrete/continuous conditions. The diffusion decoder (commonly a DiT structure, with slightly fewer parameters) iteratively denoises in a low-dimensional latent space or pixel space to reconstruct texture, lighting, and detail.
The engineering benefit of this split is that the semantic layer can reuse the language model’s inference and context capabilities to handle multi-turn edits and complex constraints (for example, “leave the top-left corner blank and put three lines of small text in the bottom-right”). The pixel layer focuses on image quality and high-frequency detail, so the backbone does not have to carry both semantic and textural objectives at once, which makes convergence difficult.
The forward pass can be abstracted schematically as:
# Pseudocode: expresses data flow only, not any specific product interfacesemantic = autoregressive_backbone.encode(prompt, reference_image)plan = planner_head(semantic) # layout, subject position, color tone, and other conditionslatent = diffusion_decoder.sample(condition=plan, steps=N, cfg=w)image = vae_decode(latent)
Training is usually staged: pretrain the backbone on large-scale image-text pairs, then jointly train the condition alignment module, and finally fine-tune image quality and text with a small set of high-quality data. The advantage of staging is that every step has a verifiable convergence signal, so when something goes wrong you can quickly tell whether the issue is semantic alignment or decoding quality.
3. Non-Standard Resolutions: Tokenizer and Position Encoding Are the Key
Traditional generation models often support only a few preset aspect ratios (such as 1:1, 4:3, 16:9), because resolution is baked into the position encoding and bucketing strategy during training. To natively support arbitrary aspect ratios and arbitrary dimensions (for example, 1240×1600, anywhere between 1024×1024 and 2048×2048), three changes are typically required:
- Bucketing and sampling strategy: introduce finer-grained aspect ratio buckets during training and resample extreme ratios, so that a shortage of long-edge samples does not cause extrapolation to fail.
- Position encoding extrapolation: use an interpolable or scalable position encoding scheme so the token grid keeps relatively consistent spatial semantics when resolution changes.
- Scale consistency in the tokenizer: the same object should encode to similar semantic tokens at different resolutions; otherwise structures break apart after upscaling.
The direct benefit for developers is that scenarios requiring exact pixel dimensions—posters, social media covers, e-commerce main images—no longer need a “generate then crop or stretch” step, which reduces secondary loss and layout misalignment.
4. Chinese Text Rendering: Turning “Forgot the Character Mid-Stroke” into a Solvable Problem
Text generation is hard because glyphs are a high-frequency, discrete, strong-prior signal that does not fully match the continuous denoising objective of diffusion models. A workable decomposition is to add a separate text encoding branch that separates “content” from “glyph shape”:
- Content side: the backbone parses the string to render and its semantic position.
- Glyph side: a dedicated encoding module supplies stroke structure priors, injected into the decoder as an additional condition.
- Layout side: bounding boxes and alignment constraints prevent text overflow and mutual occlusion.
The practical recommendation is to treat text rendering as an evaluable subtask: build an evaluation set covering Chinese and English, digits, artistic fonts, vertical text, and mixed layouts, then report character accuracy, missing-character rate, and position hit rate separately instead of judging only the overall look.
5. Deployment Advice and Common Pitfalls
- Memory and throughput: the hybrid architecture has two backbones, so at inference time consider quantizing the semantic layer and caching the decoder step by step to control first-image latency.
- Consistency: when character or style consistency is needed, reuse reference image conditions rather than relying on text description alone.
- Controllability: structured inputs for layout, color scheme, and text content are more stable than long prompts.
- Engineering support: the training and inference pipeline can rely on a container platform for elastic scheduling, with object storage managing datasets, plus logging and monitoring with alerts to track loss, throughput, and failure rate.
- Compliance: generated content needs content safety review and labeling mechanisms; text assets in particular require attention to copyright and trademark risk.
6. Conclusion
Stacking together domestic compute, a hybrid architecture, arbitrary resolution, and controllable Chinese text points to one trend: image generation is turning from a single-model capability into an engineerable, evaluable, and governable system capability. For developers, the real barrier is no longer whether you can make a call, but whether you can measure and continuously optimize the three chains—semantics, layout, and glyph shape—separately.
