Skip to main content

diffusers-dmse

MSE-optimal diffusion model scheduler (DMSE) for the HuggingFace diffusers library.

Inherits DDPMScheduler and modifies the reverse process to omit stochastic resampling, yielding a deterministic path that converges to the conditional mean estimator (CME) — the MSE-optimal denoiser.

Paper

B. Fesl, B. Böck, F. Strasser, M. Baur, M. Joham, W. Utschick, "On the Asymptotic Mean Square Error Optimality of Diffusion Models," AISTATS 2025.

[arXiv] [OpenReview] [PMLR]

Installation

pip install diffusers-dmse

Usage

Denoising a noisy observation (primary use case)

Use init_step() to find the timestep matching the observed SNR, then run the reverse process from that point. This implements Eq. (12) of the paper.

from diffusers import UNet2DModel
from diffusers_dmse import DMSEScheduler
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

scheduler = DMSEScheduler.from_pretrained("google/ddpm-cat-256")
model = UNet2DModel.from_pretrained("google/ddpm-cat-256").to(device)

# set_timesteps must be called before init_step
scheduler.set_timesteps(1000)

# Find starting timestep matching the observed SNR (in dB)
t_init, idx = scheduler.init_step(snr=10.0, is_logarithmic=True)

x = noisy_observation  # your input tensor, shape (B, C, H, W)
for t in scheduler.timesteps[idx:]:
    with torch.no_grad():
        eps = model(x, t).sample
    x = scheduler.step(eps, t, x).prev_sample

Unconditional generation (deterministic DDPM)

Drop-in replacement for DDPMScheduler. Runs the full reverse chain without noise, equivalent to DDIM with eta=0 using the DDPM posterior mean.

from diffusers import UNet2DModel
from diffusers_dmse import DMSEScheduler
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

scheduler = DMSEScheduler.from_pretrained("google/ddpm-cat-256")
model = UNet2DModel.from_pretrained("google/ddpm-cat-256").to(device)
scheduler.set_timesteps(50)

x = torch.randn((1, 3, 256, 256), device=device)
for t in scheduler.timesteps:
    with torch.no_grad():
        eps = model(x, t).sample
    x = scheduler.step(eps, t, x).prev_sample

Key difference from DDPMScheduler

DDPM DMSE
Reverse step x_{t-1} = µ_t(x_t) + σ_t·z, z~N(0,I) x_{t-1} = µ_t(x_t)
Stochastic Yes No
Optimal for Generation diversity MSE / denoising
Starting point t=T (pure noise) SNR-matched t via init_step()

Related repositories

  • Diffusion_MSE: Full source code for the AISTATS 2025 paper, including GMM, MNIST, and audio experiments.
  • Diffusion_channel_est: Application of DMSE to MIMO channel estimation (IEEE Wireless Communications Letters, 2024). [Paper]

License

MIT License. See LICENSE.

Release files for diffusers-dmse 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diffusers-dmse 0.1.0
File Size Uploaded
diffusers_dmse-0.1.0.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for diffusers-dmse 0.1.0
File Interpreter ABI Platform
diffusers_dmse-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.0 kB

Release files / diffusers_dmse-0.1.0.tar.gz

Download URL diffusers_dmse-0.1.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c2579ad4363ffc3cbd9add987d3e39ddc180c04b33493e6f880bd2b81b8ba1b4
BLAKE2b-256 checksum
How to use checksums
616f84673c3a0bea870278c1d9a543ab288ef90a460df9dba8757b9c2d2464dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / diffusers_dmse-0.1.0-py3-none-any.whl

Download URL diffusers_dmse-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be7e77577ea428d9c4a64f9f35ade185842f3052f0aedef47b4386e71e3fea0b
BLAKE2b-256 checksum
How to use checksums
cd29c723275723a38af4ca58e557d36f9b18e60b7bc484c08de4e4e17efe8959
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page