Autoregressive Diffusion - Pytorch
Implementation of the architecture behind Autoregressive Image Generation without Vector Quantization in Pytorch
Official repository has been released here
oxford flowers at 96k steps
Install
$ pip install autoregressive-diffusion-pytorch
Usage
import torch
from autoregressive_diffusion_pytorch import AutoregressiveDiffusion
model = AutoregressiveDiffusion(
dim_input = 512,
dim = 1024,
max_seq_len = 32,
depth = 8,
mlp_depth = 3,
mlp_width = 1024
)
seq = torch.randn(3, 32, 512)
loss = model(seq)
loss.backward()
sampled = model.sample(batch_size = 3)
assert sampled.shape == seq.shape
For images treated as a sequence of tokens (as in paper)
import torch
from autoregressive_diffusion_pytorch import ImageAutoregressiveDiffusion
model = ImageAutoregressiveDiffusion(
model = dict(
dim = 1024,
depth = 12,
heads = 12,
),
image_size = 64,
patch_size = 8
)
images = torch.randn(3, 3, 64, 64)
loss = model(images)
loss.backward()
sampled = model.sample(batch_size = 3)
assert sampled.shape == images.shape
An images trainer
import torch
from autoregressive_diffusion_pytorch import (
ImageDataset,
ImageAutoregressiveDiffusion,
ImageTrainer
)
dataset = ImageDataset(
'/path/to/your/images',
image_size = 128
)
model = ImageAutoregressiveDiffusion(
model = dict(
dim = 512
),
image_size = 128,
patch_size = 16
)
trainer = ImageTrainer(
model = model,
dataset = dataset
)
trainer()
For an improvised version using flow matching, just import ImageAutoregressiveFlow and AutoregressiveFlow instead
The rest is the same
ex.
import torch
from autoregressive_diffusion_pytorch import (
ImageDataset,
ImageTrainer,
ImageAutoregressiveFlow,
)
dataset = ImageDataset(
'/path/to/your/images',
image_size = 128
)
model = ImageAutoregressiveFlow(
model = dict(
dim = 512
),
image_size = 128,
patch_size = 16,
xm_candidates = 4 # explorative modeling - train against best of k candidates per timestep
)
trainer = ImageTrainer(
model = model,
dataset = dataset
)
trainer()
Citations
@article{Li2024AutoregressiveIG,
title = {Autoregressive Image Generation without Vector Quantization},
author = {Tianhong Li and Yonglong Tian and He Li and Mingyang Deng and Kaiming He},
journal = {ArXiv},
year = {2024},
volume = {abs/2406.11838},
url = {https://api.semanticscholar.org/CorpusID:270560593}
}
@article{Wu2023ARDiffusionAD,
title = {AR-Diffusion: Auto-Regressive Diffusion Model for Text Generation},
author = {Tong Wu and Zhihao Fan and Xiao Liu and Yeyun Gong and Yelong Shen and Jian Jiao and Haitao Zheng and Juntao Li and Zhongyu Wei and Jian Guo and Nan Duan and Weizhu Chen},
journal = {ArXiv},
year = {2023},
volume = {abs/2305.09515},
url = {https://api.semanticscholar.org/CorpusID:258714669}
}
@article{Karras2022ElucidatingTD,
title = {Elucidating the Design Space of Diffusion-Based Generative Models},
author = {Tero Karras and Miika Aittala and Timo Aila and Samuli Laine},
journal = {ArXiv},
year = {2022},
volume = {abs/2206.00364},
url = {https://api.semanticscholar.org/CorpusID:249240415}
}
@article{Liu2022FlowSA,
title = {Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow},
author = {Xingchao Liu and Chengyue Gong and Qiang Liu},
journal = {ArXiv},
year = {2022},
volume = {abs/2209.03003},
url = {https://api.semanticscholar.org/CorpusID:252111177}
}
@article{Esser2024ScalingRF,
title = {Scaling Rectified Flow Transformers for High-Resolution Image Synthesis},
author = {Patrick Esser and Sumith Kulal and A. Blattmann and Rahim Entezari and Jonas Muller and Harry Saini and Yam Levi and Dominik Lorenz and Axel Sauer and Frederic Boesel and Dustin Podell and Tim Dockhorn and Zion English and Kyle Lacey and Alex Goodwin and Yannik Marek and Robin Rombach},
journal = {ArXiv},
year = {2024},
volume = {abs/2403.03206},
url = {https://api.semanticscholar.org/CorpusID:268247980}
}
@misc{li2025basicsletdenoisinggenerative,
title = {Back to Basics: Let Denoising Generative Models Denoise},
author = {Tianhong Li and Kaiming He},
year = {2025},
eprint = {2511.13720},
archivePrefix = {arXiv},
primaryClass = {cs.CV},
url = {https://arxiv.org/abs/2511.13720},
}
@misc{gladstone2026explorativemodelingunlockingpretraining,
title = {Explorative Modeling: Unlocking a Third Pretraining Axis and End-to-End Generation},
author = {Alexi Gladstone and Heng Ji and Yilun Du},
year = {2026},
eprint = {2607.27372},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2607.27372},
}
Metadata
Release files for autoregressive-diffusion-pytorch 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| autoregressive_diffusion_pytorch-0.4.0.tar.gz | 13.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autoregressive_diffusion_pytorch-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.4 kB
Release files / autoregressive_diffusion_pytorch-0.4.0.tar.gz
| Download URL | autoregressive_diffusion_pytorch-0.4.0.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f45cd7ea2360d1b580b7b44bf5fd684f4f8a17def7628520ae3555ca574cb98b
|
|
BLAKE2b-256 checksum How to use checksums |
3ec2bd399c4e5b4f856f36ca2755be829763f44a4517838a8b6bf007777b8bc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Release files / autoregressive_diffusion_pytorch-0.4.0-py3-none-any.whl
| Download URL | autoregressive_diffusion_pytorch-0.4.0-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a9e5aaa5e61fdedf5dbf1980bda36548e0119ca1dac776e9df4962204389d00
|
|
BLAKE2b-256 checksum How to use checksums |
53986f6382e7ca4d357d7bb3abe19c6a91dbd453f2cbc49bff9bc6a6055b7bc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|