Skip to content
Hongyang-DuPublic

About

Very simple regulation can mitigate reconstruction-generation gap.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Repository files navigation

Regularizing Layer Fusion Mitigates the Reconstruction–Generation Gap in Representation Autoencoders

Hongyang Du1,2    Yunfei Xie3    Junjie Ye1    Jiawei Yang1    Xiaoyan Cong2    Haodong Zhang2
Yongchao Huang4    Haiyu Wu5    Zongxia Li6    Shihang Gui2    Dawei Liu7    Runhao Li1
Jingcheng Ni2    Chen Wei3,†    Randall Balestriero2,†    Yue Wang1,†

1USC PSI Lab    2Brown University    3Rice University    4University of Aberdeen
5University of Notre Dame    6University of Maryland, College Park    7University of Pennsylvania
†Equal advising  ·  Corresponding to hongyang_du@brown.edu

Website arXiv Hugging Face models

Cosine-similarity maps of decoder intermediate-block features for FuseReg (top) and RAEv2 (bottom), fed K=23, K=7 and single-layer l11 fusions, with reconstructions.

One decoder, three fusions. Cosine-similarity maps at a decoder intermediate block, with reconstructions. FuseReg (top) keeps stable spatial structure under k=23, k=7 and the single layer ℓ11; the fixed-fusion RAEv2 K=23 decoder (bottom) degrades away from its training fusion.

Overview

Representation autoencoders such as RAEv2 ask one fused latent to serve two different goals: shallow encoder features preserve pixel detail, while deeper features tend to be easier to model generatively. A fixed layer fusion hard-codes this trade-off into both the decoder and the generator.

FuseReg turns layer fusion from a fixed heuristic into a training distribution. Each training sample averages a random non-empty subset of encoder layers; the released latent also retains a fixed final-layer token-mean surrogate. The decoder learns to reconstruct from changing layer compositions, and the diffusion transformer learns from noisy subset representations while targeting the full-layer fusion. Inference uses the full-layer mean by default, with no architecture change or additional inference cost.

Averaging over the retained layers keeps the deployment latent unchanged in expectation, so randomization varies only the directions along which encoder layers disagree. The two stages use separate rates, p_dec and p_dit.

The core change, in five lines

Replace RAEv2's fixed layer mean with a per-sample random subset mean during training. DiT-Base gFID drops by 29% with DINOv3-L, 40% with SigLIP2-L and 34% with EUPE-B.

H = torch.stack(layer_tokens)                    # [K, B, N, D]: K encoder layers
keep = torch.rand(K, B) > p                      # each sample keeps each layer w.p. 1-p (empty draw -> keep one)
w = keep / keep.sum(0)                           # mean over the retained layers only
z = (w[..., None, None] * H).sum(0)              # p = 0 recovers the RAEv2 full-layer mean
z = z + H[-1].mean(1, keepdim=True)              # fixed final-layer token-mean surrogate

The decoder reconstructs the image from z with p = p_dec. The DiT takes the noisy z with p = p_dit as input and still targets the full-layer mean (p = 0). At inference p = 0, so the latent, architecture and cost are unchanged. See src/stage1/combine.py for the full implementation.

Results

One regularizer, two stages, two scales

Paper Table 2: gFID and IS grids over generator rate p_dit (rows) and decoder rate p_dec (columns) for DiT-Base and DiT-XL. Best DiT-Base gFID is 9.93 at p_dec=0.9, p_dit=0.7; best DiT-XL gFID is 2.38 at p_dec=0.95, p_dit=0.

Two stages, two scales. Unguided ImageNet-256; the green box is the fixed-fusion baseline. On DiT-Base, regularizing both stages gives the best gFID (13.96 → 9.93 at pdec=0.9, pdit=0.7). On DiT-XL, the decoder rate accounts for most of the gain (2.91 → 2.38 at pdec=0.95, pdit=0); at that decoder rate, pdit moves gFID by at most 0.07.

Fixed generator, swapped decoders

Paper decoder-swap results: gFID and Inception Score across decoder layer-drop rates for K23 and K7 readouts, without guidance and with internal guidance 1.78.

Same generator, same latents. Without guidance, swapping in a regularized decoder alone lowers gFID from 3.01 → 2.21 at k=23 and from 27.73 → 1.92 at k=7.

