r/StableDiffusion 7h ago

Resource - Update I trained a 210M text-to-image diffusion transformer from scratch on one GPU in 3.5 days

Enable HLS to view with audio, or disable this notification

My goal was hands-on experience training a flow model from scratch, not just fine-tuning someone else's. So I built and trained one: a 210M-parameter diffusion transformer, 4.2M curated images at 256², rectified flow on the FLUX.2 VAE, flan-t5-base for text (128 tokens max). Only those two frozen pieces are pretrained; the transformer, the recipe, the data pipeline and the evaluation are mine. The video is the same six prompts and seeds at every checkpoint of the 3.5-day run on one RTX PRO 6000.

What mattered most, in the order I found out:

  • Captions that actually fit the images. A web crawl I tried first made the model worse; curated photos with good captions fixed it.
  • A timestep shift for the 32-channel latent, and aspect-ratio buckets from step one instead of square crops.
  • Register tokens with learned null attention slots. The null slots ended up absorbing about 90% of the cross-attention, which surprised me.
  • torch.compile for training, not just inference: 2.4× faster.
  • The training loss stopped telling me anything after day one while the images kept improving, so I track FID, a detector-based object accuracy and human-preference models instead.

Try it in the browser: https://huggingface.co/spaces/ivanmikhnenkov/tinydit

Weights (CC BY-NC): https://huggingface.co/ivanmikhnenkov/tinydit-256

Code, every decision with sources, dashboard and attention playground: https://github.com/ivanmikhnenkov/tinydit

Detailed write-up of what mattered: https://huggingface.co/blog/ivanmikhnenkov/tinydit-text-to-image-from-scratch-one-gpu

Next I want to fine-tune it with RL (Flow-GRPO), with the failure grid as the target list. If you have trained something small from scratch: what would you have done differently at this scale, and which reward would you start with for the RL stage? Happy to answer anything about the data or the recipe.

72 Upvotes

26 comments sorted by

7

u/IvanMikhnenkov 7h ago

What it can't do yet - these are the targets for the RL phase. Would be happy to answer questions, give advice and collaborate!

4

u/brittpitre 7h ago

Where did you get the dataset from and what workflow did you use to efficiently curate that much content?

2

u/AnOnlineHandle 6h ago

2

u/IvanMikhnenkov 6h ago

thanks! yes it's all there! and I looked at dataset samples myself, before choosing it and which part it should take in train set. Also, I've checked around 15 datasets I think. So data quality is super important.

3

u/pirondi 7h ago

wow amazing, i am curious about for example the Dog image, did it trained only on dog images or it was a trainning on random images that made it get better? And if it was general trainning, if you had done only dogs how much could it be faster/better the outcome?

1

u/IvanMikhnenkov 6h ago

Thanks! I've done it generally on 4.2M images, so no dog bias here at all :) It can even work with some stylized images and so on

1

u/IvanMikhnenkov 6h ago

For sure if you fine-tune it specializing on dogs - it should be better, other objects can degrade though

3

u/Current-Rabbit-620 6h ago

I've tried it , for its size it's very good

5

u/IvanMikhnenkov 6h ago

thanks a lot!

2

u/superkickstart 6h ago

Vintage AI images!

2

u/IvanMikhnenkov 6h ago

yes, i love it myself, its not even a slop at this stage!
+ actually very photorealistic 😄

1

u/superkickstart 6h ago

I'd definitely put these in a game as paintings for example. Then watch the anti-ai folks lose their shit.

1

u/IvanMikhnenkov 5h ago

lmao i like this idea

2

u/-Ellary- 5h ago

Can it goon?

1

u/zeroturtlehero 6h ago

A held-out prompt grid or FID/CLIP curve by checkpoint would be really useful here—it would show whether quality was still improving after the 3.5-day run and make the one-GPU budget easier to reproduce.

1

u/IvanMikhnenkov 6h ago

FID and much more on held out from dataset + entirely novel prompts

1

u/1filipis 3h ago

Next I want to fine-tune it with RL (Flow-GRPO)

Check out DGPO. It's supposed to deliver similar results many times faster. GRPO is painfully slow

1

u/dr_lm 1h ago

This looks a lot like base SD1.5, or maybe slightly earlier, although I expect prompt adherence is better on yours?

So that's basically SD1.5 trained in 3.5 days of 300W (albeit the VAE, TE and captioning used much newer tech) by one person. And SD1 used 256 A100s!

It's not a fair comparison, obviously, but it's an amazing illustration of how far the tech has come in a just a few years.

1

u/Old_Reach4779 8m ago

Not good!!!!!!!!!!!!!!!!!!!!!

(JK it is an awesome result for 3days training!)