diffusers 0.34.0__py3-none-any.whl → 0.35.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. diffusers/__init__.py +98 -1
  2. diffusers/callbacks.py +35 -0
  3. diffusers/commands/custom_blocks.py +134 -0
  4. diffusers/commands/diffusers_cli.py +2 -0
  5. diffusers/commands/fp16_safetensors.py +1 -1
  6. diffusers/configuration_utils.py +11 -2
  7. diffusers/dependency_versions_table.py +3 -3
  8. diffusers/guiders/__init__.py +41 -0
  9. diffusers/guiders/adaptive_projected_guidance.py +188 -0
  10. diffusers/guiders/auto_guidance.py +190 -0
  11. diffusers/guiders/classifier_free_guidance.py +141 -0
  12. diffusers/guiders/classifier_free_zero_star_guidance.py +152 -0
  13. diffusers/guiders/frequency_decoupled_guidance.py +327 -0
  14. diffusers/guiders/guider_utils.py +309 -0
  15. diffusers/guiders/perturbed_attention_guidance.py +271 -0
  16. diffusers/guiders/skip_layer_guidance.py +262 -0
  17. diffusers/guiders/smoothed_energy_guidance.py +251 -0
  18. diffusers/guiders/tangential_classifier_free_guidance.py +143 -0
  19. diffusers/hooks/__init__.py +17 -0
  20. diffusers/hooks/_common.py +56 -0
  21. diffusers/hooks/_helpers.py +293 -0
  22. diffusers/hooks/faster_cache.py +7 -6
  23. diffusers/hooks/first_block_cache.py +259 -0
  24. diffusers/hooks/group_offloading.py +292 -286
  25. diffusers/hooks/hooks.py +56 -1
  26. diffusers/hooks/layer_skip.py +263 -0
  27. diffusers/hooks/layerwise_casting.py +2 -7
  28. diffusers/hooks/pyramid_attention_broadcast.py +14 -11
  29. diffusers/hooks/smoothed_energy_guidance_utils.py +167 -0
  30. diffusers/hooks/utils.py +43 -0
  31. diffusers/loaders/__init__.py +6 -0
  32. diffusers/loaders/ip_adapter.py +255 -4
  33. diffusers/loaders/lora_base.py +63 -30
  34. diffusers/loaders/lora_conversion_utils.py +434 -53
  35. diffusers/loaders/lora_pipeline.py +834 -37
  36. diffusers/loaders/peft.py +28 -5
  37. diffusers/loaders/single_file_model.py +44 -11
  38. diffusers/loaders/single_file_utils.py +170 -2
  39. diffusers/loaders/transformer_flux.py +9 -10
  40. diffusers/loaders/transformer_sd3.py +6 -1
  41. diffusers/loaders/unet.py +22 -5
  42. diffusers/loaders/unet_loader_utils.py +5 -2
  43. diffusers/models/__init__.py +8 -0
  44. diffusers/models/attention.py +484 -3
  45. diffusers/models/attention_dispatch.py +1218 -0
  46. diffusers/models/attention_processor.py +105 -663
  47. diffusers/models/auto_model.py +2 -2
  48. diffusers/models/autoencoders/__init__.py +1 -0
  49. diffusers/models/autoencoders/autoencoder_dc.py +14 -1
  50. diffusers/models/autoencoders/autoencoder_kl.py +1 -1
  51. diffusers/models/autoencoders/autoencoder_kl_cosmos.py +3 -1
  52. diffusers/models/autoencoders/autoencoder_kl_qwenimage.py +1070 -0
  53. diffusers/models/autoencoders/autoencoder_kl_wan.py +370 -40
  54. diffusers/models/cache_utils.py +31 -9
  55. diffusers/models/controlnets/controlnet_flux.py +5 -5
  56. diffusers/models/controlnets/controlnet_union.py +4 -4
  57. diffusers/models/embeddings.py +26 -34
  58. diffusers/models/model_loading_utils.py +233 -1
  59. diffusers/models/modeling_flax_utils.py +1 -2
  60. diffusers/models/modeling_utils.py +159 -94
  61. diffusers/models/transformers/__init__.py +2 -0
  62. diffusers/models/transformers/transformer_chroma.py +16 -117
  63. diffusers/models/transformers/transformer_cogview4.py +36 -2
  64. diffusers/models/transformers/transformer_cosmos.py +11 -4
  65. diffusers/models/transformers/transformer_flux.py +372 -132
  66. diffusers/models/transformers/transformer_hunyuan_video.py +6 -0
  67. diffusers/models/transformers/transformer_ltx.py +104 -23
  68. diffusers/models/transformers/transformer_qwenimage.py +645 -0
  69. diffusers/models/transformers/transformer_skyreels_v2.py +607 -0
  70. diffusers/models/transformers/transformer_wan.py +298 -85
  71. diffusers/models/transformers/transformer_wan_vace.py +15 -21
  72. diffusers/models/unets/unet_2d_condition.py +2 -1
  73. diffusers/modular_pipelines/__init__.py +83 -0
  74. diffusers/modular_pipelines/components_manager.py +1068 -0
  75. diffusers/modular_pipelines/flux/__init__.py +66 -0
  76. diffusers/modular_pipelines/flux/before_denoise.py +689 -0
  77. diffusers/modular_pipelines/flux/decoders.py +109 -0
  78. diffusers/modular_pipelines/flux/denoise.py +227 -0
  79. diffusers/modular_pipelines/flux/encoders.py +412 -0
  80. diffusers/modular_pipelines/flux/modular_blocks.py +181 -0
  81. diffusers/modular_pipelines/flux/modular_pipeline.py +59 -0
  82. diffusers/modular_pipelines/modular_pipeline.py +2446 -0
  83. diffusers/modular_pipelines/modular_pipeline_utils.py +672 -0
  84. diffusers/modular_pipelines/node_utils.py +665 -0
  85. diffusers/modular_pipelines/stable_diffusion_xl/__init__.py +77 -0
  86. diffusers/modular_pipelines/stable_diffusion_xl/before_denoise.py +1874 -0
  87. diffusers/modular_pipelines/stable_diffusion_xl/decoders.py +208 -0
  88. diffusers/modular_pipelines/stable_diffusion_xl/denoise.py +771 -0
  89. diffusers/modular_pipelines/stable_diffusion_xl/encoders.py +887 -0
  90. diffusers/modular_pipelines/stable_diffusion_xl/modular_blocks.py +380 -0
  91. diffusers/modular_pipelines/stable_diffusion_xl/modular_pipeline.py +365 -0
  92. diffusers/modular_pipelines/wan/__init__.py +66 -0
  93. diffusers/modular_pipelines/wan/before_denoise.py +365 -0
  94. diffusers/modular_pipelines/wan/decoders.py +105 -0
  95. diffusers/modular_pipelines/wan/denoise.py +261 -0
  96. diffusers/modular_pipelines/wan/encoders.py +242 -0
  97. diffusers/modular_pipelines/wan/modular_blocks.py +144 -0
  98. diffusers/modular_pipelines/wan/modular_pipeline.py +90 -0
  99. diffusers/pipelines/__init__.py +31 -0
  100. diffusers/pipelines/audioldm2/pipeline_audioldm2.py +2 -3
  101. diffusers/pipelines/auto_pipeline.py +17 -13
  102. diffusers/pipelines/chroma/pipeline_chroma.py +5 -5
  103. diffusers/pipelines/chroma/pipeline_chroma_img2img.py +5 -5
  104. diffusers/pipelines/cogvideo/pipeline_cogvideox.py +9 -8
  105. diffusers/pipelines/cogvideo/pipeline_cogvideox_fun_control.py +9 -8
  106. diffusers/pipelines/cogvideo/pipeline_cogvideox_image2video.py +10 -9
  107. diffusers/pipelines/cogvideo/pipeline_cogvideox_video2video.py +9 -8
  108. diffusers/pipelines/cogview4/pipeline_cogview4.py +16 -15
  109. diffusers/pipelines/controlnet/pipeline_controlnet_blip_diffusion.py +3 -2
  110. diffusers/pipelines/controlnet/pipeline_controlnet_union_inpaint_sd_xl.py +212 -93
  111. diffusers/pipelines/controlnet/pipeline_controlnet_union_sd_xl.py +7 -3
  112. diffusers/pipelines/controlnet/pipeline_controlnet_union_sd_xl_img2img.py +194 -92
  113. diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_cycle_diffusion.py +1 -1
  114. diffusers/pipelines/dit/pipeline_dit.py +3 -1
  115. diffusers/pipelines/flux/__init__.py +4 -0
  116. diffusers/pipelines/flux/pipeline_flux.py +34 -26
  117. diffusers/pipelines/flux/pipeline_flux_control.py +8 -8
  118. diffusers/pipelines/flux/pipeline_flux_control_img2img.py +1 -1
  119. diffusers/pipelines/flux/pipeline_flux_control_inpaint.py +1 -1
  120. diffusers/pipelines/flux/pipeline_flux_controlnet.py +1 -1
  121. diffusers/pipelines/flux/pipeline_flux_controlnet_image_to_image.py +1 -1
  122. diffusers/pipelines/flux/pipeline_flux_controlnet_inpainting.py +1 -1
  123. diffusers/pipelines/flux/pipeline_flux_fill.py +1 -1
  124. diffusers/pipelines/flux/pipeline_flux_img2img.py +1 -1
  125. diffusers/pipelines/flux/pipeline_flux_inpaint.py +1 -1
  126. diffusers/pipelines/flux/pipeline_flux_kontext.py +1134 -0
  127. diffusers/pipelines/flux/pipeline_flux_kontext_inpaint.py +1460 -0
  128. diffusers/pipelines/flux/pipeline_flux_prior_redux.py +1 -1
  129. diffusers/pipelines/flux/pipeline_output.py +6 -4
  130. diffusers/pipelines/hidream_image/pipeline_hidream_image.py +5 -5
  131. diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video.py +25 -24
  132. diffusers/pipelines/ltx/pipeline_ltx.py +13 -12
  133. diffusers/pipelines/ltx/pipeline_ltx_condition.py +10 -9
  134. diffusers/pipelines/ltx/pipeline_ltx_image2video.py +13 -12
  135. diffusers/pipelines/mochi/pipeline_mochi.py +9 -8
  136. diffusers/pipelines/pipeline_flax_utils.py +2 -2
  137. diffusers/pipelines/pipeline_loading_utils.py +24 -2
  138. diffusers/pipelines/pipeline_utils.py +22 -15
  139. diffusers/pipelines/pixart_alpha/pipeline_pixart_alpha.py +3 -1
  140. diffusers/pipelines/pixart_alpha/pipeline_pixart_sigma.py +20 -0
  141. diffusers/pipelines/qwenimage/__init__.py +55 -0
  142. diffusers/pipelines/qwenimage/pipeline_output.py +21 -0
  143. diffusers/pipelines/qwenimage/pipeline_qwenimage.py +726 -0
  144. diffusers/pipelines/qwenimage/pipeline_qwenimage_edit.py +882 -0
  145. diffusers/pipelines/qwenimage/pipeline_qwenimage_img2img.py +829 -0
  146. diffusers/pipelines/qwenimage/pipeline_qwenimage_inpaint.py +1015 -0
  147. diffusers/pipelines/sana/pipeline_sana_sprint.py +5 -5
  148. diffusers/pipelines/skyreels_v2/__init__.py +59 -0
  149. diffusers/pipelines/skyreels_v2/pipeline_output.py +20 -0
  150. diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2.py +610 -0
  151. diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing.py +978 -0
  152. diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_i2v.py +1059 -0
  153. diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_diffusion_forcing_v2v.py +1063 -0
  154. diffusers/pipelines/skyreels_v2/pipeline_skyreels_v2_i2v.py +745 -0
  155. diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion.py +2 -1
  156. diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint.py +1 -1
  157. diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_upscale.py +1 -1
  158. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +2 -1
  159. diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py +6 -5
  160. diffusers/pipelines/wan/pipeline_wan.py +78 -20
  161. diffusers/pipelines/wan/pipeline_wan_i2v.py +112 -32
  162. diffusers/pipelines/wan/pipeline_wan_vace.py +1 -2
  163. diffusers/quantizers/__init__.py +1 -177
  164. diffusers/quantizers/base.py +11 -0
  165. diffusers/quantizers/gguf/utils.py +92 -3
  166. diffusers/quantizers/pipe_quant_config.py +202 -0
  167. diffusers/quantizers/torchao/torchao_quantizer.py +26 -0
  168. diffusers/schedulers/scheduling_deis_multistep.py +8 -1
  169. diffusers/schedulers/scheduling_dpmsolver_multistep.py +6 -0
  170. diffusers/schedulers/scheduling_dpmsolver_singlestep.py +6 -0
  171. diffusers/schedulers/scheduling_scm.py +0 -1
  172. diffusers/schedulers/scheduling_unipc_multistep.py +10 -1
  173. diffusers/schedulers/scheduling_utils.py +2 -2
  174. diffusers/schedulers/scheduling_utils_flax.py +1 -1
  175. diffusers/training_utils.py +78 -0
  176. diffusers/utils/__init__.py +10 -0
  177. diffusers/utils/constants.py +4 -0
  178. diffusers/utils/dummy_pt_objects.py +312 -0
  179. diffusers/utils/dummy_torch_and_transformers_objects.py +255 -0
  180. diffusers/utils/dynamic_modules_utils.py +84 -25
  181. diffusers/utils/hub_utils.py +33 -17
  182. diffusers/utils/import_utils.py +70 -0
  183. diffusers/utils/peft_utils.py +11 -8
  184. diffusers/utils/testing_utils.py +136 -10
  185. diffusers/utils/torch_utils.py +18 -0
  186. {diffusers-0.34.0.dist-info → diffusers-0.35.0.dist-info}/METADATA +6 -6
  187. {diffusers-0.34.0.dist-info → diffusers-0.35.0.dist-info}/RECORD +191 -127
  188. {diffusers-0.34.0.dist-info → diffusers-0.35.0.dist-info}/LICENSE +0 -0
  189. {diffusers-0.34.0.dist-info → diffusers-0.35.0.dist-info}/WHEEL +0 -0
  190. {diffusers-0.34.0.dist-info → diffusers-0.35.0.dist-info}/entry_points.txt +0 -0
  191. {diffusers-0.34.0.dist-info → diffusers-0.35.0.dist-info}/top_level.txt +0 -0