One decoder, different layer readouts

Paper reconstruction comparison: the same FuseReg decoder and fixed-fusion RAEv2 decoders reconstruct four images from last-seven-layer and single-layer L11 readouts. Insets show PSNR in dB.

Reconstruction off the training fusion. Fixed-fusion RAEv2 decoders degrade away from the fusion they were trained on; the same FuseReg decoder has the highest PSNR on every image under both readouts. Insets show PSNR in dB.

Discussion

FuseReg distributes reconstruction across layers

Paper figure: leave-one-layer-out PSNR drop (left) and single-layer PSNR (right) for the RAEv2 decoder and FuseReg with p_dec=0.95, frozen DINOv3 K=23.

Distributed reconstruction. Left: PSNR drop when one layer is left out of the full fusion; FuseReg's profile is much flatter. Right: PSNR from one layer plus the final-layer token-mean surrogate; FuseReg is higher at every layer. 10,000 held-out ImageNet-256 images.

Because the encoder is frozen, this reflects the decoder's ability to recover information already available across depths: improving the readout of a fixed representation can improve unguided generation even when the generator and sampled latents are unchanged.

1. Environment setup

Validated with Python 3.11 on a Linux CUDA machine (package metadata supports 3.10–3.13).

git clone https://github.com/Hongyang-Du/FuseReg.git
cd FuseReg
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt   # installs torch==2.10.0, torchvision==0.25.0
python -m pip install '.[train]'             # pinned GMuon optimizer, needed for DiT training

