Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/en/using-diffusers/other-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ pipeline = DiffusionPipeline.from_single_file(

### dduf

> [!WARNING]
> DDUF support is deprecated and will be removed in version 0.41.0. Save and load your pipelines using the standard Diffusers directory format instead.

> [!TIP]
> DDUF is an experimental file type and the API may change. Refer to the DDUF [docs](https://huggingface.co/docs/hub/dduf) to learn more.

Expand Down
14 changes: 12 additions & 2 deletions src/diffusers/pipelines/pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
PushToHubMixin,
_get_detailed_type,
_is_valid_type,
deprecate,
is_accelerate_available,
is_accelerate_version,
is_bitsandbytes_version,
Expand Down Expand Up @@ -121,6 +122,11 @@

SUPPORTED_DEVICE_MAP = ["balanced"] + [get_device(), "cpu"]

_DDUF_DEPRECATION_MESSAGE = (
"Loading pipelines from DDUF files is deprecated and DDUF support will be removed entirely. "
"Please save and load your pipelines using the standard Diffusers directory format instead."
)

logger = logging.get_logger(__name__)


Expand Down Expand Up @@ -737,7 +743,8 @@ def from_pretrained(cls, pretrained_model_name_or_path: str | os.PathLike, **kwa
Load weights from a specified variant filename such as `"fp16"` or `"ema"`. This is ignored when
loading `from_flax`.
dduf_file(`str`, *optional*):
Load weights from the specified dduf file.
Load weights from the specified dduf file. <Deprecated> This argument is deprecated and will be removed
in version 0.41.0. </Deprecated>
disable_mmap ('bool', *optional*, defaults to 'False'):
Whether to disable mmap when loading a Safetensors model. This option can perform better when the model
is on a network mount or hard drive, which may not handle the seeky-ness of mmap very well.
Expand Down Expand Up @@ -852,6 +859,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: str | os.PathLike, **kwa
)

if dduf_file:
deprecate("dduf_file", "0.41.0", _DDUF_DEPRECATION_MESSAGE)
if custom_pipeline:
raise NotImplementedError("Custom pipelines are not supported with DDUF at the moment.")
if load_connected_pipeline:
Expand Down Expand Up @@ -1581,7 +1589,8 @@ def download(cls, pretrained_model_name, **kwargs) -> str | os.PathLike:
Load weights from a specified variant filename such as `"fp16"` or `"ema"`. This is ignored when
loading `from_flax`.
dduf_file(`str`, *optional*):
Load weights from the specified DDUF file.
Load weights from the specified DDUF file. <Deprecated> This argument is deprecated and will be removed
in version 0.41.0. </Deprecated>
use_safetensors (`bool`, *optional*, defaults to `None`):
If set to `None`, the safetensors weights are downloaded if they're available **and** if the
safetensors library is installed. If set to `True`, the model is forcibly loaded from safetensors
Expand Down Expand Up @@ -1625,6 +1634,7 @@ def download(cls, pretrained_model_name, **kwargs) -> str | os.PathLike:
use_flashpack = kwargs.pop("use_flashpack", False)

if dduf_file:
deprecate("dduf_file", "0.41.0", _DDUF_DEPRECATION_MESSAGE)
if custom_pipeline:
raise NotImplementedError("Custom pipelines are not supported with DDUF at the moment.")
if load_connected_pipeline:
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/ace_step/test_ace_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class AceStepPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
# ACE-Step uses custom attention, not standard diffusers attention processors
test_attention_slicing = False
test_xformers_attention = False
supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
Expand Down
33 changes: 0 additions & 33 deletions tests/pipelines/allegro/test_allegro.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import gc
import inspect
import os
import tempfile
import unittest

import numpy as np
Expand All @@ -28,9 +26,7 @@
backend_empty_cache,
enable_full_determinism,
numpy_cosine_similarity_distance,
require_hf_hub_version_greater,
require_torch_accelerator,
require_transformers_version_greater,
slow,
torch_device,
)
Expand Down Expand Up @@ -308,35 +304,6 @@ def test_vae_tiling(self, expected_diff_max: float = 0.2):
"VAE tiling should not affect the inference results",
)

@require_hf_hub_version_greater("0.26.5")
@require_transformers_version_greater("4.47.1")
def test_save_load_dduf(self):
# reimplement because it needs `enable_tiling()` on the loaded pipe.
from huggingface_hub import export_folder_as_dduf

components = self.get_dummy_components()
pipe = self.pipeline_class(**components)
pipe = pipe.to(torch_device)
pipe.set_progress_bar_config(disable=None)

