Purify Before You Align:
Improving Representation Alignment for Diffusion Models

Cornell University University of Pennsylvania
(a) A pretrained encoder's features split into local appearance, which can hurt generation, and a residual, which retains the gain; LAP aligns the diffusion model to the residual. (b) On the 200-class ImageNet subset, MAE alignment improves from FID-DINOv2 1642.3 (raw) to 1508.3 (LAP-L) and 1484.4 (LAP-N), below DINOv2 REPA at 1534.9.

Purify the target, then align. LAP subtracts the part of a pretrained encoder's features that local clean-image appearance already predicts, and aligns the diffusion model to the residual. Only the alignment target changes: training loss, architecture and sampler stay the same.

Abstract

Representation alignment improves and accelerates diffusion training by encouraging intermediate features to match a pretrained visual encoder. However, standard alignment matches pretrained representations without distinguishing what information may be more useful for generation. We introduce local appearance purification (LAP), which improves generation quality and makes encoders such as MAE more effective alignment targets by removing locally predictable content and aligning to the residual. LAP modifies only the alignment target, and requires no changes to diffusion training or inference. Through controlled interventions within a fixed encoder, we show that effective alignment depends on what information the target emphasizes, not simply how much image information it contains. Our theory gives a variational interpretation of standard alignment and, for fixed local predictors, a sum of token-wise information bounds conditioned on local appearance. To understand why purification benefits some encoders more than others, we derive an exact constant-readout test that measures how well the target can be matched without using the diffusion model's hidden state. LAP improves generation quality across five pretrained representations (MAE, AIMv2, CLIP, DINOv2, DINOv3), with the largest gain for MAE: on ImageNet-256 with SiT-B/2, it reduces FID from 53.1 to 42.3. Its gains persist with stronger alignment recipes and tokenizers. Computed before diffusion training, the constant-readout score predicts the benefit of purification (Spearman \(\rho=0.94\) across 13 encoders).

What Should an Alignment Target Ask For?

REPA trains a diffusion transformer to match, through a small projector, the features of a frozen pretrained encoder. Which encoder to use is still mostly an empirical choice, and MAE is the sharpest puzzle: diffusion models learn to reconstruct clean images, and MAE features predict clean-image content far better than DINOv2. Yet across five encoders, better clean-image prediction generally accompanies worse generation, and MAE gives the smallest gain.

Scatter of FID-DINOv2 against image-prediction R squared for CLIP, I-JEPA, DINOv2, MoCo v3 and MAE: higher image prediction goes with worse FID, and MAE is near the no-alignment line.
Clean-latent prediction from the target vs. generation (200-class ImageNet subset, 50K steps, FID-DINOv2 on 10K samples).

What information should an alignment target ask the denoiser to match?

One encoder, opposite effects

A comparison across encoders cannot isolate the cause, since architecture, data and objective all change together. We therefore hold DINOv2 fixed and split each target token into the part an affine map can predict from the co-located clean-latent patch, and the residual. The predictable part is tiny (rank at most 17, about 2% of the centered feature variance) and easier to match, yet aligning to it alone makes FID-50K worse than no alignment (56.71 vs. 53.92). Aligning to the residual keeps the full benefit of raw DINOv2 (41.47 vs. 41.75).

Patch-similarity maps for the original, predictable and residual DINOv2 features on two images, and FID-50K: original 41.75, predictable component 56.71, residual 41.47, no alignment 53.92.
One encoder, opposite alignment effects. (a) DINOv2 features split into a locally predictable component and a residual; each map shows the cosine similarity of every patch to the red-boxed patch. (b) Aligning to the locally predictable component hurts generation, whereas the residual (LAP-L) keeps the benefit (SiT-B/2, ImageNet 256×256, 400K steps, FID-50K).

Better velocity prediction, worse generation

A second intervention pushes the aligned representation to predict the denoising target directly, with an auxiliary head. At full scale this raises the held-out velocity-prediction \(R^2\) from 0.11 to 0.53, but worsens FID-50K from 41.75 to 46.79. In the unmodified REPA model, DINOv2 features are readable from the hidden state, but the denoiser relies on the aligned subspace less than on rank-matched random subspaces: readable is not the same as relied on.

