Official codebase for the paper Reverse Diffusion Sequential Monte Carlo Samplers.
- Python 3.13
- conda
-
Create a conda environment named
rdsmcwith Python 3.13:conda create -n rdsmc python=3.13 -y conda activate rdsmc
-
Install the package with PyTorch:
pip install -e . -
For evaluation in experiments, install
potpackage:pip install pot
rdsmc/
├── src/
│ ├── rdsmc/ # RDSMC sampler and utilities
│ │ ├── rdsmc_sampler.py # Main RDSMC sampler with callback support
│ │ └── resample.py # Resampling utilities
│ ├── diffusion/ # Diffusion noisers
│ │ └── noiser.py
│ ├── posterior_sampler/ # SMC, MCMC, and continual AIS samplers
│ │ ├── smc.py
│ │ ├── mcmc.py
│ │ └── continual_ais.py
│ └── target/ # Target distributions
│ ├── gmm.py
│ ├── logistic_regression.py
│ ├── rings.py
│ └── funnel.py
├── experiments/ # Experiment scripts and configurations
│ ├── run.py # Main RDSMC experiment script (uses callbacks)
│ ├── run_ais.py # Main AIS experiment script
│ ├── callbacks.py # Callback implementations for logging/plotting
│ ├── eval.py # Evaluation utilities
│ ├── configs/ # Configuration files
│ │ ├── experiment/ # Experiment-specific configs
│ │ ├── target/ # Target distribution configs
│ │ ├── noiser/ # Noiser configs
│ │ ├── wandb/ # Weights & Biases configs
│ │ ├── sampling_rdsmc.yaml # Base RDSMC config
│ │ └── sampling_ais.yaml # Base AIS config
│ └── data/ # Dataset files
└── pyproject.toml # Package configuration
The package requires:
torch- PyTorchnumpy- Numerical computingomegaconf- Configuration managementhydra-core- Configuration frameworkwandb- Experiment trackingmatplotlib- Plottingnumba- JIT compilation for resampling
RDSMC experiments:
cd experiments
python run.py experiment=gmm2dYou can override hyperparameters using command-line arguments:
python run.py experiment=gmm2d score_approx.ais.n_annealing_steps=10 plot_every=10 log_every=10Configuration files for all experiments in the paper are available in the experiments/configs/ folder. For example:
python run.py experiment=ringsYou can also create your own experiment configuration files following the same structure.
Note: For accurate performance timing, set plot_every=null and log_every=null to disable intermediate plotting and logging, which can add significant overhead.
AIS experiments:
We also provide a script to run baseline methods: Annealed Importance Sampling (AIS) and Sequential Monte Carlo (SMC), which use a geometric annealing schedule.
cd experiments
python run_ais.py experiment=ais_gmm # AIS
python run_ais.py experiment=ais_gmm ais.ess_threshold=1.0 # SMC with resampling at every step
python run_ais.py experiment=ais_gmm ais.ess_threshold=0.3 # SMC with adaptive resamplingAIS experiment configurations are available in experiments/configs/experiment/ (e.g., ais_gmm.yaml, ais_rings.yaml, ais_funnel.yaml).
Experiments are configured using Hydra. Configuration files are in experiments/configs/:
experiment/- Experiment-specific configs (e.g.,gmm2d.yaml,ais_gmm.yaml)target/- Target distribution configsnoiser/- Noiser configs (e.g.,vpnoiser.yaml)sampling_rdsmc.yaml- Base config for RDSMC experimentssampling_ais.yaml- Base config for AIS experiments
Example:
python run.py experiment=gmm2d
python run_ais.py experiment=ais_gmmThe RDSMC sampler uses a callback-based architecture for extensibility:
WandbCallback- Logging to Weights & BiasesPlottingCallback- Generating plots during samplingMetricsCallback- Computing and logging metricsPrintCallback- Printing progress to consoleSaveSamplesCallback- Saving samples to disk
See experiments/callbacks.py for implementation details.
If you use this codebase in your research, please cite our paper:
@inproceedings{wu2025reverse,
title = {Reverse Diffusion Sequential Monte Carlo Samplers},
author = {Wu, Luhuan and Han, Yi and Naesseth, Christian A. and Cunningham, John P.},
booktitle = {Proceedings of the 39th Conference on Neural Information Processing Systems (NeurIPS 2025)},
year = {2025}
}