3 min readfrom Machine Learning

Training a 210M text-to-image DiT from scratch on one GPU: what I measured [P]

Our take

This project details the training of a 210M-parameter text-to-image diffusion transformer from scratch on a single GPU, yielding valuable insights into the underlying mechanics. Three key measurements emerged: learned null attention slots acting as a sink, the flow-matching loss serving as a health signal rather than a direct quality indicator, and the significant impact of training-time timestep shifts. Explore the full details, including code and weights, on GitHub and Hugging Face. For further understanding of related architectures, see our analysis of CABiNet’s performance on UAVid.
Training a 210M text-to-image DiT from scratch on one GPU: what I measured [P]

The recent demonstration of training a 210M-parameter text-to-image diffusion transformer from scratch on a single GPU is a compelling achievement, and one that highlights a significant trend towards more accessible and understandable AI development. It’s a welcome counterpoint to the relentless pursuit of ever-larger models, reminding us that impactful research can still emerge from focused, well-executed experiments. This work builds upon earlier explorations of efficient architectures; for example, CABiNet (ICRA 2021) vs YOLO26-sem on UAVid: accuracy, compute, and GPU latency similarly focused on optimizing performance within resource constraints, albeit in a different domain. The author’s meticulous measurement of training dynamics – specifically the allocation of cross-attention, the behavior of the flow-matching loss, and the impact of timestep shifts – provides invaluable data points that are often glossed over in larger-scale training runs. The open-sourcing of the code and weights further amplifies the impact, allowing researchers and practitioners to readily reproduce and build upon these findings.

What makes this project particularly noteworthy is the author’s focus on understanding *how* the model learns, rather than simply showcasing impressive image generation capabilities. The observation that learned null attention slots effectively become a “sink” for attention mass, while the flow-matching loss doesn't necessarily correlate with image quality, are subtle but crucial insights. It challenges conventional wisdom and encourages a more nuanced approach to training diffusion models. The detailed analysis of timestep shifting is another example of this analytical rigor. It’s interesting to consider this alongside the exploration of sparse causal attention in architectures like Monodratic: learned product-hash routing for sparse causal attention, which also seeks to optimize computational efficiency through intelligent architectural design. The author’s decision to prioritize these measurements over showcasing high-fidelity image samples reflects a commitment to advancing the foundational understanding of these models, rather than chasing purely aesthetic results.

The technical details shared – the dataset composition, the training hyperparameters, and the implementation choices – are remarkably transparent. The use of `torch.compile` to accelerate training demonstrates a pragmatic approach to optimization, highlighting the importance of leveraging available tools to maximize efficiency. The author’s data mix, blending Pexels, FLUX-Reason-6M, and COCO with GPT-4V captions, also points to a deliberate effort to balance dataset size, quality, and diversity. This careful consideration of data curation is often underestimated, but it plays a critical role in the model’s ability to generalize and produce meaningful results. The resulting "TinyDiT" model, despite its relatively small size, exhibits surprisingly strong performance, demonstrating that scale isn't always the defining factor in achieving impressive outcomes.

Looking ahead, the author’s question regarding the optimal reward function for the next phase of development – exploring Flow-GRPO – is a particularly intriguing one. Should the focus be on detector-based object accuracy, PickScore/HPSv2, or something more verifiable like counting objects? This choice will likely have a significant impact on the model’s downstream capabilities and its ability to align with human preferences. Ultimately, this project serves as a powerful reminder that innovation in AI doesn't always require massive computational resources or unprecedented model sizes. It's often the careful experimentation, meticulous analysis, and open sharing of knowledge that drive the most meaningful progress.

Training a 210M text-to-image DiT from scratch on one GPU: what I measured [P]

I trained a 210M-parameter text-to-image diffusion transformer from scratch (3.5 days, one RTX PRO 6000, 4.2M images at 256²) mainly to understand the recipe end to end. Three measurements came out of it that I have not seen stated plainly elsewhere, so I'm posting those rather than the samples.

1. Learned null attention slots become the sink. Following the register-token idea, the model has 16 register tokens in the image stream plus 2 learned key/value slots appended to every cross-attention. At mid-noise in a middle block, those 2 slots receive ~90% of the cross-attention mass; the EOS token, which is the usual sink in cross-attention models, drops to ~4%; content words keep a few percent each, sharply on their objects. Register vectors grow to 4–13× the norm of image tokens by the middle blocks.

2. The flow-matching loss is a health signal, not a quality signal. It moved 0.805 → 0.754 over the whole run while held-out FID went 33.7 → 27.0, FD-DINOv2 570 → 218 and detector-based object accuracy 65% → 90%. Most of the loss at high noise is the irreducible variance of the velocity target; training and held-out loss stayed equal to the third decimal for 24 epochs.

3. The training-time timestep shift is worth more than doubling the steps. On 2,456 held-out prompts with the final weights: 20 steps with shift 2.8 → FID 27.0; 50 steps → 26.6; 8 steps → 28.4; 20 steps with no shift → 27.3 and FD-DINOv2 218 → 228. Shift 2.8 comes from the SD3/RAE rule √(32·32·32/4096) for the 32-channel FLUX.2 latent.

Setup, briefly: cross-attention DiT (896 × 16 blocks), 2D RoPE, QK-norm, SwiGLU, adaLN-single; rectified flow with logit-normal timesteps and the shift above; cosine velocity and dispersive auxiliary losses; five aspect-ratio buckets of ~256 tokens from step one; flan-t5-base frozen, long/short caption per image sampled 50/40/10 (empty). Data: Pexels 2.8M (60%), a quality-filtered 1.2M slice of FLUX-Reason-6M (25%), COCO with GPT-4V captions (15%). batch 256, 400k steps, EMA 0.9999, linear LR decay over the last quarter, torch.compile (2.4× over eager).

Everything, with the sources for each decision: https://github.com/ivanmikhnenkov/tinydit

Write-up: https://huggingface.co/blog/ivanmikhnenkov/tinydit-text-to-image-from-scratch-one-gpu

Weights: https://huggingface.co/ivanmikhnenkov/tinydit-256

Demo: https://huggingface.co/spaces/ivanmikhnenkov/tinydit

For the next phase (Flow-GRPO on this base), which reward would you start with: PickScore/HPSv2, a detector-based object reward, or something verifiable like counting?

submitted by /u/IvanMikhnenkov
[link] [comments]

Read on the original site

Open the publisher's page for the full experience

View original article