Skip to content

Commit fd512d7

Browse files
nipunjindalnjindal
andauthored
[2064]: Add stochastic sampler (sample_dpmpp_sde) (#3020)
* [2064]: Add stochastic sampler * [2064]: Add stochastic sampler * [2064]: Add stochastic sampler * [2064]: Add stochastic sampler * [2064]: Add stochastic sampler * [2064]: Add stochastic sampler * [2064]: Add stochastic sampler * Review comments * [Review comment]: Add is_torchsde_available() * [Review comment]: Test and docs * [Review comment] * [Review comment] * [Review comment] * [Review comment] * [Review comment] --------- Co-authored-by: njindal <[email protected]>
1 parent e0a2bd1 commit fd512d7

File tree

12 files changed

+695
-3
lines changed

12 files changed

+695
-3
lines changed

docs/source/en/_toctree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@
266266
title: VP-SDE
267267
- local: api/schedulers/vq_diffusion
268268
title: VQDiffusionScheduler
269+
- local: api/schedulers/dpm_sde
270+
title: DPMSolverSDEScheduler
269271
title: Schedulers
270272
- sections:
271273
- local: api/experimental/rl
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--Copyright 2023 The HuggingFace Team. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License.
11+
-->
12+
13+
# DPM Stochastic Scheduler inspired by Karras et. al paper
14+
15+
## Overview
16+
17+
Inspired by Stochastic Sampler from [Karras et. al](https://arxiv.org/abs/2206.00364).
18+
Scheduler ported from @crowsonkb's https://github.com/crowsonkb/k-diffusion library:
19+
20+
All credit for making this scheduler work goes to [Katherine Crowson](https://github.com/crowsonkb/)
21+
22+
## DPMSolverSDEScheduler
23+
[[autodoc]] DPMSolverSDEScheduler

src/diffusers/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
is_onnx_available,
1313
is_scipy_available,
1414
is_torch_available,
15+
is_torchsde_available,
1516
is_transformers_available,
1617
is_transformers_version,
1718
is_unidecode_available,
@@ -102,6 +103,13 @@
102103
else:
103104
from .schedulers import LMSDiscreteScheduler
104105

106+
try:
107+
if not (is_torch_available() and is_torchsde_available()):
108+
raise OptionalDependencyNotAvailable()
109+
except OptionalDependencyNotAvailable:
110+
from .utils.dummy_torch_and_torchsde_objects import * # noqa F403
111+
else:
112+
from .schedulers import DPMSolverSDEScheduler
105113

106114
try:
107115
if not (is_torch_available() and is_transformers_available()):

src/diffusers/schedulers/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
# limitations under the License.
1414

1515

16-
from ..utils import OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available
16+
from ..utils import (
17+
OptionalDependencyNotAvailable,
18+
is_flax_available,
19+
is_scipy_available,
20+
is_torch_available,
21+
is_torchsde_available,
22+
)
1723

1824

1925
try:
@@ -72,3 +78,11 @@
7278
from ..utils.dummy_torch_and_scipy_objects import * # noqa F403
7379
else:
7480
from .scheduling_lms_discrete import LMSDiscreteScheduler
81+
82+
try:
83+
if not (is_torch_available() and is_torchsde_available()):
84+
raise OptionalDependencyNotAvailable()
85+
except OptionalDependencyNotAvailable:
86+
from ..utils.dummy_torch_and_torchsde_objects import * # noqa F403
87+
else:
88+
from .scheduling_dpmsolver_sde import DPMSolverSDEScheduler

0 commit comments

Comments
 (0)