(a) Ablating the aligned subspace raises velocity error by 12.2% of the full-layer effect, versus 14.0% for the untrained projector subspace and 22.7% for random subspaces. (b, c) Increasing the auxiliary velocity loss raises velocity sufficiency but worsens FID.
Readability, reliance, and the auxiliary prediction loss. (a) Subspace ablations of the REPA model, as a percentage of the full-layer effect. (b) Sweeping the auxiliary loss weight \(\lambda_s\) on the 200-class subset: velocity sufficiency saturates while FID keeps worsening. (c) The same loss at full scale (FID-50K).

Takeaway. The denoising loss already supplies a strong reconstruction signal. Alignment helps most when the target emphasizes information beyond what local appearance predicts, not when it adds more reconstruction content.

Local Appearance Purification

In REPA, a projector \(g_\psi\) maps the hidden state \(h_t^l\) at block \(l\) to \(a_t = g_\psi(h_t^l)\), which is matched token-wise to a target \(y\) computed from the clean image:

\[ \begin{gathered} \mathcal{L} = \mathcal{L}_{\mathrm{flow}} + \lambda_a \mathcal{L}_{\mathrm{align}}, \\ \mathcal{L}_{\mathrm{align}} = -\mathbb{E}\Big[\tfrac{1}{N}\textstyle\sum_{i=1}^{N} \cos\big(a_t^{(i)}, y^{(i)}\big)\Big]. \end{gathered} \]

Standard REPA uses the raw encoder output \(y = z = f(I)\). LAP fits a local predictor \(d_\phi\) from the patchified clean latent \(X_p\) to \(z\), and aligns to what it cannot predict:

\[ \begin{gathered} \mathcal{L}_{\mathrm{pred}} = \mathbb{E}\,\big\| z - d_\phi(X_p) \big\|^2, \\ y^{\mathrm{pure}} = \mathrm{sg}\big[\, z - d_\phi(X_p) \,\big]. \end{gathered} \]
Diagram comparing vanilla SiT training, SiT with REPA aligned to the raw encoder target, and LAP-N, where a frozen local predictor's prediction from the patchified clean latent is subtracted from the encoder target before alignment.
The LAP-N framework. Compared with SiT training with REPA, LAP-N changes only the alignment target, by subtracting the content a frozen local predictor \(d_\phi\) recovers from the clean latent. Training and inference are otherwise unchanged.

LAP-L (linear). An affine map from each clean-latent patch to its target token, refit on every minibatch with no gradient through the fit. Nothing to pretrain.

LAP-N (nonlinear). A small convolutional predictor over a local \(k\times k\) neighborhood of latent patches, trained once per teacher before diffusion training and then frozen.

The predictor only defines the target: it receives no gradient from diffusion training and is discarded at sampling time. The residual is not guaranteed to be purely semantic (local patches can carry semantics, and a limited predictor will not remove everything local), so we measure its content and its effect on generation directly.

Pseudocode of the target change (see train.py for the full version)

# z:  teacher tokens f(I)                  (B, N, D)
# Xp: patchified clean latent, one patch per token  (B, N, C*p*p)

# LAP-L: per-batch affine residual
A = torch.cat([Xp, torch.ones_like(Xp[..., :1])], dim=-1).flatten(0, 1)
W = torch.linalg.lstsq(A, z.flatten(0, 1)).solution
y = z - (A @ W).view_as(z)

# LAP-N: subtract a frozen local purifier (trained once per teacher)
y = z - purifier(Xp)

loss_align = -F.cosine_similarity(projector(h), y.detach(), dim=-1).mean()

A variational view

Reading cosine alignment as the log-likelihood of a von Mises–Fisher decoder for each target direction, standard alignment maximizes a variational lower bound on the information the hidden state carries about the teacher. For a fixed local predictor with input neighborhood \(S_i\), LAP instead bounds a sum of token-wise information terms conditioned on local appearance:

\[ \begin{aligned} \mathcal{I}(h; z) &\;\ge\; c_\sigma - \kappa N\, \mathcal{L}^{(t)}_{\mathrm{align}}(z), \\ \textstyle\sum_{i=1}^{N} \mathcal{I}\big(h; z^{(i)} \mid S_i\big) &\;\ge\; c'_\sigma - \kappa N\, \mathcal{L}^{(t)}_{\mathrm{align}}\big(y^{\mathrm{pure}}\big). \end{aligned} \]

These bounds clarify what each loss rewards; they may be loose and do not by themselves explain the generation gains. Derivations and assumptions are in the paper's appendix.

The Constant-Readout Score \(C_0\)

A high alignment score does not mean the hidden state is informative. If target tokens share a common direction, a readout that ignores the hidden state and always outputs the same unit vector \(\mu\) already scores well. The best such constant readout has a closed form:

\[ \begin{gathered} C_0(y) \;=\; \max_{\|\mu\|=1} \mu^\top m_y \;=\; \|m_y\|, \\ m_y = \mathbb{E}\Big[\tfrac{1}{N}\textstyle\sum_{i=1}^{N} \hat y^{(i)}\Big], \end{gathered} \]

where \(\hat y^{(i)}\) is the normalized target token. \(C_0\) depends only on the target, so it can be computed before any diffusion training: normalize the tokens, average over images and positions, take the norm. Raw MAE has \(C_0 = 0.93\), close to the trained projector's cosine of 0.957, so most of its alignment score is reachable without using the hidden state. Both LAP variants bring \(C_0\) down to about 0.01–0.02.

Cosine similarity to a query patch for raw MAE features (nearly uniform), LAP-L, LAP-N and iREPA spatial normalization (localized structure). Mean pairwise cosine over 256 images: raw MAE 0.876, LAP-L 0.084, LAP-N 0.072, iREPA SN -0.002.
How purification changes the MAE target. (a) Cosine similarity to the red-boxed query patch for raw features, LAP-L, LAP-N, and the iREPA-style spatially normalized target (SN), on a shared scale. (b) Mean off-diagonal patch cosine over 256 held-out images: both LAP variants remove MAE's high common similarity.

\(C_0\) predicts which teachers benefit. Across 13 encoders under matched protocols, higher raw-target \(C_0\) goes with larger FID gains from LAP-L: Spearman \(\rho = 0.94\) at 100K steps (FID-10K) and 0.79 at 400K steps (FID-50K). Controlling for raw-target FID, the partial rank correlations remain 0.83 and 0.69.

\(C_0\) is not the whole story. For MAE, LAP-L and LAP-N reach the same near-zero \(C_0\), yet LAP-N generates better. LAP-N removes 35% of held-out target variance while preserving class information (68.7% linear-probe accuracy vs. 66.1% for raw MAE).

Scatter of alignment gain in FID against raw-target C0 for 13 encoders, rising with C0; MAE-B and MAE-L have the largest C0 and the largest gains.
Raw-to-LAP-L FID-10K improvement at 100K steps vs. raw-target \(C_0\). Dashed: quadratic fit.

Results

Class-conditional SiT-B/2 on ImageNet 256×256, 400K steps, batch 64, SD-VAE, alignment at block 8, no guidance, ADM evaluation protocol. Every number is a mean over two training seeds.

Purification across five teachers

Teacher\(C_0\)MethodFID ↓IS ↑Prec. ↑Rec. ↑
No alignment53.9225.340.4350.602
MAE ViT-L0.93REPA53.0526.300.4380.599
+ LAP-L45.1531.440.4800.617
+ LAP-N42.3033.850.4960.622
AIMv2 ViT-L0.66REPA47.9729.880.4640.615
+ LAP-L44.3132.670.4840.622
+ LAP-N44.5632.400.4830.621
CLIP ViT-L0.61REPA44.7432.210.4810.615
+ LAP-L42.6933.910.4930.621
+ LAP-N42.2134.380.4950.624
DINOv3 ViT-B0.52REPA42.7334.250.4860.623
+ LAP-L42.0734.910.4900.633
+ LAP-N43.2734.020.4850.628
DINOv2 ViT-B0.22REPA41.7535.500.4920.630
+ LAP-L41.4735.530.4950.621
+ LAP-N42.1135.260.4930.632

Teachers are ordered by raw-target \(C_0\). Shaded rows use LAP; bold marks the best mean per teacher and metric. The gain is largest where \(C_0\) is high: LAP-L improves mean FID by 7.9, 3.7 and 2.0 for MAE, AIMv2 and CLIP, and by 0.7 and 0.3 for DINOv3 and DINOv2, which is within seed variation.

Faster from the start

FID-10K against training steps from 100K to 400K for MAE, AIMv2, CLIP and DINOv3: the LAP curve is below REPA at every checkpoint, by the widest margin for MAE.
Purification improves throughout training. Two-seed FID-10K means and ranges, using LAP-N for MAE and CLIP and LAP-L for AIMv2 and DINOv3. By 100K steps LAP lowers FID-10K by 14.4 (MAE), 4.3 (AIMv2) and 4.5 (CLIP).

Complements stronger alignment recipes

LAP changes only the target, so it stacks with methods that change other parts of alignment: spatial operations (iREPA), the alignment schedule (VA-REPA), an entangled class token (REG), and a structural loss (sREPA).

RecipeMAEMAE + LAPDINOv2DINOv2 + LAP
iREPA43.0641.3241.3240.55
VA-REPA52.8241.6040.7140.39
REG52.9241.6529.2428.67
sREPA50.4338.4638.1336.92

FID-50K. Each + LAP column uses the variant with the best two-seed mean (LAP-N for MAE; LAP-L or LAP-N for DINOv2, see the paper). Spatial operations improve MAE a lot on their own, but do not subsume purification.

Makes MAE effective across tokenizers

TokenizerNo alignmentREPA (raw MAE)+ LAP-N
SD-VAE53.9253.0542.30
EQ-VAE52.5052.4140.01
REPA-E VAE32.3033.7427.56

FID-50K, MAE ViT-L teacher, released tokenizers kept frozen. With the REPA-E VAE, raw MAE is worse than no alignment, while LAP turns it into a clear gain.

Larger batches and models

ModelBatchUnalignedRaw MAELAP-N (MAE)REPA (DINOv2)LAP-L (DINOv2)
SiT-B/225636.5434.7228.5727.6727.58
SiT-L/225620.1416.0511.9710.019.78
SiT-XL/225617.8613.659.678.107.76

FID-50K without guidance, 400K steps. LAP-N keeps improving MAE at scale, though a gap to DINOv2 REPA remains; LAP-L on DINOv2 gives the lowest FID in every row. With classifier-free guidance, see the paper's appendix.

Beyond ImageNet. On the aerial-scene datasets RESISC45 and AID, LAP with MAE gives the best FID, improving over DINOv2-based REPA by 4.9 and 3.6 FID. On AID neither raw MAE nor raw DINOv2 beats no alignment, while purified MAE does.

Samples

Samples from the 400K-step EMA checkpoints. In each column, every row shares the class label and the sampling noise, so differences come from the alignment target alone.

    Code and Checkpoints

    The repository covers LAP-L, LAP-N and purifier training, the REPA baselines and compositions, the \(C_0\) score and hidden-state probes, and one-command recipes for every experiment in the paper. Five SiT-B/2 checkpoints and all 12 purifiers are on Hugging Face.

    git clone https://github.com/yingheng-wang/LAP && cd LAP
    pip install -r requirements.txt          # plus OpenAI CLIP, see the README
    
    python scripts/download_checkpoints.py --output checkpoints
    python sample.py --ckpt checkpoints/diffusion/in1k_mae_lapk5_s1.pt --out samples/mae_lapn
    
    python reproduce.py train in1k_mae_lapk5  # MAE + LAP-N, as in the paper

    BibTeX

    @article{wang2026purify,
      title   = {Purify Before You Align: Improving Representation Alignment for Diffusion Models},
      author  = {Wang, Yingheng and Li, Yaoqiang and Wu, Yaqin and Bai, Junwen and Gu, Jiatao and De Sa, Christopher and Kuleshov, Volodymyr},
      journal = {arXiv preprint arXiv:2610.20761},
      year    = {2026}
    }