Boosting Resolution Generalization of Diffusion Transformers with Randomized Positional Encodings

Liang Hou, Cong Liu, Mingwu Zheng, Xin Tao, Pengfei Wan, Di Zhang, Kun Gai

TL;DR

RPE-2D (2D Randomized Positional Encodings) allows Diffusion Transformers (DiTs) to generate high-quality images at resolutions far beyond what they were trained on. By replacing fixed positional grids with a randomized sampling strategy during training, the authors transform a difficult "out-of-distribution" extrapolation problem into a manageable interpolation task, achieving state-of-the-art resolution generalization without increasing training costs.

What Problem Does This Paper Address?

Diffusion Transformers (DiTs) have become the backbone of modern generative AI, but they suffer from a rigid "resolution lock." If a model is trained on $256 \times 256$ images, it typically fails to produce coherent $512 \times 512$ or $1024 \times 1024$ images at inference time.

The primary culprit is the Positional Encoding (PE). Transformers use PEs to understand where patches of an image are located. Standard PEs are tied to a fixed coordinate grid. When you try to generate a larger image, the model encounters "new" positions it never saw during training, leading to a distributional mismatch. Existing fixes like Position Interpolation (PI) or NTK-aware scaling often result in blurry details or structural artifacts because they don't fundamentally bridge the gap between training and testing distributions.

Methods

The authors introduce RPE-2D, a framework consisting of three main pillars:

  1. 2D Randomized Positional Encodings: Instead of using a fixed $16 \times 16$ grid for $256 \times 256$ images, RPE-2D samples indices from a much larger "maximal grid" (e.g., $H \times W$). During training, the model sees a random subset of these positions, sorted to maintain relative order. This ensures that the specific positions required for high-resolution generation at test time have already been "statistically covered" during training.
  2. Data Augmentation & Micro-Conditioning: To prevent the model from memorizing specific distances, they use a random resize-and-crop strategy. They also introduce "micro-conditioning"—injecting the original image resolution and cropping coordinates into the model via Adaptive Layer Norm (adaLN). This helps the model understand the global context of the patches it is processing.
  3. Training-Free Sampling Strategies: At inference, generating more patches changes the math of the model. The authors apply Attention Scaling to account for the increased entropy in the attention mechanism and Timestep Shifting to maintain a consistent Signal-to-Noise Ratio (SNR) across different resolutions.

Datasets

The researchers evaluated their method using the standard ImageNet benchmark:

  • ImageNet-256: Models were trained from scratch at $256 \times 256$ resolution.
  • ImageNet-512: Models were fine-tuned at $512 \times 512$ resolution.
  • Evaluation: The models were tested on "extrapolation" tasks, such as evaluating a 256-trained model at 384 and 512, and a 512-trained model at 768 and 1024.

Key Insights and Ideas

  • Extrapolation as Interpolation: The core "aha" moment is that if you sample positions randomly from a large enough range during training, you never actually have to "extrapolate" at test time. You are simply interpolating between points the model has already seen.
  • Order > Absolute Distance: By using randomized sampling, the model stops relying on the exact pixel distance between patches and starts focusing on their relative order (e.g., "this patch is to the right of that one"). This makes the model much more robust to changes in scale.
  • SNR Consistency: The paper highlights that simply fixing PEs isn't enough. As resolution increases, the noise schedule's SNR changes. Shifting the timesteps during inference is crucial to keep the denoising process stable at higher resolutions.

Key Results

RPE-2D significantly outperforms existing methods like Position Interpolation (PI), NTK-aware scaling, and YaRN across both quantitative metrics and qualitative visual quality.

  • Quantitative: When trained at $256^2$ and evaluated at $512^2$, RPE-2D achieved an sFID of 18.23, a massive improvement over the previous best of 34.31 (YaRN).
  • Qualitative: Visual comparisons show that while other methods produce "repeated" patterns or blurry textures at high resolutions, RPE-2D maintains sharp details and global structural integrity (e.g., generating a single coherent eagle or panda rather than distorted fragments).
  • Efficiency: RPE-2D also acts as a "training accelerator." When fine-tuning a model for a higher resolution, starting with RPE-2D weights leads to faster convergence and lower initial loss compared to standard RoPE.

Limitations and Future Work

  • Maximal Grid Limits: While the method works well, there is likely an upper bound to the "maximal grid" size before the density of sampled points during training becomes too sparse for effective learning.
  • Text-to-Image Scaling: The experiments were conducted on ImageNet (class-conditioned). While the principles should hold for large-scale text-to-image models (like Stable Diffusion 3), the paper does not demonstrate results on these massive, open-domain datasets.
  • Computational Overhead: Although the inference-time adjustments are training-free, the micro-conditioning adds a small amount of complexity to the architecture that must be handled during the initial training phase.

Summary updated

BibTeX
@inproceedings{hou2026boosting,
  author = {Liang Hou and Cong Liu and Mingwu Zheng and Xin Tao and Pengfei Wan and Di Zhang and Kun Gai},
  title = {{Boosting Resolution Generalization of Diffusion Transformers with Randomized Positional Encodings}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i6.42478},
}

Loading related content...

Figure