@@ -168,6 +168,8 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
168
168
  use_beta_sigmas (`bool`, *optional*, defaults to `False`):
169
169
  Whether to use beta sigmas for step sizes in the noise schedule during the sampling process. Refer to [Beta
170
170
  Sampling is All You Need](https://huggingface.co/papers/2407.12173) for more information.
171
+ use_flow_sigmas (`bool`, *optional*, defaults to `False`):
172
+ Whether to use flow sigmas for step sizes in the noise schedule during the sampling process.
171
173
  timestep_spacing (`str`, defaults to `"linspace"`):
172
174
  The way the timesteps should be scaled. Refer to Table 2 of the [Common Diffusion Noise Schedules and
173
175
  Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) for more information.
@@ -212,6 +214,8 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
212
214
  steps_offset: int = 0,
213
215
  final_sigmas_type: Optional[str] = "zero", # "zero", "sigma_min"
214
216
  rescale_betas_zero_snr: bool = False,
217
+ use_dynamic_shifting: bool = False,
218
+ time_shift_type: str = "exponential",
215
219
  ):
216
220
  if self.config.use_beta_sigmas and not is_scipy_available():
217
221
  raise ImportError("Make sure to install scipy if you want to use beta sigmas.")
@@ -298,7 +302,9 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
298
302
  """
299
303
  self._begin_index = begin_index
300
304
 
301
- def set_timesteps(self, num_inference_steps: int, device: Union[str, torch.device] = None):
305
+ def set_timesteps(
306
+ self, num_inference_steps: int, device: Union[str, torch.device] = None, mu: Optional[float] = None
307
+ ):
302
308
  """
