Skip to content

Commit b3545f9

Browse files
committed
deprecate dduf.
1 parent c56add8 commit b3545f9

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

docs/source/en/using-diffusers/other-formats.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ pipeline = DiffusionPipeline.from_single_file(
220220

221221
### dduf
222222

223+
> [!WARNING]
224+
> 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.
225+
223226
> [!TIP]
224227
> 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.
225228

src/diffusers/pipelines/pipeline_utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
PushToHubMixin,
5959
_get_detailed_type,
6060
_is_valid_type,
61+
deprecate,
6162
is_accelerate_available,
6263
is_accelerate_version,
6364
is_bitsandbytes_version,
@@ -114,6 +115,11 @@
114115

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

118+
_DDUF_DEPRECATION_MESSAGE = (
119+
"Loading pipelines from DDUF files is deprecated and DDUF support will be removed entirely. "
120+
"Please save and load your pipelines using the standard Diffusers directory format instead."
121+
)
122+
117123
logger = logging.get_logger(__name__)
118124

119125

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

845852
if dduf_file:
853+
deprecate("dduf_file", "0.41.0", _DDUF_DEPRECATION_MESSAGE)
846854
if custom_pipeline:
847855
raise NotImplementedError("Custom pipelines are not supported with DDUF at the moment.")
848856
if load_connected_pipeline:
@@ -1572,7 +1580,8 @@ def download(cls, pretrained_model_name, **kwargs) -> str | os.PathLike:
15721580
Load weights from a specified variant filename such as `"fp16"` or `"ema"`. This is ignored when
15731581
loading `from_flax`.
15741582
dduf_file(`str`, *optional*):
1575-
Load weights from the specified DDUF file.
1583+
Load weights from the specified DDUF file. <Deprecated> This argument is deprecated and will be removed
1584+
in version 0.41.0. </Deprecated>
15761585
use_safetensors (`bool`, *optional*, defaults to `None`):
15771586
If set to `None`, the safetensors weights are downloaded if they're available **and** if the
15781587
safetensors library is installed. If set to `True`, the model is forcibly loaded from safetensors
@@ -1616,6 +1625,7 @@ def download(cls, pretrained_model_name, **kwargs) -> str | os.PathLike:
16161625
use_flashpack = kwargs.pop("use_flashpack", False)
16171626

16181627
if dduf_file:
1628+
deprecate("dduf_file", "0.41.0", _DDUF_DEPRECATION_MESSAGE)
16191629
if custom_pipeline:
16201630
raise NotImplementedError("Custom pipelines are not supported with DDUF at the moment.")
16211631
if load_connected_pipeline:

tests/pipelines/test_pipelines.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,16 @@ def test_dduf_raises_error_with_connected_pipeline(self):
20142014
"DDUF/tiny-flux-dev-pipe-dduf", dduf_file="fluxpipeline.dduf", load_connected_pipeline=True
20152015
)
20162016

2017+
@require_hf_hub_version_greater("0.26.5")
2018+
@require_transformers_version_greater("4.47.1")
2019+
def test_dduf_file_is_deprecated(self):
2020+
with tempfile.TemporaryDirectory() as tmpdir:
2021+
with self.assertWarns(FutureWarning) as warning_ctx:
2022+
_ = DiffusionPipeline.from_pretrained(
2023+
"DDUF/tiny-flux-dev-pipe-dduf", dduf_file="fluxpipeline.dduf", cache_dir=tmpdir
2024+
)
2025+
assert "dduf_file" in str(warning_ctx.warning)
2026+
20172027
@pytest.mark.xfail(condition=is_transformers_version(">", "4.56.2"), reason="Some import error", strict=False)
20182028
def test_wrong_model(self):
20192029
tokenizer = CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip")

0 commit comments

Comments
 (0)