Manuscript Offprint
arXiv:2610.18870Dog-Breed Text-to-image Flow Matching from Pretraining to Fine-Tuning on 4 Consumer GPUs
Abstract
We generally perceive that training text-to-image diffusion models requires heavy compute: it is true if we aim at a comprehensive frontier model. This understanding prevents people from training their own models when getting started in the field. We develop MiniDog, a framework that enables pretraining diffusion transformers in 55 minutes and fine-tuning in another 15 minutes on four 3090 GPUs. For data, we use 26k dog images from ImageNet and caption them for pretraining and use 2k images generated by FLUX.1-schnell for fine-tuning. We precompute the image and text features and cache them for efficiency. For architecture, we use E2E-INVAE for its semantic latent space, a small transformer with 22M parameters, a small Qwen model for text encoding, and in-context conditioning. For training, we use iREPA and an EUPE perception encoder for acceleration. For evaluation, our repository supports FID, HPSv2 score, PickScore, and various VAE reconstruction metrics. The project is open-sourced at GitHub. We do not claim technical novelty.

Figure 1: Samples from the SFT model. Prompts of the highlighted samples: ■ “Golden Retriever with a dark golden, freshly brushed…” ■ “Corgi with a clean fawn-and-white coat stands alert…” ■ “Samoyed with a fluffy biscuit double coat sleeps curled…”
1 Introduction
Training diffusion models is computationally heavy, especially for frontier models. In the community, beginners often struggle to find the opportunity to do the whole pipeline. This paper presents MiniDog, a simple yet useful codebase, where pretraining and fine-tuning of text-to-image (T2I) models can be performed in about an hour and 15 minutes, respectively, on four 3090 GPUs.
Concept. This material presents data, architecture, training methods, and evaluation metrics for T2I model training. Flow-matching beginners can train their own T2I models efficiently.
Leveling and prerequisite knowledge. The material targets advanced undergraduate and graduate courses and assumes linear algebra, calculus, probability, and deep learning.
Learning objectives and outcomes. On completing the material, beginners can:
• build and pretrain a text-to-image flow-matching pipeline on consumer GPUs (Section 3);
• explain how the tokenizer, caption length, and representation alignment change FID; and
• fine-tune the model and evaluate it with human-preference models.
In the sampling phase, noise at t = 1 gets back to data at t = 0 by following the velocity predicted by the denoising model. The denoiser is now typically a transformer. Diffusion Transformer (DiT) [4] establishes this architecture by adapting Vision Transformers [5] to latent space, which has replaced legacy U-Nets [6]. We use LightningDiT [7], a more efficient variant that improves the standard DiT backbone with training upgrades such as rectified flow and logit-normal timestep sampling [8]. It converges faster than the standard DiT without losing image quality.
Representation alignment accelerates diffusion model training [9]. In REPA, the intermediate layers of the student model align to the output features of the teacher model, making the learning model rely both on its own generative capability and teacher knowledge. In other words, REPA takes the hidden states h of the N patch tokens at an intermediate block, maps each through a small learned projector , and pulls it toward the target feature of the same patch of the clean image:
where indexes patches and is a distance (cosine or squared error), and . is the clean image feature extracted by an external perception model such as DINOv2 [10]. iREPA [11] builds on REPA by transferring more of the spatial structure of the teacher model (the target representation), which further speeds up convergence. Appendix A gives the details.
Latent tokenizers. Latent diffusion [12] trains the denoiser on the compressed latents of a tokenizer (a VAE) instead of pixels. VAVAE [7] aligns these latents with a pretrained vision encoder, distilling its semantics into the tokenizer so that the latents are easier to learn. REPA-E [13] goes further: besides bringing in these semantics, it enables joint optimization of the tokenizer and the diffusion model.
3 The MiniDog resource
Data. Pretraining uses 26,000 recaptioned ImageNet [16] images of 20 dog breeds. Supervised fine-tuning (SFT) uses 2,000 high-quality images of the same breeds that we generate with FLUX.1-schnell [17] from text prompts written by GPT-5.5 in the same structure as the real-photo captions. Evaluation uses 500 held-out prompts. All three datasets have been released on HuggingFace.
Pipeline is depicted in Fig. 2, where we adopt the DiffusionBench framework [18]. During pretraining, we pass the image caption through Qwen3-0.6B [14] and obtain text tokens. The paired image is fed to a VAE and an external vision encoder (e.g., DINOv2). Noise is added to the image latent. Timestep and text tokens are concatenated with the noisy latents into one sequence (in-context conditioning [4]) and this sequence is fed into the diffusion transformer. The vision perception tokens, on the other

