Official code for:
Avoid Catastrophic Forgetting with Rank-1 Fisher from Diffusion Models
Zekun Wang, Anant Gupta, Zihan Dong, Christopher J. MacLellan
ICLR 2026
This repository implements continual learning for class-conditional diffusion models with:
- EWC with diagonal Fisher (
diag) - EWC with rank-1 optimal Fisher approximation (
rank1_opt) (main contribution) - Generative replay
- Replay distillation (teacher-student noise prediction matching)
Training and evaluation are task-incremental: classes are split into tasks using group_size, and FID is evaluated on all seen tasks after each task.
train-model.py: main entrypoint (config loading, continual loop, FID logging)example_config.json: runnable example configsrc/ddim.py: class-conditional DDIM model and samplersrc/utils.py: dataset loaders, task split logic, training loop, FID evaluatorsrc/parameter_scoring.py: gradient-based Fisher statistics and rank-1 coefficientsrc/ewc.py: EWC penalty over all past taskssrc/gr.py: generative replay buffer built from frozen teacher generationssrc/fisher_analysis.py: Fisher analysis utilities
Python 3.8+ is recommended.
pip install torch torchvision diffusers torchmetrics tqdm datasets wandbDefault run (uses example_config.json):
python train-model.pyRun with a custom config:
python train-model.py --config path/to/your_config.jsonAll experiment options are read from JSON. Key fields:
dataset:mnist|fmnist|cifar10|imagenet32num_classes: number of classes to includegroup_size: number of classes per task (num_tasks = num_classes / group_size)use_ewc: enable EWCewc_lambda: EWC regularization weightewc_fisher_type:diagorrank1_optuse_generative_replay: enable generative replaygr_alpha,gr_pool_size_per_class,gr_num_inference_steps,gr_eta: replay controlsuse_distillation,gr_kl: replay distillation controlsepochs,batch_size,lr,seednormalize,greyscaleuse_wandb,wandb_project,wandb_run_nameoutput_dir: root folder for checkpoints, samples, and logs
The provided example_config.json runs MNIST with:
num_classes=10,group_size=2(5 tasks)- rank-1 EWC (
rank1_opt) - replay + distillation enabled
- MNIST/FashionMNIST/CIFAR10 are downloaded via
torchvision. - ImageNet32 uses Hugging Face dataset
benjamin-paine/imagenet-1k-32x32. - Optional environment variables:
DATA_ROOT(default:./data)HF_DATASETS_CACHE(default:./cache)
Under output_dir, each run writes to:
{dataset}-{ewc_fisher_type}{-gr}{-distill}-{seed}/
including:
model-task{t}.pt: checkpoint after tasktfisher-task{t}.pt: saved Fisher statistics (when EWC is enabled andtis not the final task)task_{t}/epoch_*/epoch_*_grid.png: sampled image grids logged during training
Set:
use_ewc = trueewc_fisher_type = "rank1_opt"
Optional (as in demo config):
use_generative_replay = trueuse_distillation = true
Then run:
python train-model.py --config example_config.json@inproceedings{
wang2026avoid,
title={Avoid Catastrophic Forgetting with Rank-1 Fisher from Diffusion Models},
author={Zekun Wang and Anant Gupta and Zihan Dong and Christopher J. MacLellan},
booktitle={The Fourteenth International Conference on Learning Representations},
year={2026},
url={https://openreview.net/forum?id=zCZcbRsc4g}
}