Abstract
Traditional diffusion models are constrained by fixed-resolution training, leading to data degradation and poor generalization to non-square aspect ratios. We present the Native-resolution diffusion Transformer (NiT), a generative model designed to learn directly from images in their original resolutions and aspect ratios. By treating images as variable-length token sequences and employing techniques like 2D Rotary Positional Embeddings (RoPE) and sequence packing, NiT achieves state-of-the-art performance on ImageNet benchmarks while demonstrating remarkable zero-shot generalization to resolutions up to 2048x2048. NiT bridges the gap between vision and language modeling by applying sequence-length flexibility to pixels, offering a more efficient and versatile approach to image synthesis.
Introduction
Most current image generation models, such as DiT or Stable Diffusion, are "resolution-experts" but "format-illiterate." They typically require images to be resized and center-cropped into fixed, square dimensions (usually 256x256 or 512x512) during training. This standard approach introduces three major drawbacks:
- Data Degradation: Resizing introduces blurriness or loses high-frequency details, while cropping discards essential semantic context.
- Inhibited Generalization: Models trained only on squares struggle to generate wide panoramas or tall portraits, often producing "cropping bias" where objects are unnaturally centered or cut off.
- Inefficiency: To support multiple resolutions, developers often train separate models for each size, which is computationally expensive and redundant.
NiT addresses these challenges by asking: Can we build a model that learns from images exactly as they are, regardless of their shape or size?
Methodology
NiT treats images as variable-length sequences of tokens, much like how Large Language Models (LLMs) treat text. The architecture incorporates several key innovations to handle this flexibility:
- Dynamic Tokenization & Packing: Instead of padding images to a fixed size—which wastes computation—NiT converts images into variable-length token sequences. To maintain GPU efficiency, it "packs" multiple different-sized images into a single long sequence, utilizing an algorithm borrowed from efficient LLM training.
- Axial 2D Rotary Positional Embedding (2D RoPE): Standard positional embeddings are often tied to a specific grid size. NiT uses 2D RoPE to factorize height and width impact, allowing the model to understand relative spatial relationships flexibly and operate on resolutions it has never seen during training.
- Packed Adaptive Layer Normalization (Packed-AdaLN): Since a single batch contains tokens from multiple different images, the model uses a specialized normalization layer to ensure each image's tokens are conditioned correctly based on their specific metadata, such as class labels or timestamps.
- FlashAttention-2 Integration: To handle the heterogeneous, unpadded sequences efficiently, the model utilizes FlashAttention-2, significantly reducing memory overhead.
Experimental Setup
The model was evaluated across several diverse datasets:
- ImageNet-1K: Used for class-guided image generation, where the model was trained on "native" versions of images rather than forced squares.
- COCO-2014: Utilized for zero-shot evaluation of text-to-image capabilities.
- SAM (Segment Anything Model) Dataset: Employed for training the text-to-image version of the model (NiT-T2I).
Key Results and Insights
State-of-the-Art Performance
A single NiT-XL model achieved an FID of 1.45 on ImageNet 512x512, surpassing the previous state-of-the-art (EDM2-XXL) despite having half the parameters. On 1024x1024 resolution, NiT achieved an FID of 4.52, while traditional models like FiTv2 and SiT-REPA failed to produce coherent images at that scale.
Zero-Shot Scaling and Generalization
By training on original aspect ratios, the model avoids the "truncation bias" common in other models. For example, when generating a guitar, NiT can render the whole instrument in a tall aspect ratio, whereas square-trained models often crop the headstock. Remarkably, NiT—trained primarily on ImageNet-scale data (mostly 200-600 pixels)—can generate high-fidelity 2048x2048 images without any additional fine-tuning.
Efficiency
NiT is faster to train and has lower inference latency than the standard DiT architecture. It achieves its results using only approximately 37% of the token budget required by some competitors, demonstrating that sequence-length flexibility is as powerful for pixels as it is for words.
Conclusion and Future Work
NiT successfully demonstrates that training on native resolutions leads to superior generalization and efficiency. However, the authors note that at extremely high resolutions or very disparate aspect ratios, quality is not yet perfect. Future research will focus on finding the optimal "recipe" for balancing small and large images in a single batch and extending this native-resolution paradigm to video generation, where aspect ratio and resolution variety are even more prevalent.
Summary updated