Figure 2: T2I pretraining recipe. Frozen Qwen3 [14], E2E-INVAE [13] and EUPE ViT-B/16 [15] produce the text embeddings, the latents (noised with ) and the alignment targets. LightningDiT [7] is pretrained with the flow-matching loss [2] and the iREPA [11] loss on Block 4.
hand, are used to align with intermediate diffusion features (REPA loss Eq. 2) at Block 4, where our diffusion transformer has 12 blocks in total. The flow matching loss (Eq. 1) is also applied. At the SFT stage, we turn off the REPA loss and only use flow matching loss.
The tokenizer (VAE) is always frozen. Images are encoded into latents which are cached and reused during training: this reduces training time significantly. Unless otherwise stated, we pretrain for 200 epochs ( 20k steps) and SFT for 100 epochs ( 700 steps). Appendix C lists all hyperparameters.
Methods supported. From architecture point of view, MiniDog supports latent diffusion with a 12-block transformer with 22.06M parameters and in-context conditioning. For VAE, the project supports E2E-INVAE and E2E-VAVAE [13]. For REPA, we support original REPA and iREPA. Various vision encoders can be used, including DINov2, DINov3 [19], PE-Spatial [20], and EUPE [15]. Our repository also allows for supervised fine-tuning and reward-model-based scoring.
Evaluation metrics supported. We measure generation quality using gFID [21]. Specifically, we use all the 26k real pretraining images as the reference set and generate 26k images using the same pretraining prompts. The two sets of images are used for gFID calculation. We measure tokenizer reconstruction using PSNR, SSIM [22], LPIPS [23] and rFID. To assess the effect of SFT, we use two human-preference models, HPSv2 [24] and PickScore [25]. The two scores are averaged over 500 images that the pretrained and the SFT checkpoints (ckpts) each generate from 500 held-out prompts. Inherited from DiffusionBench, our repository supports online evaluation, where intermediate checkpoints can be evaluated during training. Online evaluation will double the pretraining time and add about an hour to SFT. Appendix B explains each metric in more detail.
4 Results
4.1 Our best recipe
Quality of generated images. Our best pretraining recipe is to use E2E-INVAE as tokenizer, 128-token captions, iREPA for acceleration with mean squared error loss, and EUPE as the external vision encoder. As shown in Table 2, this method yields gFID = 8.32. We then apply standard SFT. As shown in Table 4, SFT gives us HPSv2 = 0.2427 and PickScore = 19.61.
Efficiency. Using RTX 3090 GPUs, pretraining for 200 epochs takes 55 minutes, while SFT for 100 epochs takes 15 minutes. If using a single RTX 3090 GPU, pretraining for 200 epochs takes about 3 hours, while SFT for 100 epochs takes 21 minutes. Qualitative results after SFT are shown in Fig. 1. Training the best recipe on a single GPU with the provided configuration (micro-batches of 64 with 4 gradient-accumulation steps, bf16) needs at least 10 GiB of VRAM, or 15 GiB if FID is evaluated during training. Also note that the image and text tokens are precomputed and cached, which takes about 15 minutes on one 3090 GPU.