inputs = self.get_dummy_inputs(device="cpu")
inputs.pop("generator")
inputs["generator"] = torch.manual_seed(0)

pipeline_out = pipe(**inputs)[0].cpu()

with tempfile.TemporaryDirectory() as tmpdir:
dduf_filename = os.path.join(tmpdir, f"{pipe.__class__.__name__.lower()}.dduf")
pipe.save_pretrained(tmpdir, safe_serialization=True)
export_folder_as_dduf(dduf_filename, folder_path=tmpdir)
loaded_pipe = self.pipeline_class.from_pretrained(tmpdir, dduf_file=dduf_filename).to(torch_device)

loaded_pipe.vae.enable_tiling()
inputs["generator"] = torch.manual_seed(0)
loaded_pipeline_out = loaded_pipe(**inputs)[0].cpu()

assert np.allclose(pipeline_out, loaded_pipeline_out)


@slow
@require_torch_accelerator
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/anyflow/test_anyflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class AnyFlowPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
]
)
test_xformers_attention = False
supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/anyflow/test_anyflow_far.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class AnyFlowFARPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
]
)
test_xformers_attention = False
supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/audioldm2/test_audioldm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ class AudioLDM2PipelineFastTests(PipelineTesterMixin, unittest.TestCase):
]
)

supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
unet = AudioLDM2UNet2DConditionModel(
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/bria_fibo/test_pipeline_bria_fibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class BriaFiboPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
test_xformers_attention = False
test_layerwise_casting = False
test_group_offloading = False
supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class BriaFiboPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
test_xformers_attention = False
test_layerwise_casting = False
test_group_offloading = False
supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/chronoedit/test_chronoedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class ChronoEditPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
]
)
test_xformers_attention = False
supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cogview4/test_cogview4.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class CogView4PipelineFastTests(PipelineTesterMixin, unittest.TestCase):
]
)

supports_dduf = False
test_xformers_attention = False
test_layerwise_casting = True

