Training Cognitive Image Generation Models on Domestic Chips: A Technical Breakdown
This article explains how cognitive image generation splits language understanding from image rendering, and what it takes to train such a multi-branch model on domestic accelerators. It covers the two-branch architecture, engineering challenges around operator coverage, numerical stability and fault tolerance, native support for arbitrary aspect ratios, Chinese poster text rendering, and practical recommendations for training, inference and operations.
1. Why Cognitive Generation Is Becoming the New Direction for Image Models
The mainstream text-to-image paradigm works in two stages: a text encoder first maps the prompt into a conditioning vector, then a diffusion process gradually denoises in latent space. This pipeline is sensitive to whether an image looks good, but not to whether it is actually correct. Strong semantic constraints such as quantity relationships, spatial occlusion, text content, and layout hierarchy are often compressed away during encoding.
The core idea of cognitive generation is to split responsibilities: the language model handles understanding and planning, while the image generation model handles execution and rendering. The two are chained into a pipeline that can reason and verify. In engineering terms, the language side first emits a structured description of the scene (subjects, attributes, positions, text, style), and the generation side then performs pixel-level reconstruction based on that description. The direct benefit is better controllability: semantic changes after a prompt edit become traceable, and a failed sample can be attributed to either a misunderstanding or a rendering error.
2. Overall Architecture: Dividing Work Between the Semantic Understanding Branch and the Diffusion Decoding Branch
A repeatedly validated split is to divide the model into two branches of similar size:
- Autoregressive semantic branch: roughly 9B parameters, responsible for prompt parsing, global composition planning, and text content determination. It outputs an intermediate representation rather than the final image.
- Diffusion decoding branch: roughly 7B parameters, responsible for denoising under the constraints of the intermediate representation, ensuring correct glyphs, natural texture, and clean edges.
The value of this split is that training and iteration are decoupled. The semantic branch is trained mainly on image-text pairs, document layouts, and structured descriptions; the decoding branch is trained mainly on high-resolution images paired with intermediate representations. Each side can scale data and run evaluations independently, avoiding the coupled oscillation where one metric rises while the other collapses.
A schematic inference flow looks like this:
# Pseudocode: expresses data flow only, not a concrete APIplan = ar_model.parse(prompt) # structured scene descriptiontokens = tokenizer.encode(plan) # unified intermediate representationimage = diffusion.decode(tokens, size=(1240, 1600))
3. Full-Stack Domestic Training: The Hard Part Is Stability, Not Operators
Training this kind of multi-branch model on domestic accelerators usually puts the engineering focus on three areas.
The first is operator coverage and graph compilation. The autoregressive branch is dominated by attention over variable-length sequences, while the decoding branch is dominated by convolution, upsampling, and multiple denoising rounds. The two computation graphs differ significantly, so operators must be filled in and graphs optimized separately to avoid large amounts of fallback to generic operators, which creates slow paths.
The second is numerical stability. Under mixed precision, attention and normalization layers are the most prone to overflow and gradient scale drift. A common approach is to set precision policies per layer, keeping higher precision for sensitive layers, and to remove outliers from the loss.
The third is parallelism and fault tolerance. With the 9B and 7B branches resident at the same time, memory and communication overhead stack up, so the model must be partitioned using tensor parallelism, pipeline parallelism, and activation recomputation. Long-running training must rely on periodic checkpoints, resumable training, and slow-node isolation; otherwise a single hardware hiccup can consume days of compute.
A possible training configuration abstraction:
train:precision: mixed # sensitive layers use higher precisionparallel: [tensor, pipeline]recompute: truecheckpoint: {interval_steps: 500, keep_last: 3}fault_tolerance: {slow_node_detect: true, auto_resume: true}
4. Arbitrary Aspect Ratios: The Problem Lies in the Tokenizer and Position Encoding
Preset ratios such as 4:3 and 16:9 are essentially a limitation of training: the model has only seen a finite set of width-height combinations and has no inductive ability for non-standard sizes. To natively support any width and height in the range from 1024x1024 to 2048x2048, for example a portrait size like 1240x1600, two changes are usually needed.
First, decouple the tokenization and tiling strategy from width and height. Pass the grid size of the image tiles in as a variable instead of hardcoding a fixed grid, while keeping semantics intact within each tile so that text strokes are not cut off.
Second, make position encoding extrapolatable. The 2D position representation needs to support coordinates beyond the training range and normalize across different aspect ratios, so the model maintains consistent local continuity even at extreme ratios.
Engineering practice: sample by ratio buckets during training, covering extreme ratios while controlling their share; at inference time, progressively upscale out-of-range sizes and apply post-processing crops to reduce edge artifacts.
5. Direct Chinese Poster Output: Text Rendering Is the Hardest Constraint
Poster use cases have near-zero tolerance for text errors: glyphs cannot be missing strokes, layout cannot be misaligned, and font size hierarchy must be readable. A workable approach includes: the semantic branch explicitly outputs text content and region boxes, and the decoding branch performs glyph-constrained generation within the specified regions. For data, add a large amount of Chinese layout samples covering common styles such as Hei (sans-serif), Song (serif), and rounded fonts, as well as vertical and staggered arrangements. For evaluation, introduce character-level accuracy and region alignment metrics instead of only judging overall aesthetics.
6. Implementation Recommendations and Engineering Support
- Training side: prioritize a reproducible data pipeline and experiment tracking, making the impact of each change on both the semantic and decoding sides explicit.
- Inference side: expose resolution, aspect ratio, and text regions as explicit parameters so business teams can configure them.
- Operations side: use a container platform for elastic scheduling, object storage for checkpoints and assets, and logging and monitoring with alerts to track throughput, failure rate, and memory usage.
- If compute or data preparation is still being built out, evaluate the general capabilities of Baidu AI Cloud in heterogeneous compute scheduling, storage, and observability to reduce infrastructure investment.
7. Conclusion
Separating the language side’s understanding capability from the generation side’s rendering capability, and connecting them with a unified intermediate representation, is currently an effective path to better controllability and better Chinese text accuracy. Whether full-stack domestic training can work depends on the maturity of operator coverage, numerical stability, and fault tolerance. For teams, the safer order is to first build a solid evaluation system and data pipeline, and only then scale up the model.