Figure 3: VAE diffusability comparison. Pretraining gFID with EUPE, iREPA, and 128 tokens.
| PSNR↑ | SSIM↑ | LPIPS↓ | rFID↓ | |
|---|---|---|---|---|
| E2E-INVAE | 28.42 | 0.792 | 0.039 | 1.14 |
| E2E-VAVAE | 27.59 | 0.753 | 0.044 | 1.39 |
Table 1: VAE reconstruction comparison. We report four metrics for the E2E-INVAE and E2E-VAVAE.
| FID↓ | 64 tokens | 128 tokens |
|---|---|---|
| E2E-INVAE | 8.54 | 8.32 |
Table 2: Comparing short and long captions FIDs for pretraining stage.

Figure 4: Comparing REPA, iREPA, and no REPA. We use E2E-INVAE, EUPE encoder, 128 tokens, and MSE loss.
| Target representation | Squared error | Cosine | ||
|---|---|---|---|---|
| FID | iREPA FID | FID | iREPA FID | |
| DINov2 ViT-B/14 | 8.80 | 8.68 | 9.14 | 8.89 |
| PE-Spatial B/16 | 9.56 | 9.65 | 9.89 | 9.99 |
| EUPE ViT-B/16 | 9.71 | 8.32 | 10.20 | 8.37 |
| DINov3 ViT-B/16 | 10.12 | 8.46 | 10.32 | 9.01 |
Table 3: Comparing external vision encoders, REPA vs. iREPA, and MSE vs. cosine similarity. We use E2E-INVAE and 128 prompt tokens. .
4.2 Method comparisons
Comparing E2E-INVAE and E2E-VAVAE. Both VAEs, trained by the REPA-E method [13], are publicly available. To compare VAEs, both reconstruction and diffusability are important [26]. We first compare their reconstruction performance in Table 1. Across the four metrics, E2E-INVAE is consistently better. We then compare how they support diffusion model training in Fig. 3. We also observe that E2E-INVAE yields lower gFID scores or better diffusability.
Long caption vs. short caption. For each dog image, we provide a short caption (64 tokens maximum) and a long caption (128 tokens maximum). We compare them in MiniDog using E2E-INVAE in Table 2. For this comparison, iREPA with EUPE encoder and MSE loss is used. Under E2E-INVAE, training with long captions yields lower gFID results. It indicates that long captions allow pretraining to converge faster than short captions.
REPA vs. iREPA. We compare REPA, iREPA and baseline without REPA in Fig. 4 and Table 3. We clearly see that REPA accelerates convergence of the baseline. Moreover, when using the EUPE encoder, iREPA converges faster than REPA. While REPA is slightly better under the PE-Spatial encoder (Table 3), the overall best performance is still achieved with iREPA (with EUPE). In addition, from Table 3, using the MSE loss is superior to the cosine similarity loss for REPA and iREPA.
Comparing different vision encoders. In Table 3, we observe that the best encoder is DINov2 for REPA and EUPE for iREPA. The EUPE encoder [15] is trained by distilling from DINov3, PE-Core, and PE-Lang. Its spatially coherent dense features may explain its advantages for iREPA.
Benefit of supervised fine-tuning. In Table 4, we compare generation quality of our pretrained model and SFT model. We use two pretrained reward models for scoring, which generally reflect how much people would like an image given its prompt. It is obvious that the HPSv2 and PickScore of the SFT model are consistently higher than those of the pretrained model. It is mainly because of the high quality SFT data. Note that FID (not shown) of the SFT model is higher than the pretrained model, because the high-quality SFT data pulls the model away from the pretraining distribution. Fig. 1 presents some cherry-picked images.
| HPSv2 | PickScore | |
|---|---|---|
| Pretrained | 0.1625 | 18.42 |
| SFT | 0.2427 | 19.61 |
Table 4: Human-preference scores of the pretrained and SFT ckpts.
5 Conclusion
MiniDog does not build a comprehensive T2I model. Instead, it is a minimal project that focuses on dog image generation for the purpose of democratizing T2I training. Under our configuration, pretraining only takes about an hour on four 3090 GPUs and yields an FID of 8.32 at the resolution of . Users can spend another 15 minutes on supervised fine-tuning, which improves image quality judged by pretrained reward models. The entire project including data, models, and code has been publicly open-sourced, with the hope to allow researchers to get started and evaluate their ideas.
References
[1] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In NeurIPS, 2020.
[2] Yaron Lipman et al. Flow matching for generative modeling. ICLR, 2023.
[3] Xingchao Liu et al. Flow straight and fast: Learning to generate and transfer data with rectified flow. In ICLR, 2023.
[4] William Peebles and Saining Xie. Scalable diffusion models with transformers. In ICCV, 2023.
[5] Alexey Dosovitskiy et al. An image is worth words: Transformers for image recognition at scale. In ICLR, 2021.
[6] Olaf Ronneberger et al. U-Net: Convolutional networks for biomedical image segmentation. In MICCAI, 2015.
[7] Jingfeng Yao et al. Reconstruction vs. generation: Taming optimization dilemma in latent diffusion models. In CVPR, 2025.
[8] Patrick Esser et al. Scaling rectified flow transformers for high-resolution image synthesis. In ICML, 2024.
[9] Sihyun Yu et al. Representation alignment for generation: Training diffusion transformers is easier than you think. In ICLR, 2025.
[10] Maxime Oquab et al. DINOv2: Learning robust visual features without supervision. TMLR, 2024.
[11] Jaskirat Singh, Xingjian Leng, et al. What matters for representation alignment: Global information or spatial structure? ICLR, 2026.
[12] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. In CVPR, 2022.
[13] Xingjian Leng et al. REPA-E: Unlocking VAE for end-to-end tuning of latent diffusion transformers. In ICCV, 2025.
[14] An Yang et al. Qwen3 technical report. arXiv:2505.09388, 2025.
[15] Chenchen Zhu, Saksham Suri, et al. Efficient universal perception encoder. arXiv:2603.22387, 2026.
[16] Olga Russakovsky et al. ImageNet large scale visual recognition challenge. IJCV, 2015.
[17] Black Forest Labs. FLUX. https://github.com/black-forest-labs/flux, 2024.
[18] Xingjian Leng et al. DiffusionBench: On holistic evaluation of diffusion transformers. arXiv:2606.24888, 2026.
[19] Oriane Siméoni, Huy V. Vo, et al. DINOv3. TMLR, 2026.
[20] Daniel Bolya, Po-Yao Huang, et al. Perception encoder: The best visual embeddings are not at the output of the network. In NeurIPS, 2025.
[21] Martin Heusel et al. GANs trained by a two time-scale update rule converge to a local Nash equilibrium. NeurIPS, 2017.
[22] Zhou Wang, Alan C. Bovik, Hamid R. Sheikh, and Eero P. Simoncelli. Image quality assessment: From error visibility to structural similarity. IEEE Transactions on Image Processing, 13(4): 600–612, 2004.
[23] Richard Zhang, Phillip Isola, Alexei A. Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In CVPR, 2018.
[24] Xiaoshi Wu et al. Human preference score v2: A solid benchmark for evaluating human preferences of text-to-image synthesis. arXiv:2306.09341, 2023.
[25] Yuval Kirstain et al. Pick-a-Pic: An open dataset of user preferences for text-to-image generation. NeurIPS, 2023.
[26] Ivan Skorokhodov, Sharath Girish, Benran Hu, Willi Menapace, Yanyu Li, Rameen Abdal, Sergey Tulyakov, and Aliaksandr Siarohin. Improving the diffusability of autoencoders. In ICML, 2025.
[27] Christian Szegedy et al. Rethinking the Inception architecture for computer vision. In CVPR, 2016.
[28] Alec Radford et al. Learning transferable visual models from natural language supervision. In ICML, 2021.
[29] Biao Zhang and Rico Sennrich. Root mean square layer normalization. In NeurIPS, 2019.
[30] Noam Shazeer. GLU variants improve transformer. arXiv:2002.05202, 2020.
[31] Jianlin Su et al. RoFormer: Enhanced transformer with rotary position embedding. Neurocomputing, 2024.
[32] Boyang Zheng et al. Diffusion transformers with representation autoencoders. ICLR, 2026.
[33] Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv:2207.12598, 2022.
[34] Anton Obukhov et al. High-fidelity performance metrics for generative models in PyTorch. https://github.com/toshas/torch-fidelity, 2020.
A iREPA
iREPA [11] keeps the REPA loss of Eq. (2) but makes two changes that transfer more of the spatial structure of the target representation. The iREPA runs done during the comparison of target representations (Table 3) make both changes and keep everything else fixed.
Convolutional projector. REPA's MLP projector (a single linear layer in our REPA runs) is replaced by a convolution (padding 1) over the grid of hidden states, which preserves the local spatial relations between neighbouring patches.
Spatial normalization. The target features are normalized across the patch tokens of each image before alignment,
where is the feature of patch , and are the mean and standard deviation over the patches of the image, , and . Subtracting the mean removes most of the global component that all patches share, which increases the contrast between patches and so strengthens the spatial signal that alignment transfers to the backbone. Table 5 in Appendix C lists these settings.
B Evaluation metrics
This appendix explains the metrics of Section 3. For each, an arrow in the tables marks whether lower (↓) or higher (↑) is better.
FID ↓. The Fréchet Inception Distance [21] compares two sets of images through the features of a pretrained InceptionV3 [27] network. It fits a Gaussian to the features of each set, with means , and covariances , , and measures the distance between the two Gaussians:
It captures both the quality and the diversity of the generated images. We compare generated images against the 26k pretraining images.
rFID ↓. The same FID, computed between the pretraining images and their reconstructions after encoding and decoding with the tokenizer. It measures how much the tokenizer loses, and because it uses the same Inception reference as our FID, it can be read on the same scale.
PSNR ↑. The peak signal-to-noise ratio, in dB, where MSE is the mean squared pixel error between an image and its reconstruction and MAX is the largest possible pixel value. It measures pixel-level fidelity.
SSIM ↑. The structural similarity index [22] compares local luminance, contrast and structure between an image and its reconstruction. It equals 1 for identical images.
| Pretraining | SFT | |
|---|---|---|
| Architecture | ||
| Backbone | LightningDiT | |
| Input dim. | ||
| Patch size | 1 | |
| Num. layers | 12 | |
| Hidden dim. | 384 | |
| Num. heads | 6 | |
| Timestep / text tokens | 4 / 128 | |
| Text encoder | Qwen3-0.6B (frozen) | |
| Tokenizer | E2E-INVAE (frozen) | |
| Alignment — final recipe | ||
| Target representation | EUPE ViT-B/16 | - |
| Method | iREPA | - |
| Distance | mean squared error | - |
| 0.5 | - | |
| Alignment depth | 4 | - |
| Projector | , padding 1 | - |
| Spatial norm. | - | |
| Alignment — compared in Table 3 | ||
| Target representations | DINOv2, DINOv3, PE-Spatial, EUPE | - |
| Methods | REPA (linear, ), iREPA | - |
| Distances | mean squared error, cosine | - |
| Optimization | ||
| Training data | 26k images | 2k images |
| Epochs | 200 (~20k steps) | 100 |
| Batch size | 256 | 256 |
| Optimizer | AdamW | AdamW |
| Learning rate | , then linear decay | , constant |
| (0.9, 0.999) | (0.9, 0.999) | |
| Weight decay | 0 | 0 |
| Gradient clipping | 1.0 | 1.0 |
| EMA decay | 0.9995 | 0.995 |
| Condition dropout | 0.1 | 0.1 |
| Precision | bf16 | bf16 |
| Interpolants and sampling | ||
| Training objective | v-prediction | |
| Timestep sampling | logit-normal(0,1), shift | |
| Sampler | Euler (ODE), 50 steps | |
| Guidance (CFG scale) | 6.0 | |
Table 5: Hyperparameters of the final recipe (configs/pretrain_e2e-invae_128tok_mse_irepa_eupe.yaml and configs/sft_e2e-invae_128tok_mse_norepa.yaml).
LPIPS ↓. The learned perceptual image patch similarity [23] measures the distance between the deep-network features of two images, calibrated so that it agrees with human judgments of perceptual similarity.
HPSv2 and PickScore ↑. Both are CLIP-based [28] models fine-tuned on human choices between pairs of generated images: HPSv2 [24] on the Human Preference Dataset v2, and PickScore [25] on the Pick-a-Pic dataset. Given a prompt and an image, each predicts how much people would prefer the image. We use them only for evaluation, never as a training signal, and report the average score over the 500 images, one per held-out prompt, that each checkpoint (pretrained and SFT) generates.
C Hyperparameters and more implementation details
Architecture. We use LightningDiT [7] with RMSNorm [29], query-key normalization, SwiGLU feed-forward layers [30], and 2D rotary position embeddings [31]. Conditioning is in-context: the timestep is embedded into 4 tokens with Gaussian Fourier features, the text embedding (the last hidden layer of Qwen3-0.6B, padded to 128 tokens with an attention mask) is projected to the hidden size, and both are concatenated with the 256 latent tokens.
Cached inputs. Every frozen model runs only once, before training. We resize and center-crop each image to and cache its E2E-INVAE latent, its text embedding, and, for alignment, the patch features of the target representation (DINOv2, or EUPE in the final recipe), so training updates only the DiT. We use no data augmentation. The 64-token ablations use a second, shorter caption (about 30–40 words) for each image, so that the caption fits within 64 tokens.
Optimization. We use AdamW with , no weight decay, gradient clipping at 1.0, and bf16 mixed precision, and we evaluate an exponential moving average (EMA) of the weights. Pretraining keeps the learning rate at for 100 epochs and then decays it linearly; the schedule would reach at epoch 600, so at the end of training (epoch 200) the learning rate is . SFT starts from the pretrained weights with a fresh optimizer and a constant learning rate of . In both stages, the text condition is dropped with probability 0.1 so that classifier-free guidance can be used at sampling time.
REPA. A single linear layer maps the 384-dimensional hidden states of block 4 to the 768-dimensional patch features of the target representation, and is their mean squared error (or per patch in the cosine runs of Table 3), weighted by . All images are . DINOv3, PE-Spatial and EUPE, which use patches, take them at that size; DINOv2 ViT-B/14, used without register tokens, takes them resized to , with its positional embeddings resampled to a grid. Every target representation therefore gives 256 patch tokens, which match the 256 latent tokens one to one.
Target representations. The target representations of Table 3 come from DINOv2 ViT-B/14, DINOv3 ViT-B/16, PE-Spatial B/16, and EUPE ViT-B/16, all with 768-dimensional patch features. DINOv2 and DINOv3 are used as released, with their final LayerNorm and its learned affine parameters. We renormalise the other two, so that every encoder ends in a LayerNorm: PE-Spatial has no output normalisation, so we add a parameter-free LayerNorm, and for EUPE we remove the learned affine parameters of its final LayerNorm.
Timesteps and sampling. Training timesteps follow a logit-normal distribution, shifted towards noise by with the dimension-dependent factor , where is the latent dimension [32]. Sampling integrates the learned velocity with 50 Euler steps from to on a time grid with the same shift, and applies classifier-free guidance [33] with scale 6.0 at every step.
Evaluation. FID uses the InceptionV3 network of torch-fidelity [34], one generated image per caption of the 26k pretraining set, and reference statistics of the 26k real images. HPSv2 and PickScore use their officially released checkpoints.
Computing resources. All runs except the single-GPU timings in Section 4.1 use 4 of the 8 NVIDIA RTX 3090 GPUs (24 GB, 350 W) in a single server, connected over PCIe 4.0 without NVLink, with two AMD EPYC 7343 CPUs (32 cores in total), 256 GB of RAM, and the cached inputs on a local NVMe SSD. The software stack is Ubuntu 24.04, NVIDIA driver 590.44, Python 3.13, PyTorch 2.10.0 with CUDA 12.8, cuDNN 9.10, NCCL 2.27, and Triton 3.6; pyproject.toml and uv.lock in the repository pin every package version. Training uses PyTorch DistributedDataParallel over the 4 GPUs (64 images per GPU).