303
309
  Sets the discrete timesteps used for the diffusion chain (to be run before inference).
304
310
 
@@ -309,6 +315,9 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
309
315
  The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
310
316
  """
311
317
  # "linspace", "leading", "trailing" corresponds to annotation of Table 2. of https://huggingface.co/papers/2305.08891
318
+ if mu is not None:
319
+ assert self.config.use_dynamic_shifting and self.config.time_shift_type == "exponential"
320
+ self.config.flow_shift = np.exp(mu)
312
321
  if self.config.timestep_spacing == "linspace":
313
322
  timesteps = (
314
323
  np.linspace(0, self.config.num_train_timesteps - 1, num_inference_steps + 1)
@@ -140,8 +140,8 @@ class SchedulerMixin(PushToHubMixin):
140
140
 
141
141
  <Tip>
142
142
 
143
- To use private or [gated models](https://huggingface.co/docs/hub/models-gated#gated-models), log-in with
144
- `huggingface-cli login`. You can also activate the special
143
+ To use private or [gated models](https://huggingface.co/docs/hub/models-gated#gated-models), log-in with `hf
144
+ auth login`. You can also activate the special
145
145
  ["offline-mode"](https://huggingface.co/diffusers/installation.html#offline-mode) to use this method in a
146
146
  firewalled environment.
147
147
 
@@ -120,7 +120,7 @@ class FlaxSchedulerMixin(PushToHubMixin):
120
120
 
121
121
  <Tip>
122
122
 
123
- It is required to be logged in (`huggingface-cli login`) when you want to use private or [gated
123
+ It is required to be logged in (`hf auth login`) when you want to use private or [gated
124
124
  models](https://huggingface.co/docs/hub/models-gated#gated-models).
125
125
 
126
126
  </Tip>
@@ -3,12 +3,16 @@ import copy
3
3
  import gc
4
4
  import math
5
5
  import random
6
+ import re
7
+ import warnings
8
+ from contextlib import contextmanager
6
9
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
7
10
 
8
11
  import numpy as np
9
12
  import torch
10
13
 
11
14
  from .models import UNet2DConditionModel
15
+ from .pipelines import DiffusionPipeline
12
16
  from .schedulers import SchedulerMixin
13
17
  from .utils import (
14
18
  convert_state_dict_to_diffusers,
@@ -316,6 +320,80 @@ def free_memory():
316
320
  torch.xpu.empty_cache()
317
321
 
318
322
 
323
+ @contextmanager
324
+ def offload_models(
325
+ *modules: Union[torch.nn.Module, DiffusionPipeline], device: Union[str, torch.device], offload: bool = True
326
+ ):
327
+ """
328
+ Context manager that, if offload=True, moves each module to `device` on enter, then moves it back to its original
329
+ device on exit.
330
+
331
+ Args:
332
+ device (`str` or `torch.Device`): Device to move the `modules` to.
333
+ offload (`bool`): Flag to enable offloading.
334
+ """
335
+ if offload:
336
+ is_model = not any(isinstance(m, DiffusionPipeline) for m in modules)
337
+ # record where each module was
338
+ if is_model:
339
+ original_devices = [next(m.parameters()).device for m in modules]
340
+ else:
341
+ assert len(modules) == 1
342
+ # For DiffusionPipeline, wrap the device in a list to make it iterable
343
+ original_devices = [modules[0].device]
344
+ # move to target device
345
+ for m in modules:
346
+ m.to(device)
347
+
348
+ try:
349
+ yield
350
+ finally:
351
+ if offload:
352
+ # move back to original devices
353
+ for m, orig_dev in zip(modules, original_devices):
354
+ m.to(orig_dev)
355
+
356
+
357
+ def parse_buckets_string(buckets_str):
358
+ """Parses a string defining buckets into a list of (height, width) tuples."""
359
+ if not buckets_str:
360
+ raise ValueError("Bucket string cannot be empty.")
361
+
362
+ bucket_pairs = buckets_str.strip().split(";")
363
+ parsed_buckets = []
364
+ for pair_str in bucket_pairs:
365
+ match = re.match(r"^\s*(\d+)\s*,\s*(\d+)\s*$", pair_str)
366
+ if not match:
367
+ raise ValueError(f"Invalid bucket format: '{pair_str}'. Expected 'height,width'.")
368
+ try:
369
+ height = int(match.group(1))
370
+ width = int(match.group(2))
371
+ if height <= 0 or width <= 0:
372
+ raise ValueError("Bucket dimensions must be positive integers.")
373
+ if height % 8 != 0 or width % 8 != 0:
374
+ warnings.warn(f"Bucket dimension ({height},{width}) not divisible by 8. This might cause issues.")
375
+ parsed_buckets.append((height, width))
376
+ except ValueError as e:
377
+ raise ValueError(f"Invalid integer in bucket pair '{pair_str}': {e}") from e
378
+
379
+ if not parsed_buckets:
380
+ raise ValueError("No valid buckets found in the provided string.")
381
+
382
+ return parsed_buckets
383
+
384
+
385
+ def find_nearest_bucket(h, w, bucket_options):
386
+ """Finds the closes bucket to the given height and width."""
387
+ min_metric = float("inf")
388
+ best_bucket_idx = None
389
+ for bucket_idx, (bucket_h, bucket_w) in enumerate(bucket_options):
390
+ metric = abs(h * bucket_w - w * bucket_h)
391
+ if metric <= min_metric:
392
+ min_metric = metric
393
+ best_bucket_idx = bucket_idx
394
+ return best_bucket_idx
395
+
396
+
319
397
  # Adapted from torch-ema https://github.com/fadel/pytorch_ema/blob/master/torch_ema/ema.py#L14
320
398
  class EMAModel:
321
399
  """
