REPA-E: Unlocking VAE for End-to-End Tuning with Latent Diffusion Transformers
- Publication
- ICCV 2025Conference
- First submitted to arXiv
- arXiv:2504.10483
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{imagegenerationrepae2025,
title = {{REPA-E: Unlocking VAE for End-to-End Tuning with Latent Diffusion Transformers}},
author = {Xingjian Leng and Jaskirat Singh and Yunzhong Hou and Zhenchang Xing and Saining Xie and Liang Zheng},
year = {2025},
eprint = {2504.10483},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2504.10483}
}
The first figure in this paper sketches three ways of training, and next to the VAE in the leftmost column sits a tiny snowflake.
The snowflake means frozen. Almost every latent diffusion model today trains in two stages. First a variational autoencoder (VAE) is trained with a reconstruction loss, then it is frozen, and the diffusion model learns to generate in its latent space. In the second stage, not a single VAE parameter moves.
The lesson of the past decade of deep learning is that whatever can be trained end to end usually should be. Detection went from R-CNN to Faster R-CNN by folding separately trained parts into a single loss, one after another. So why don't latent diffusion models unfreeze the VAE and train it together with the diffusion model?
The authors tried, and it was ugly. Backpropagating the diffusion loss straight into the VAE gives a generation FID of 372 (lower is better; a normal model is in single digits). This paper explains why it breaks, and what signal to use instead so the VAE can be unfrozen safely.
Defining the problem
The gap between the two stages
Two-stage training leaves a question nobody can quite answer. The first-stage VAE looks only at reconstruction; is its latent space actually suited to second-stage generation?
This series already ran into that dilemma at VA-VAE, where raising the latent dimension improves reconstruction but makes generation harder. VA-VAE's fix was to align the latents with DINOv2's features while training the VAE, so that a high-dimensional latent space becomes easier to learn. That means shaping the latent space a certain way in the first stage and hoping the second stage likes it.
The trouble is that different VAEs give different answers to what "good" looks like. Concurrent work says SD-VAE's latent space carries high-frequency noise that needs suppressing; the REPA-E authors projected the latent spaces of several VAEs onto three channels with PCA and colored them, and SD-VAE is indeed a sheet of noise, but VA-VAE and the authors' own IN-VAE trained on ImageNet (16× downsampling, 32 channels) are the opposite, blurred together and short on detail. One rule can't fix two opposite problems.
So the authors want to hand the judgment to the second stage itself. The diffusion model knows best what kind of latent space it needs; let its training signal tune the VAE directly, and nobody has to guess.
Why direct backpropagation breaks
Start by writing out the diffusion model's training objective. The generator in this paper is SiT, a diffusion Transformer with the same architecture as DiT that uses linear interpolation as its noising path. The VAE encoder turns an image into a latent , noise is added at time , and the model has to predict the velocity:
is standard normal noise; is the clean latent and is pure noise.
With the VAE frozen, is fixed data, and the model has no choice but to learn to denoise. Unfreeze the VAE and let the gradient of flow into the encoder, and the VAE can also go and change to make this loss smaller.
The laziest change is to flatten across space.
Let's work through an extreme case. SD-VAE compresses a image into a latent. Suppose the encoder learns to output the same number at all 1,024 positions of some channel. After noising, position holds . The model averages the 1,024 positions; the mean of has a standard deviation of only , nearly 0, so the average is just , and has been read out. Then each position's noise can be computed directly, and the target is no challenge at all.
The model needn't understand the image at all. Estimate one offset, and the denoising loss goes down. When the paper says the diffusion loss "hacks" the latent space, this is what it means.
The measurements say the same. Initializing from SD-VAE and training SiT-XL for 400K steps, the authors measured the variance of each latent channel across space; it is 17.06 with the VAE frozen and only 0.02 after end-to-end training with the diffusion loss. The total variation, which measures differences between neighboring positions, also falls from 6,627 to 89.8.
The VAE's own KL term doesn't stop this either. Someone asked about it in the official repo (issue #10), and the authors replied that the KL loss was there the whole time, and that after the collapse, the KL of the overall latent distribution against the standard normal was actually smaller. KL only checks whether the overall distribution resembles the prior; it doesn't care about the spatial structure inside each image.
So what signal can tell the VAE "this kind of latent space is better for generation" without leaving that cheating shortcut open?
Solving the problem
Getting to know REPA first
The answer comes from another paper half a year earlier, REPA (REPresentation Alignment, Yu et al.; Saining Xie is an author on both papers). The site has no REPA note yet, so let's lay it out properly first.
REPA originally had nothing to do with VAEs; it tackles how slowly diffusion Transformers train. Its authors observed that SiT's middle layers do learn some kind of semantic representation, just one far from what self-supervised models like DINOv2 learn; REPA's idea is to use DINOv2 directly as a teacher and have SiT's middle layers imitate it.
Let's follow the shapes of one image:
- SD-VAE compresses it to . SiT-XL/2 cuts that into patches, giving tokens of 1,152 dimensions each.
- After noising it goes into SiT, and the output of block 8, , is taken, with shape .
- A trainable three-layer MLP () projects each token to 768 dimensions.
- On the other side, the clean version of the same image is resized to and fed to a frozen DINOv2-B. DINOv2's patch size is 14, so this also gives tokens, each 768-dimensional, written .
- The -th token positions on the two sides correspond one to one; compute the cosine similarity token by token, average, and negate:
is the number of tokens. REPA multiplies this by and adds it to the denoising loss.
This loss asks SiT, at layer 8 and working from a noisy latent, to say what DINOv2 sees in the clean image. In the REPA paper, SiT-XL/2 with this loss reaches FID 7.9 in only 400K steps, whereas the original SiT-XL/2 needs 7M steps to get to 8.3, more than 17.5× faster convergence.
Three observations
Turning this loss back on the VAE, the REPA-E authors made three observations.

(a) is the collapse described above. On the far left is the original image, and the second column is SD-VAE's original latent space, with visible outlines but covered in speckles; on the far right, after end-to-end training with the diffusion loss, everything turns into one uniform color, and the puppy and the butterfly are gone. The third column is end-to-end training with the REPA loss, and its outlines are actually clearer than before.
The horizontal axis of (b) is CKNNA, a representation alignment score that measures how structurally similar SiT's features are to DINOv2's. For the same batch of images, it finds the nearest neighbors in each representation and computes kernel alignment only over pairs that are mutual neighbors on both sides; the closer the score is to 1, the more consistent the two. The points are SiT-XL/2 + REPA measured under different settings; the higher the CKNNA, the lower the gFID, and a linear fit gives of 0.97. The alignment score can serve as a proxy for generation quality.
(c) points straight at what REPA-E does. The original REPA stays at about 0.42 CKNNA all the way to 400K steps; backpropagate the REPA loss into the VAE as well, and it climbs to about 0.51 at 400K steps. The authors read this as the original REPA's alignment being capped by the VAE's latent features; however hard SiT tries, its input only carries so much information.
Put the three together, and REPA-E's approach is to tune the VAE with the REPA loss instead of the diffusion loss.
The paper doesn't directly explain why the REPA loss isn't fooled by the same shortcut, but the formula offers one reason. It requires every token position to match the feature DINOv2 sees at that position, and the puppy's head has different features from the grass behind it; if the VAE flattens the latent, SiT has no spatial information left to use at layer 8, and the alignment loss goes up. What this loss rewards is exactly what the diffusion loss wants to quietly wipe out.
The REPA-E recipe

(a) is the usual two-stage setup, (b) is the naive version that just collapsed, and (c) is REPA-E. Comparing (b) and (c), there are three differences. The diffusion loss arrow gets an X drawn on it above the VAE, a BatchNorm layer appears between the VAE and SiT, and on the right an extra alignment loss runs from the middle of SiT all the way to the VAE. Add a set of VAE regularization losses not shown in the figure, and that makes four parts.
Part one, BatchNorm. The diffusion model wants input latents with mean 0 and variance 1. The traditional approach computes statistics of the VAE latents over the dataset in advance; SD-VAE's latents, for example, are multiplied by 0.18215. Once the VAE can change, these numbers go stale, and recomputing them at every step is too expensive. The authors put a BatchNorm layer between the VAE and SiT and use its moving averages (running mean and running variance) as a stand-in for the dataset statistics; the learnable affine parameters are switched off, so the layer only normalizes, and it is differentiable.
Part two, the end-to-end REPA loss. The same alignment loss now updates three sets of parameters at once:
is SiT, is the VAE and is the projection MLP. is the output of SiT's layer 8, and SiT's input comes from the VAE, so the gradient can pass through SiT's first 8 layers and the BatchNorm back into the VAE encoder.
Part three, stop-grad on the diffusion loss. updates only ; on this path, the gradient is cut at the latent before it enters SiT. The VAE can no longer reshape itself to make denoising easier.
Part four, the VAE regularization losses. If it only looked at alignment, the VAE might forget how to reconstruct in its eagerness to align. The authors reuse the set of losses Stability AI used to fine-tune SD-VAE:
A KL term, pixel reconstruction, a perceptual loss and a discriminator loss; anyone who has read VQGAN will find them familiar.
With all four in place, the total loss is:
In practice is split in two, 0.5 when updating SiT and 1.5 when updating the VAE. On the VAE side, the alignment signal is turned up threefold.
(d) previews the results. The green line is the original SiT, reaching 8.3 at 7M steps; the orange REPA line reaches 5.9 at 4M steps; the blue REPA-E line catches SiT's 8.3 at roughly 150K steps, catches REPA's 5.9 around 250K steps, and reaches 4.07 at 400K. The abstract's speedups of "over 17× and 45×" are the step ratios marked by these two arrows.
One training step
The formula is written as a single total loss, but the official code splits every step into two updates. Below is an excerpt, simplified from the official train_repae.py, with the discriminator update left out:
# 1) VAE step: SiT frozen; the REPA gradient passes through SiT blocks 1-8 into the VAE
posterior, z, recon = vae(images)
requires_grad(sit, False)
sit.eval() # keep BatchNorm running stats untouched
vae_loss = vae_loss_fn(images, recon, posterior) # L1 + LPIPS + KL + GAN
align = sit(x=z, y=labels, zs=dino_feats, align_only=True) # stops after block 8
vae_loss = vae_loss + 1.5 * align["proj_loss"]
vae_loss.backward(); opt_vae.step(); opt_vae.zero_grad()
# 2) SiT step: stop-grad on the latent; diffusion + REPA update SiT only
requires_grad(sit, True)
sit.train()
out = sit(x=z.detach(), y=labels, zs=dino_feats,
time_input=align["time_input"], noises=align["noises"])
sit_loss = out["denoising_loss"] + 0.5 * out["proj_loss"]
sit_loss.backward(); opt_sit.step(); opt_sit.zero_grad()
The first part updates the VAE. SiT's parameters are frozen for the moment but still take part in the forward pass, and the alignment loss gradient flows through them to the VAE; sit.eval() makes BatchNorm use its moving averages on this pass without updating its statistics. align_only=True makes SiT stop at layer 8, so the remaining 20 layers don't have to run.
The second part updates SiT. z.detach() is the X in the figure; the diffusion loss stops right here. SiT reuses the time and noise drawn in the first part and takes both the denoising loss and 0.5× the alignment loss; on this pass, BatchNorm uses the batch statistics and updates its moving averages along the way.
Each of the three parameter sets has its own AdamW. Compared with training on a frozen VAE, every step adds the VAE's forward and backward passes, the discriminator update and one extra forward pass through SiT's first 8 layers. The authors said in issue #11 that it is "slightly more memory expensive."
Discussion
Experimental setup
Everything is trained on ImageNet . SD-VAE (8× downsampling, 4 channels) is paired with SiT-XL/2; IN-VAE and VA-VAE (16× downsampling, 32 channels) are paired with SiT-XL/1, which uses patch 1, so both combinations have 256 tokens. Alignment uses DINOv2-B at SiT's layer 8; AdamW with a constant learning rate of , batch 256, 8 H100s.
Evaluation follows the ADM protocol, generating 50,000 images to compute gFID (the FID between generated and real images), sFID, IS, precision and recall, with a 250-step SDE solver for sampling. rFID is the FID after the VAE reconstructs the 50,000 ImageNet validation images, so it measures reconstruction. Unless stated otherwise, none of the numbers below use classifier-free guidance (CFG).
Speed
| Epochs | REPA | REPA-E |
|---|---|---|
| 20 | 19.40 | 12.83 |
| 40 | 11.10 | 7.17 |
| 80 | 7.90 | 4.07 |
| 800 | 5.90 | – |
Compiled from Table 1 of the paper. SiT-XL, SD-VAE, gFID, no CFG.
80 epochs is 400K steps. REPA-E's 4.07 at 80 epochs is already lower than REPA's 5.90 after the full 800 epochs; among the other SD-VAE methods in the same table, SiT gets 8.61 after 1400 epochs, FasterDiT 7.91 after 400 epochs and MaskDiT 5.69 after 1600 epochs, and none of them catch up.
Does it hold under other conditions?
Section 4.3 switches the default to the smaller SiT-L trained for only 100K steps and changes one condition at a time:
| Change | REPA | REPA-E |
|---|---|---|
| SiT-B | 49.5 | 34.8 |
| SiT-L (default) | 24.1 | 16.3 |
| SiT-XL | 19.4 | 12.8 |
| Teacher CLIP-L | 29.2 | 23.4 |
| Teacher I-JEPA-H | 23.0 | 16.5 |
| Teacher DINOv2-L | 23.3 | 16.0 |
| IN-VAE | 22.7 | 12.7 |
| VA-VAE | 12.8 | 11.1 |
| Align layer 6 | 23.0 | 16.4 |
| Align layer 10 | 23.7 | 16.2 |
Compiled from Tables 2–5 of the paper. gFID, no CFG.
REPA-E wins every row. The bigger the model, the bigger the relative improvement; SiT-B, L and XL drop by 29.6%, 32.3% and 34.0%.
The VAE rows show the most uneven gains. IN-VAE goes from 22.7 to 12.7, nearly halved; VA-VAE only from 12.8 to 11.1. VA-VAE was already aligned with DINOv2 during its own training stage, so it starts out in good shape and leaves less room for end-to-end tuning.
Ablations and training from scratch
Removing the parts one by one (SiT-L, 100K steps, gFID):
- Full REPA-E: 16.3.
- Without BatchNorm: 18.1.
- Without the VAE regularization losses (the table labels this row with the GAN term): 19.2.
- Without stop-grad: 444.1, IS 1.49, precision and recall both 0.
Item 4 shows that even with the REPA loss and the whole set of regularization losses still there, as long as the diffusion loss can flow back into the VAE, the collapse happens anyway. Stop-grad is the one line in the whole recipe you can least do without.
The appendix also compares against the approach of LSGM (Vahdat et al., 2021). LSGM likewise trains a latent-space diffusion model end to end and uses an entropy term to keep the latent space from collapsing; under the same conditions, SiT-XL at 400K steps, it gets gFID 9.89 against REPA-E's 4.07.
Can the VAE be trained from scratch? The authors dropped SD-VAE's weights and trained the VAE and SiT together from random initialization:
| Steps | REPA | Scratch | VAE init |
|---|---|---|---|
| 100K | 19.40 | 14.12 | 12.83 |
| 200K | 11.10 | 7.54 | 7.17 |
| 400K | 7.90 | 4.34 | 4.07 |
Compiled from Table 7 of the paper. SiT-XL, gFID, no CFG.
Training from scratch is only slightly worse than initializing from a pretrained VAE, and still far better than REPA. Someone pointed out in issue #9 that pretraining the VAE and then training jointly is still two stages at heart; this table is the authors' response, although the from-scratch runs only went to 80 epochs, and the authors themselves say longer training hasn't been verified.
Can the tuned VAE be used on its own?
After end-to-end training, the VAE itself has changed too. The authors took it out, froze it, swapped it in for the original VAE, and trained a diffusion model from scratch the traditional two-stage way.

In each pair, the left column is the original VAE and the right one is after REPA-E. The SD-VAE pair starts out full of speckles; after training there are fewer of them and the outlines come through. IN-VAE and VA-VAE start out as blurred blobs of color; after training they actually gain detail. The same loss fixes two opposite problems, each in the right direction, and this is the basis for the paper's claim that end-to-end training "automatically improves the latent space structure."
E2E-VAE is the VAE taken out after running REPA-E with VA-VAE and SiT-XL. Freeze it and train for 80 epochs:
| Diffusion model | SD-VAE | VA-VAE | E2E-VAE |
|---|---|---|---|
| DiT-XL | 19.82 | 6.74 | 6.75 |
| SiT-XL | 17.20 | 5.93 | 5.26 |
| DiT-XL + REPA | 12.29 | 4.71 | 4.20 |
| SiT-XL + REPA | 7.90 | 4.88 | 3.46 |
Compiled from Table 8 of the paper. gFID, no CFG.
E2E-VAE was tuned with SiT-XL, yet it also works with DiT-XL, which the authors use to argue that it isn't tied to the diffusion model it was trained with. The paper's text says the tuned VAEs "consistently" beat the originals across architectures and settings; in the first row, DiT-XL without REPA, VA-VAE gets 6.74 and E2E-VAE gets 6.75 (a win by minus 0.01). In the other three rows the gap is clear; the SiT-XL + REPA row drops from 4.88 to 3.46.
What about reconstruction?
| VAE | PSNR | rFID |
|---|---|---|
| SD-VAE | 25.67 → 24.84 | 0.74 → 0.53 |
| IN-VAE | 27.40 → 26.87 | 0.26 → 0.27 |
| VA-VAE | 26.32 → 26.25 | 0.28 → 0.28 |
Compiled from Table 14 of the paper. ImageNet 256; left of the arrow is the original VAE, right of it is after REPA-E.
PSNR drops a little for all three, most for SD-VAE at 0.83 dB; rFID roughly holds, and SD-VAE's even improves. End-to-end tuning gives up a little pixel-level accuracy to gain on generation, and the regularization losses keep that cost very small.
Where 1.12 comes from
The paper's abstract reports gFID 1.69 (no CFG) and 1.12 (with CFG) on ImageNet 256.
| Method | Epochs | No CFG | CFG |
|---|---|---|---|
| MAR | 800 | 2.35 | 1.55 |
| SiT (SD-VAE) | 1400 | 8.61 | 2.06 |
| LightningDiT (VA-VAE) | 800 | 2.05 | 1.25 |
| REPA (SD-VAE) | 800 | 5.84 | 1.28 |
| REPA (E2E-VAE) | 80 | 3.46 | 1.67 |
| REPA (E2E-VAE) | 800 | 1.69 | 1.12 |
Compiled from Table 9 of the paper. gFID.
There are two catches in reading this 1.12.
First, it isn't the result of 800 epochs of end-to-end training. The pipeline first runs 80 epochs of REPA-E to tune VA-VAE into E2E-VAE; then E2E-VAE is frozen, and SiT-XL/1 is trained from scratch with ordinary REPA for 800 epochs (the authors confirmed this pipeline in issue #11). For the version trained end to end for 80 epochs directly, the official README lists gFID 4.05, and 1.73 with CFG.
Second, the sampling changed. The first version of the paper, in April 2025, gave 1.83 and 1.26 for the same model; the version updated in October switched to generating a fixed 50 images per class (class-balanced), which gives 1.69 and 1.12. The authors write in the appendix that "to our surprise," this sampling gives slightly better FID, so they recomputed all the 800-epoch alignment methods in the table the new way, with REPA going from 1.42 to 1.28 and LightningDiT from 1.35 to 1.25, so the comparison itself is fair. It's just that once FID is in the 1.x range, the sampling method alone can make a difference of about 0.1, about as large as the differences between methods.
What you'll run into following along
The official repo's code and the paper disagree in a few places.
The paper writes the regularization loss with and simply adds up the four terms; the official config l1_lpips_kl_gan.yaml uses an L1 reconstruction loss, a KL weight of and a discriminator weight of 0.1. Someone asked in issue #29 (April 2026) which one to follow to reproduce the results, and there has been no reply to this day.
Reproduction reports haven't gone smoothly either. The user in issue #16 (May 2025) took the officially released E2E-VAE, trained SiT-XL/1 for 80 epochs following the README, and after several attempts kept ending up around 3.99, against the paper's 3.46; evaluating the official checkpoint matched the paper, so the problem was in training. This issue never got a single reply and was eventually closed by the person who opened it (self-service support). Issue #30 (June 2026) reproduced end-to-end training with the README's SD-VAE command, and at around 90K steps SiT's gradients, the GAN loss and the denoising loss all dropped to zero together; again, nobody replied. The repo was last updated in December 2025.
Maintenance aside, the method itself comes with a few conditions worth keeping in mind. It needs a pretrained representation model as the teacher, and changing the teacher changes the results a lot; the CLIP-L row is 7 points worse than DINOv2. During training, the VAE, the discriminator and SiT all sit in memory. And the main experiments are all on ImageNet 256; text-to-image gets a single trial on MSCOCO in the appendix, where swapping VA-VAE for E2E-VAE lowers FID from 5.43 to 5.02.
Conclusion
REPA-E unfreezes the VAE by changing the signal sent into it. The diffusion loss updates only the diffusion model, the VAE is tuned by the representation alignment loss instead, and a BatchNorm layer keeps track of the ever-changing latent statistics. As a result, SiT-XL reaches gFID 4.07 at 400K steps, and the tuned VAE can also be taken out on its own to train other diffusion models.
When you plug E2E-VAE into your own diffusion model, the latent normalization statistics have to change with it; you can't reuse the original VAE's numbers, such as SD-VAE's 0.18215. The official approach pulls running_mean and running_var out of SiT's BatchNorm layer and saves them alongside the VAE weights as -latents-stats.pt; if you extract the VAE from a full REPA-E checkpoint yourself, take these two sets of numbers along too.
Half a year later, RAE, with Saining Xie among its authors, decided to stop tuning the VAE and use a frozen DINOv2 as the encoder directly. The snowflake is drawn back in, only this time what's frozen is the teacher.