# Sampling with a diffusion model

**URL:** <https://discourse.pymc.io/t/sampling-with-a-diffusion-model/13879>\
**Category:** Sharing\
**Tags:** development, sampling\
**Created:** [February 26, 2024, 7:08pm UTC](https://discourse.pymc.io/t/sampling-with-a-diffusion-model/13879 "2024-02-26T19:08:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leventov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/leventov/32/7778_2.png) [@leventov](https://discourse.pymc.io/u/leventov)\
**Post date:** [February 26, 2024, 7:08pm UTC](https://discourse.pymc.io/t/sampling-with-a-diffusion-model/13879/1 "2024-02-26T19:08:03Z")

</div>

Hello,

I wonder if it would be useful to implement diffusion-based sampling methods in PyMC, as described here: [[2402.05098] On diffusion models for amortized inference: Benchmarking and improving stochastic control and sampling](https://arxiv.org/abs/2402.05098)? Do I think in the right direction or it’s totally misplaced in PyMC?

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [February 27, 2024, 7:53am UTC](https://discourse.pymc.io/t/sampling-with-a-diffusion-model/13879/2 "2024-02-27T07:53:58Z")

</div>

Useful is a funny word, but it would certainly be interesting. I think the [pymc-experimental](https://github.com/pymc-devs/pymc-experimental) package exists for exactly projectsl like this one. PyMC would allow you to easily define the energy function (the unnormalized logp of the model), then you’ll have to do a lot of work to implement the diffusion scheme in pytensor.

Tag me if you end up working on something, it looks super interesting!