@@ -20,10 +20,12 @@ from packaging import version
20
20
  from .. import __version__
21
21
  from .constants import (
22
22
  CONFIG_NAME,
23
+ DEFAULT_HF_PARALLEL_LOADING_WORKERS,
23
24
  DEPRECATED_REVISION_ARGS,
24
25
  DIFFUSERS_DYNAMIC_MODULE_NAME,
25
26
  FLAX_WEIGHTS_NAME,
26
27
  GGUF_FILE_EXTENSION,
28
+ HF_ENABLE_PARALLEL_LOADING,
27
29
  HF_MODULES_CACHE,
28
30
  HUGGINGFACE_CO_RESOLVE_ENDPOINT,
29
31
  MIN_PEFT_VERSION,
@@ -67,6 +69,9 @@ from .import_utils import (
67
69
  is_bitsandbytes_version,
68
70
  is_bs4_available,
69
71
  is_cosmos_guardrail_available,
72
+ is_flash_attn_3_available,
73
+ is_flash_attn_available,
74
+ is_flash_attn_version,
70
75
  is_flax_available,
71
76
  is_ftfy_available,
72
77
  is_gguf_available,
@@ -78,6 +83,8 @@ from .import_utils import (
78
83
  is_invisible_watermark_available,
79
84
  is_k_diffusion_available,
80
85
  is_k_diffusion_version,
86
+ is_kernels_available,
87
+ is_kornia_available,
81
88
  is_librosa_available,
82
89
  is_matplotlib_available,
83
90
  is_nltk_available,
@@ -90,6 +97,8 @@ from .import_utils import (
90
97
  is_peft_version,
91
98
  is_pytorch_retinaface_available,
92
99
  is_safetensors_available,
100
+ is_sageattention_available,
101
+ is_sageattention_version,
93
102
  is_scipy_available,
94
103
  is_sentencepiece_available,
95
104
  is_tensorboard_available,
@@ -108,6 +117,7 @@ from .import_utils import (
108
117
  is_unidecode_available,
109
118
  is_wandb_available,
110
119
  is_xformers_available,
120
+ is_xformers_version,
111
121
  requires_backends,
112
122
  )
113
123
  from .loading_utils import get_module_from_name, get_submodule_by_name, load_image, load_video
@@ -41,6 +41,10 @@ DIFFUSERS_DYNAMIC_MODULE_NAME = "diffusers_modules"
41
41
  HF_MODULES_CACHE = os.getenv("HF_MODULES_CACHE", os.path.join(HF_HOME, "modules"))
42
42
  DEPRECATED_REVISION_ARGS = ["fp16", "non-ema"]
43
43
  DIFFUSERS_REQUEST_TIMEOUT = 60
44
+ DIFFUSERS_ATTN_BACKEND = os.getenv("DIFFUSERS_ATTN_BACKEND", "native")
45
+ DIFFUSERS_ATTN_CHECKS = os.getenv("DIFFUSERS_ATTN_CHECKS", "0") in ENV_VARS_TRUE_VALUES
46
+ DEFAULT_HF_PARALLEL_LOADING_WORKERS = 8
47
+ HF_ENABLE_PARALLEL_LOADING = os.environ.get("HF_ENABLE_PARALLEL_LOADING", "").upper() in ENV_VARS_TRUE_VALUES
44
48
 
45
49
  # Below should be `True` if the current version of `peft` and `transformers` are compatible with
46
50
  # PEFT backend. Will automatically fall back to PEFT backend if the correct versions of the libraries are
@@ -2,6 +2,141 @@
2
2
  from ..utils import DummyObject, requires_backends
3
3
 
4
4
 
5
+ class AdaptiveProjectedGuidance(metaclass=DummyObject):
6
+ _backends = ["torch"]
7
+
8
+ def __init__(self, *args, **kwargs):
9
+ requires_backends(self, ["torch"])
10
+
11
+ @classmethod
12
+ def from_config(cls, *args, **kwargs):
13
+ requires_backends(cls, ["torch"])
14
+
15
+ @classmethod
16
+ def from_pretrained(cls, *args, **kwargs):
17
+ requires_backends(cls, ["torch"])
18
+
19
+
20
+ class AutoGuidance(metaclass=DummyObject):
21
+ _backends = ["torch"]
22
+
23
+ def __init__(self, *args, **kwargs):
24
+ requires_backends(self, ["torch"])
25
+
26
+ @classmethod
27
+ def from_config(cls, *args, **kwargs):
28
+ requires_backends(cls, ["torch"])
29
+
30
+ @classmethod
31
+ def from_pretrained(cls, *args, **kwargs):
32
+ requires_backends(cls, ["torch"])
33
+
34
+
35
+ class ClassifierFreeGuidance(metaclass=DummyObject):
36
+ _backends = ["torch"]
37
+
38
+ def __init__(self, *args, **kwargs):
39
+ requires_backends(self, ["torch"])
40
+
41
+ @classmethod
42
+ def from_config(cls, *args, **kwargs):
43
+ requires_backends(cls, ["torch"])
44
+
45
+ @classmethod
46
+ def from_pretrained(cls, *args, **kwargs):
47
+ requires_backends(cls, ["torch"])
48
+
49
+
50
+ class ClassifierFreeZeroStarGuidance(metaclass=DummyObject):
51
+ _backends = ["torch"]
52
+
53
+ def __init__(self, *args, **kwargs):
54
+ requires_backends(self, ["torch"])
55
+
56
+ @classmethod
57
+ def from_config(cls, *args, **kwargs):
58
+ requires_backends(cls, ["torch"])
59
+
60
+ @classmethod
61
+ def from_pretrained(cls, *args, **kwargs):
62
+ requires_backends(cls, ["torch"])
63
+
64
+
65
+ class FrequencyDecoupledGuidance(metaclass=DummyObject):
66
+ _backends = ["torch"]
67
+
68
+ def __init__(self, *args, **kwargs):
69
+ requires_backends(self, ["torch"])
70
+
71
+ @classmethod
72
+ def from_config(cls, *args, **kwargs):
73
+ requires_backends(cls, ["torch"])
74
+
75
+ @classmethod
76
+ def from_pretrained(cls, *args, **kwargs):
77
+ requires_backends(cls, ["torch"])
78
+
79
+
80
+ class PerturbedAttentionGuidance(metaclass=DummyObject):
81
+ _backends = ["torch"]
82
+
83
+ def __init__(self, *args, **kwargs):
84
+ requires_backends(self, ["torch"])
85
+
86
+ @classmethod
87
+ def from_config(cls, *args, **kwargs):
88
+ requires_backends(cls, ["torch"])
89
+
90
+ @classmethod
91
+ def from_pretrained(cls, *args, **kwargs):
92
+ requires_backends(cls, ["torch"])
93
+
94
+
95
+ class SkipLayerGuidance(metaclass=DummyObject):
96
+ _backends = ["torch"]
97
+
98
+ def __init__(self, *args, **kwargs):
99
+ requires_backends(self, ["torch"])
100
+
101
+ @classmethod
102
+ def from_config(cls, *args, **kwargs):
103
+ requires_backends(cls, ["torch"])
104
+
105
+ @classmethod
106
+ def from_pretrained(cls, *args, **kwargs):
107
+ requires_backends(cls, ["torch"])
108
+
109
+
110
+ class SmoothedEnergyGuidance(metaclass=DummyObject):
111
+ _backends = ["torch"]
112
+
113
+ def __init__(self, *args, **kwargs):
114
+ requires_backends(self, ["torch"])
115
+
116
+ @classmethod
117
+ def from_config(cls, *args, **kwargs):
118
+ requires_backends(cls, ["torch"])
119
+
120
+ @classmethod
121
+ def from_pretrained(cls, *args, **kwargs):
122
+ requires_backends(cls, ["torch"])
123
+
124
+
125
+ class TangentialClassifierFreeGuidance(metaclass=DummyObject):
126
+ _backends = ["torch"]
127
+
128
+ def __init__(self, *args, **kwargs):
129
+ requires_backends(self, ["torch"])
130
+
131
+ @classmethod
132
+ def from_config(cls, *args, **kwargs):
133
+ requires_backends(cls, ["torch"])
134
+
135
+ @classmethod
136
+ def from_pretrained(cls, *args, **kwargs):
137
+ requires_backends(cls, ["torch"])
138
+
139
+
5
140
  class FasterCacheConfig(metaclass=DummyObject):
6
141
  _backends = ["torch"]
7
142
 
@@ -17,6 +152,21 @@ class FasterCacheConfig(metaclass=DummyObject):
17
152
  requires_backends(cls, ["torch"])
18
153
 
19
154
 
155
+ class FirstBlockCacheConfig(metaclass=DummyObject):
156
+ _backends = ["torch"]
157
+
158
+ def __init__(self, *args, **kwargs):
159
+ requires_backends(self, ["torch"])
160
+
161
+ @classmethod
162
+ def from_config(cls, *args, **kwargs):
163
+ requires_backends(cls, ["torch"])
164
+
165
+ @classmethod
166
+ def from_pretrained(cls, *args, **kwargs):
167
+ requires_backends(cls, ["torch"])
168
+
169
+
20
170
  class HookRegistry(metaclass=DummyObject):
21
171
  _backends = ["torch"]
22
172
 
@@ -32,6 +182,21 @@ class HookRegistry(metaclass=DummyObject):
32
182
  requires_backends(cls, ["torch"])
33
183
 
34
184
 
185
+ class LayerSkipConfig(metaclass=DummyObject):
186
+ _backends = ["torch"]
187
+
188
+ def __init__(self, *args, **kwargs):
189
+ requires_backends(self, ["torch"])
190
+
191
+ @classmethod
192
+ def from_config(cls, *args, **kwargs):
193
+ requires_backends(cls, ["torch"])
194
+
195
+ @classmethod
196
+ def from_pretrained(cls, *args, **kwargs):
197
+ requires_backends(cls, ["torch"])
198
+
199
+
35
200
  class PyramidAttentionBroadcastConfig(metaclass=DummyObject):
36
201
  _backends = ["torch"]
37
202
 
@@ -47,10 +212,33 @@ class PyramidAttentionBroadcastConfig(metaclass=DummyObject):
47
212
  requires_backends(cls, ["torch"])
48
213
 
49
214
 
215
+ class SmoothedEnergyGuidanceConfig(metaclass=DummyObject):
216
+ _backends = ["torch"]
217
+
218
+ def __init__(self, *args, **kwargs):
219
+ requires_backends(self, ["torch"])
220
+
221
+ @classmethod
222
+ def from_config(cls, *args, **kwargs):
223
+ requires_backends(cls, ["torch"])
224
+
225
+ @classmethod
226
+ def from_pretrained(cls, *args, **kwargs):
227
+ requires_backends(cls, ["torch"])
228
+
229
+
50
230
  def apply_faster_cache(*args, **kwargs):
51
231
  requires_backends(apply_faster_cache, ["torch"])
52
232
 
53
233
 
234
+ def apply_first_block_cache(*args, **kwargs):
235
+ requires_backends(apply_first_block_cache, ["torch"])
236
+
237
+
238
+ def apply_layer_skip(*args, **kwargs):
239
+ requires_backends(apply_layer_skip, ["torch"])
240
+
241
+
54
242
  def apply_pyramid_attention_broadcast(*args, **kwargs):
55
243
  requires_backends(apply_pyramid_attention_broadcast, ["torch"])
56
244
 
@@ -85,6 +273,21 @@ class AsymmetricAutoencoderKL(metaclass=DummyObject):
85
273
  requires_backends(cls, ["torch"])
86
274
 
87
275
 
276
+ class AttentionBackendName(metaclass=DummyObject):
277
+ _backends = ["torch"]
278
+
279
+ def __init__(self, *args, **kwargs):
280
+ requires_backends(self, ["torch"])
281
+
282
+ @classmethod
283
+ def from_config(cls, *args, **kwargs):
284
+ requires_backends(cls, ["torch"])
285
+
286
+ @classmethod
287
+ def from_pretrained(cls, *args, **kwargs):
288
+ requires_backends(cls, ["torch"])
289
+
290
+
88
291
  class AuraFlowTransformer2DModel(metaclass=DummyObject):
89
292
  _backends = ["torch"]
90
293
 
@@ -235,6 +438,21 @@ class AutoencoderKLMochi(metaclass=DummyObject):
235
438
  requires_backends(cls, ["torch"])
236
439
 
237
440
 
441
+ class AutoencoderKLQwenImage(metaclass=DummyObject):
442
+ _backends = ["torch"]
443
+
444
+ def __init__(self, *args, **kwargs):
445
+ requires_backends(self, ["torch"])
446
+
447
+ @classmethod
448
+ def from_config(cls, *args, **kwargs):
449
+ requires_backends(cls, ["torch"])
450
+
451
+ @classmethod
452
+ def from_pretrained(cls, *args, **kwargs):
453
+ requires_backends(cls, ["torch"])
454
+
455
+
238
456
  class AutoencoderKLTemporalDecoder(metaclass=DummyObject):
239
457
  _backends = ["torch"]
240
458
 
@@ -850,6 +1068,21 @@ class PriorTransformer(metaclass=DummyObject):
850
1068
  requires_backends(cls, ["torch"])
851
1069
 
852
1070
 
1071
+ class QwenImageTransformer2DModel(metaclass=DummyObject):
1072
+ _backends = ["torch"]
1073
+
1074
+ def __init__(self, *args, **kwargs):
1075
+ requires_backends(self, ["torch"])
1076
+
1077
+ @classmethod
1078
+ def from_config(cls, *args, **kwargs):
1079
+ requires_backends(cls, ["torch"])
1080
+
1081
+ @classmethod
1082
+ def from_pretrained(cls, *args, **kwargs):
1083
+ requires_backends(cls, ["torch"])
1084
+
1085
+
853
1086
  class SanaControlNetModel(metaclass=DummyObject):
854
1087
  _backends = ["torch"]
855
1088
 
@@ -925,6 +1158,21 @@ class SD3Transformer2DModel(metaclass=DummyObject):
925
1158
  requires_backends(cls, ["torch"])
926
1159
 
927
1160
 
1161
+ class SkyReelsV2Transformer3DModel(metaclass=DummyObject):
1162
+ _backends = ["torch"]
1163
+
1164
+ def __init__(self, *args, **kwargs):
1165
+ requires_backends(self, ["torch"])
1166
+
1167
+ @classmethod
1168
+ def from_config(cls, *args, **kwargs):
1169
+ requires_backends(cls, ["torch"])
1170
+
1171
+ @classmethod
1172
+ def from_pretrained(cls, *args, **kwargs):
1173
+ requires_backends(cls, ["torch"])
1174
+
1175
+
928
1176
  class SparseControlNetModel(metaclass=DummyObject):
929
1177
  _backends = ["torch"]
930
1178
 
@@ -1180,6 +1428,70 @@ class WanVACETransformer3DModel(metaclass=DummyObject):
1180
1428
  requires_backends(cls, ["torch"])
1181
1429
 
1182
1430
 
1431
+ def attention_backend(*args, **kwargs):
1432
+ requires_backends(attention_backend, ["torch"])
1433
+
1434
+
1435
+ class ComponentsManager(metaclass=DummyObject):
1436
+ _backends = ["torch"]
1437
+
1438
+ def __init__(self, *args, **kwargs):
1439
+ requires_backends(self, ["torch"])
1440
+
1441
+ @classmethod
1442
+ def from_config(cls, *args, **kwargs):
1443
+ requires_backends(cls, ["torch"])
1444
+
1445
+ @classmethod
1446
+ def from_pretrained(cls, *args, **kwargs):
1447
+ requires_backends(cls, ["torch"])
1448
+
1449
+
1450
+ class ComponentSpec(metaclass=DummyObject):
1451
+ _backends = ["torch"]
1452
+
1453
+ def __init__(self, *args, **kwargs):
1454
+ requires_backends(self, ["torch"])
1455
+
1456
+ @classmethod
1457
+ def from_config(cls, *args, **kwargs):
1458
+ requires_backends(cls, ["torch"])
1459
+
1460
+ @classmethod
1461
+ def from_pretrained(cls, *args, **kwargs):
1462
+ requires_backends(cls, ["torch"])
1463
+
1464
+
1465
+ class ModularPipeline(metaclass=DummyObject):
1466
+ _backends = ["torch"]
1467
+
1468
+ def __init__(self, *args, **kwargs):
1469
+ requires_backends(self, ["torch"])
1470
+
1471
+ @classmethod
1472
+ def from_config(cls, *args, **kwargs):
1473
+ requires_backends(cls, ["torch"])
1474
+
1475
+ @classmethod
1476
+ def from_pretrained(cls, *args, **kwargs):
1477
+ requires_backends(cls, ["torch"])
1478
+
1479
+
1480
+ class ModularPipelineBlocks(metaclass=DummyObject):
1481
+ _backends = ["torch"]
1482
+
1483
+ def __init__(self, *args, **kwargs):
1484
+ requires_backends(self, ["torch"])
1485
+
1486
+ @classmethod
1487
+ def from_config(cls, *args, **kwargs):
1488
+ requires_backends(cls, ["torch"])
1489
+
1490
+ @classmethod
1491
+ def from_pretrained(cls, *args, **kwargs):
1492
+ requires_backends(cls, ["torch"])
1493
+
1494
+
1183
1495
  def get_constant_schedule(*args, **kwargs):
1184
1496
  requires_backends(get_constant_schedule, ["torch"])
1185
1497