MCPcopy Index your code
hub / github.com/SwayStar123/SpeedrunDiT

github.com/SwayStar123/SpeedrunDiT @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
291 symbols 750 edges 19 files 87 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

image Images generated by SR-DiT-B/1 (140M parameter diffusion model) with 400k training steps

SpeedrunDiT (SR-DiT): Speedrunning ImageNet Diffusion

This repository contains the reference implementation for SR-DiT (Speedrun Diffusion Transformer), a framework that combines representation alignment (REG-style), token routing (SPRINT), architectural improvements, and training modifications on top of a SiT-B/1 backbone with the INVAE tokenizer. You need approximately 15x8 h100 hours to train this, ~$240 of compute at $2/gpu/hr. Training is ~360x faster in convergence compared to baseline

Links: - Code: https://github.com/SwayStar123/SpeedrunDiT - Checkpoints: https://huggingface.co/SwayStar123/SpeedrunDiT/tree/main - W&B runs: https://wandb.ai/kagaku-ai/REG/ - Ablations (branches): https://github.com/SwayStar123/REG - Paper (arxiv): https://arxiv.org/abs/2512.12386

Highlights

  • ImageNet-256 (400K iters, no CFG): FID 3.49, KDD 0.319, 140M params, sampling at NFE=250
  • ImageNet-512 (400K iters, no CFG): FID 4.23, KDD 0.306, sampling at NFE=250

SR-DiT builds on top of a strong baseline (REG + INVAE) and then progressively adds: - Semantic latent space via E2E-INVAE - SPRINT token routing - RMSNorm, RoPE, QK normalization, value residual learning - Contrastive Flow Matching (CFM) - Time shifting and balanced label sampling (for evaluation)

Repository layout

  • train.py: training loop (Accelerate)
  • generate.py: multi-GPU sampling to .png and .npz
  • evaluations/evaluator.py: computes FID/sFID/IS/Precision/Recall from .npz
  • preprocessing/dataset_tools.py: ImageNet preprocessing + INVAE encoding
  • train.sh, eval.sh: example scripts used for our runs

Setup

Create an environment (python 3.11) and install dependencies:

pip install -r requirements.txt

Dataset

Training expects a directory (passed via --data-dir) containing:

dataset/
  images/            # preprocessed ImageNet images (256x256 or 512x512)
  vae-in/            # INVAE latents (.npy) + dataset.json labels

Follow the preprocessing guide in preprocessing/README.md. The minimal flow is:

# 1) Convert raw ImageNet to resized/cropped PNG dataset
python preprocessing/dataset_tools.py convert --source /path/to/imagenet/train \
  --dest dataset/images --resolution=256x256 --transform=center-crop-dhariwal

# 2) Encode images to INVAE latents
python preprocessing/dataset_tools.py encode --source dataset/images \
  --dest dataset/vae-in

Preprocessed dataset is also uploaded here:

https://huggingface.co/datasets/SwayStar123/repa-imagenet-256/blob/main/dataset.zip
https://huggingface.co/datasets/SwayStar123/repa-imagenet-256/blob/main/vae-in.zip

You must first unzip the dataset.zip file, and then unzip the vae-in.zip inside the newly created dataset folder

Training

An example command is provided in train.sh:

bash train.sh

Key arguments: - --model: use SiT-B/1 for the SR-DiT-B/1 configuration - --data-dir: directory containing images/ and vae-in/ - --qk-norm: enables QK normalization - --cfm-coeff, --cfm-weighting: CFM settings - --time-shifting, --shift-base: time shifting for training

Checkpoints are written to:

exps/<exp-name>/checkpoints/<step>.pt

Sampling and evaluation

eval.sh runs sampling (generate.py) and then computes metrics (evaluations/evaluator.py).

bash eval.sh

Notes: - generate.py currently supports --mode sde (the ode branch is not implemented). - For metric computation, download the matching reference batch listed in evaluations/README.md. - Balanced label sampling can be enabled via --balanced-sampling when generating samples.

Citation

If you use this repository, please cite SR-DiT:

@misc{bhanded2025speedrundit,
  title         = {Speedrunning ImageNet Diffusion},
  author        = {Bhanded, Swayam},
  year          = {2025},
  eprint        = {2512.12386},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CV},
  url           = {https://arxiv.org/abs/2512.12386},
}

Contact

Please open a GitHub issue for any questions or issues.

Acknowledgements

This codebase builds upon: - REG / REPA - SiT - DINOv2 - ADM evaluations - NVLabs edm2 preprocessing utilities

We gratefully acknowledge support from WayfarerLabs (Open World Labs) for sponsoring compute resources used in this work.

Core symbols most depended-on inside this repo

mean
called by 24
preprocessing/torch_utils/training_stats.py
get_score_from_velocity
called by 16
samplers.py
load
called by 14
evaluations/evaluator.py
write
called by 9
preprocessing/dnnlib/util.py
Normalize
called by 6
models/invae.py
compute_diffusion
called by 5
samplers.py
load_invae
called by 5
preprocessing/encoders.py
save
called by 5
preprocessing/torch_utils/distributed.py

Shape

Function 134
Method 120
Class 35
Route 2

Languages

Python100%

Modules by API surface

evaluations/evaluator.py51 symbols
models/sit.py43 symbols
models/invae.py33 symbols
preprocessing/dnnlib/util.py30 symbols
preprocessing/dataset_tools.py24 symbols
preprocessing/torch_utils/misc.py20 symbols
preprocessing/torch_utils/training_stats.py14 symbols
preprocessing/torch_utils/persistence.py13 symbols
preprocessing/torch_utils/distributed.py13 symbols
preprocessing/encoders.py12 symbols
train.py8 symbols
samplers.py6 symbols

For agents

$ claude mcp add SpeedrunDiT \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page