Expand Down
4 changes: 0 additions & 4 deletions tests/pipelines/controlnet/test_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ class StableDiffusionMultiControlNetPipelineFastTests(
batch_params = TEXT_TO_IMAGE_BATCH_PARAMS
image_params = frozenset([]) # TO_DO: add image_params once refactored VaeImageProcessor.preprocess

supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
unet = UNet2DConditionModel(
Expand Down Expand Up @@ -494,8 +492,6 @@ class StableDiffusionMultiControlNetOneModelPipelineFastTests(
batch_params = TEXT_TO_IMAGE_BATCH_PARAMS
image_params = frozenset([]) # TO_DO: add image_params once refactored VaeImageProcessor.preprocess

supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
unet = UNet2DConditionModel(
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/controlnet/test_controlnet_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ class StableDiffusionMultiControlNetPipelineFastTests(
batch_params = TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
image_params = frozenset([]) # TO_DO: add image_params once refactored VaeImageProcessor.preprocess

supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
unet = UNet2DConditionModel(
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/controlnet/test_controlnet_inpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@ class MultiControlNetInpaintPipelineFastTests(
params = TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
batch_params = TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS

supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
unet = UNet2DConditionModel(
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/controlnet/test_controlnet_inpaint_sdxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ class ControlNetPipelineSDXLFastTests(
}
)

supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
unet = UNet2DConditionModel(
Expand Down
4 changes: 0 additions & 4 deletions tests/pipelines/controlnet/test_controlnet_sdxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ class StableDiffusionXLMultiControlNetPipelineFastTests(
batch_params = TEXT_TO_IMAGE_BATCH_PARAMS
image_params = frozenset([]) # TO_DO: add image_params once refactored VaeImageProcessor.preprocess

supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
unet = UNet2DConditionModel(
Expand Down Expand Up @@ -660,8 +658,6 @@ class StableDiffusionXLMultiControlNetOneModelPipelineFastTests(
batch_params = TEXT_TO_IMAGE_BATCH_PARAMS
image_params = frozenset([]) # TO_DO: add image_params once refactored VaeImageProcessor.preprocess

supports_dduf = False

def get_dummy_components(self):
torch.manual_seed(0)
unet = UNet2DConditionModel(
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cosmos/test_cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class CosmosTextToWorldPipelineFastTests(PipelineTesterMixin, unittest.TestCase)
"callback_on_step_end_tensor_inputs",
]
)
supports_dduf = False
test_xformers_attention = False
test_layerwise_casting = True
test_group_offloading = True
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cosmos/test_cosmos2_5_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Cosmos2_5_PredictPipelineFastTests(PipelineTesterMixin, unittest.TestCase)
"callback_on_step_end_tensor_inputs",
]
)
supports_dduf = False
test_xformers_attention = False
test_layerwise_casting = True
test_group_offloading = True
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cosmos/test_cosmos2_5_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class Cosmos2_5_TransferPipelineFastTests(PipelineTesterMixin, unittest.TestCase
"callback_on_step_end_tensor_inputs",
]
)
supports_dduf = False
test_xformers_attention = False
test_layerwise_casting = True
test_group_offloading = True
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cosmos/test_cosmos2_text2image.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class Cosmos2TextToImagePipelineFastTests(PipelineTesterMixin, unittest.TestCase
"callback_on_step_end_tensor_inputs",
]
)
supports_dduf = False
test_xformers_attention = False
test_layerwise_casting = True
test_group_offloading = True
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cosmos/test_cosmos2_video2world.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class Cosmos2VideoToWorldPipelineFastTests(PipelineTesterMixin, unittest.TestCas
"callback_on_step_end_tensor_inputs",
]
)
supports_dduf = False
test_xformers_attention = False
test_layerwise_casting = True
test_group_offloading = True
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cosmos/test_cosmos_video2world.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class CosmosVideoToWorldPipelineFastTests(PipelineTesterMixin, unittest.TestCase
"callback_on_step_end_tensor_inputs",
]
)
supports_dduf = False
test_xformers_attention = False
test_layerwise_casting = True
test_group_offloading = True
Expand Down
7 changes: 0 additions & 7 deletions tests/pipelines/deepfloyd_if/test_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
backend_reset_peak_memory_stats,
load_numpy,
require_accelerator,
require_hf_hub_version_greater,
require_torch_accelerator,
require_transformers_version_greater,
skip_mps,
slow,
torch_device,
Expand Down Expand Up @@ -90,11 +88,6 @@ def test_inference_batch_single_identical(self):
def test_xformers_attention_forwardGenerator_pass(self):
self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3)

@require_hf_hub_version_greater("0.26.5")
@require_transformers_version_greater("4.47.1")
def test_save_load_dduf(self):
super().test_save_load_dduf(atol=1e-2, rtol=1e-2)

@unittest.skip("Functionality is tested elsewhere.")
def test_save_load_optional_components(self):
pass
Expand Down
7 changes: 0 additions & 7 deletions tests/pipelines/deepfloyd_if/test_if_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
floats_tensor,
load_numpy,
require_accelerator,
require_hf_hub_version_greater,
require_torch_accelerator,
require_transformers_version_greater,
skip_mps,
slow,
torch_device,
Expand Down Expand Up @@ -103,11 +101,6 @@ def test_inference_batch_single_identical(self):
expected_max_diff=1e-2,
)

@require_hf_hub_version_greater("0.26.5")
@require_transformers_version_greater("4.47.1")
def test_save_load_dduf(self):
super().test_save_load_dduf(atol=1e-2, rtol=1e-2)

@unittest.skip("Functionality is tested elsewhere.")
def test_save_load_optional_components(self):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
floats_tensor,
load_numpy,
require_accelerator,
require_hf_hub_version_greater,
require_torch_accelerator,
require_transformers_version_greater,
skip_mps,
slow,
torch_device,
Expand Down Expand Up @@ -100,11 +98,6 @@ def test_inference_batch_single_identical(self):
expected_max_diff=1e-2,
)

@require_hf_hub_version_greater("0.26.5")
@require_transformers_version_greater("4.47.1")
def test_save_load_dduf(self):
super().test_save_load_dduf(atol=1e-2, rtol=1e-2)

@unittest.skip("Functionality is tested elsewhere.")
def test_save_load_optional_components(self):
pass
Expand Down
7 changes: 0 additions & 7 deletions tests/pipelines/deepfloyd_if/test_if_inpainting.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
floats_tensor,
load_numpy,
require_accelerator,
require_hf_hub_version_greater,
require_torch_accelerator,
require_transformers_version_greater,
skip_mps,
slow,
torch_device,
Expand Down Expand Up @@ -100,11 +98,6 @@ def test_inference_batch_single_identical(self):
expected_max_diff=1e-2,
)

@require_hf_hub_version_greater("0.26.5")
@require_transformers_version_greater("4.47.1")
def test_save_load_dduf(self):
super().test_save_load_dduf(atol=1e-2, rtol=1e-2)

@unittest.skip("Test done elsewhere.")
def test_save_load_optional_components(self, expected_max_difference=0.0001):
pass
Expand Down
Loading
Loading