If the default index does not match your CUDA runtime, install the same torch pair from the matching PyTorch wheel index first (e.g. --index-url https://download.pytorch.org/whl/cu128), then install FuseReg.

Checkpoints (access-controlled on Hugging Face; see the checkpoint manifest):

hf auth login
hf download Hongyang-Du/FuseReg --local-dir checkpoints
python scripts/verify_checkpoints.py --root checkpoints

External assets (obtain under their own terms):

Asset Location
DINOv3-L encoder (access) pretrained_models/encoders/dinov3/dinov3_vitl16_pretrain_lvd1689m-8aa4cbdd.pth (or set DINOV3_CKPT_DIR)
DINO S/8 discriminator (decoder training only) pretrained_models/encoders/dino/dino_vit_small_patch8_224.pth
ImageNet train data/imagenet/train/ (ImageFolder) or data/imagenet/imagenet-latents-images/ (Arrow)
ImageNet-256 val data_eval/imagenet-256-val.npz — RGB uint8, shape [N, 256, 256, 3]

For offline clusters, set DINOV3_REPO_DIR to a local DINOv3 checkout containing hubconf.py. Check the eval archive header before loading any model:

python scripts/validate_image_archive.py data_eval/imagenet-256-val.npz --min-images 100

2. Train the decoder

One config per p_dec in configs/stage1/decoder (p00, p005, p01, p03, p05, p07, p09, p095; 16 epochs):

torchrun --standalone --nproc_per_node=8 src/train_decoder.py \
  --config configs/stage1/decoder/dinov3-k23-p095.yaml \
  data.data_dir=data/imagenet \
  data.val_npz=data_eval/imagenet-256-val.npz \
  training.out_dir=outputs/decoder-p095 \
  loss.gan.disc_ckpt=pretrained_models/encoders/dino/dino_vit_small_patch8_224.pth \
  wandb.enabled=false

3. Train the DiT

One config per p_dit in configs/stage2/training (DiT-Base: p00–p09; DiT-XL: p00, p05, p07, p09; 40 epochs). First compute latent statistics for the full-fusion readout, then train:

torchrun --standalone --nproc_per_node=1 src/compute_latent_stats.py \
  --config configs/stage2/training/dinov3-k23-fulltarget-p09-ditxl.yaml \
  --num-samples 50000 --batch 32 \
  --out checkpoints/latent_stats.pt \
  dataset.data_dir=data/imagenet \
  stage_1.params.stage1_ckpt_path=checkpoints/dinov3-vitl/decoder_k23/p0.95.safetensors

GRAD_ACCUM_OVERRIDE=8 torchrun --standalone --nproc_per_node=8 src/train.py \
  --config configs/stage2/training/dinov3-k23-fulltarget-p09-ditxl.yaml \
  --results-dir outputs/ditxl-p09 --precision bf16 \
  dataset.data_dir=data/imagenet \
  stage_1.params.stage1_ckpt_path=checkpoints/dinov3-vitl/decoder_k23/p0.95.safetensors \
  stage_1.params.normalization_stat_path=checkpoints/latent_stats.pt

The global batch is fixed at 1024 (micro-batch = 1024 / (world_size × GRAD_ACCUM_OVERRIDE)); keep it when changing GPU count.

4. Reproducing the tables

scripts/run_table.py builds every evaluation command for a table from the experiment matrix, runs it and compares against the paper value. Add --dry-run to only print the commands. Reconstruction uses 50,000 ImageNet-256 images; generation uses 50,000 samples with 50 Euler steps. Rows with unmapped assets are skipped and reported, not approximated. See the reproduction guide for protocol details.

Table 1's baselines and Table 5's K7 generator are official RAEv2 checkpoints. Download them, then list the latent statistics each generator was trained with in assets.json:

hf download nyu-visionx/RAEv2-models \
  --include "stage1/imagenet/dinov3l-k7/*" "stage1/imagenet/dinov3l-k23/decoder.pt" "stage2/imagenet/dinov3l-k7/*" \
  --local-dir checkpoints/raev2-models

cat > assets.json <<'JSON'
{
  "latent_stats_k23": "checkpoints/latent_stats.pt",
  "latent_stats_k7": "checkpoints/raev2-models/stage1/imagenet/dinov3l-k7/stats.pt"
}
JSON
Table 1 · Reconstruction across fusions (k=7, k=23, ℓ11)
python scripts/run_table.py --table 1 \
  --val-npz data_eval/imagenet-256-val.npz --results-dir results/table1

All 9 rows. The official RAEv2 K7/K23 decoders always run with raw [0, 1] output, whatever --decoder-output-normalization says.

Table 2 · pdec × pdit grid, DiT-Base and DiT-XL, no guidance
python scripts/run_table.py --table 2 --bindings assets.json \
  --val-npz data_eval/imagenet-256-val.npz --results-dir results/table2

Runs the 32 DiT-XL cells (same as the unguided half of Table 6). The 49 DiT-Base cells are skipped: the DiT-Base generators are not in the checkpoint manifest yet.

Table 4 (appendix) · Decoder drop-rate sweep, 8 decoders × 3 readouts
python scripts/run_table.py --table 4 --decoder-output-normalization encoder \
  --val-npz data_eval/imagenet-256-val.npz --results-dir results/table4

All 24 rows. --decoder-output-normalization is required for the pdec=0 decoder (its checkpoint does not record it); without it those 3 rows are skipped.

Table 5 (appendix) · Fixed generator, swapped decoders, with/without guidance
python scripts/run_table.py --table 5 --bindings assets.json --decoder-output-normalization encoder \
  --val-npz data_eval/imagenet-256-val.npz --results-dir results/table5

All 32 rows. Use --bindings, not --latent-stats: the K7 and K23 columns need different statistics.

Table 6 (appendix) · DiT-XL rates, 4 generators × 8 decoders × 2 guidance settings
python scripts/run_table.py --table 6 --bindings assets.json --decoder-output-normalization encoder \
  --val-npz data_eval/imagenet-256-val.npz --results-dir results/table6

All 64 rows.

License

See LICENSE for the repository's inherited code license and THIRD_PARTY_NOTICE.md for upstream attribution. Paper figures/PDF, released checkpoints, DINO weights and ImageNet data may have separate terms; users are responsible for following the terms attached to each asset.

Citation

@misc{du2026fuseregregularizinglayerfusion,
      title={FuseReg: Regularizing Layer Fusion Mitigates the Reconstruction-Generation Gap in Representation Autoencoders}, 
      author={Hongyang Du and Yunfei Xie and Junjie Ye and Jiawei Yang and Xiaoyan Cong and Haodong Zhang and Yongchao Huang and Haiyu Wu and Zongxia Li and Shihang Gui and Dawei Liu and Runhao Li and Jingcheng Ni and Chen Wei and Randall Balestriero and Yue Wang},
      year={2026},
      eprint={2609.31620},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2609.31620}, 
}

About

Very simple regulation can mitigate reconstruction-generation gap.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages