Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
1fb86e3
load and save dduf archive
SunMarc Nov 27, 2024
0389333
style
SunMarc Nov 27, 2024
2eeda25
switch to zip uncompressed
SunMarc Nov 28, 2024
cbee7cb
Merge branch 'main' into dduf
sayakpaul Nov 30, 2024
d840867
updates
sayakpaul Nov 29, 2024
78135f1
Merge branch 'main' into dduf
sayakpaul Dec 4, 2024
7d2c7d5
Update src/diffusers/pipelines/pipeline_utils.py
SunMarc Dec 4, 2024
e66c4d0
Update src/diffusers/pipelines/pipeline_utils.py
SunMarc Dec 4, 2024
b14bffe
first draft
SunMarc Dec 4, 2024
1cd5155
remove print
SunMarc Dec 4, 2024
b8a43e7
switch to dduf_file for consistency
SunMarc Dec 5, 2024
cac988a
Merge remote-tracking branch 'origin/main' into dduf
SunMarc Dec 5, 2024
977baa3
switch to huggingface hub api
SunMarc Dec 5, 2024
81bd097
fix log
SunMarc Dec 6, 2024
c4df147
Merge branch 'main' into dduf
sayakpaul Dec 8, 2024
d0a861c
add a basic test
sayakpaul Dec 8, 2024
1ec988f
Update src/diffusers/configuration_utils.py
SunMarc Dec 9, 2024
5217712
Update src/diffusers/pipelines/pipeline_utils.py
SunMarc Dec 9, 2024
6922226
Update src/diffusers/pipelines/pipeline_utils.py
SunMarc Dec 9, 2024
3b0d84d
fix
SunMarc Dec 9, 2024
1bc953b
Merge remote-tracking branch 'origin/dduf' into dduf
SunMarc Dec 9, 2024
04ecf0e
fix variant
SunMarc Dec 9, 2024
9fff68a
change saving logic
SunMarc Dec 10, 2024
ed6c727
DDUF - Load transformers components manually (#10171)
Wauplin Dec 11, 2024
17d50d1
working version with transformers and tokenizer !
SunMarc Dec 11, 2024
59929a5
add generation_config case
SunMarc Dec 12, 2024
aa0d497
fix tests
sayakpaul Dec 12, 2024
a793066
Merge branch 'main' into dduf
sayakpaul Dec 12, 2024
7602952
remove saving for now
SunMarc Dec 12, 2024
660d7c8
typing
SunMarc Dec 12, 2024
8358ef6
need next version from transformers
SunMarc Dec 12, 2024
4e7d15a
Update src/diffusers/configuration_utils.py
SunMarc Dec 12, 2024
cc75db3
check path corectly
SunMarc Dec 12, 2024
63575af
Merge remote-tracking branch 'origin/dduf' into dduf
SunMarc Dec 12, 2024
1e5ebf5
Apply suggestions from code review
SunMarc Dec 12, 2024
53e100b
udapte
SunMarc Dec 12, 2024
54991ac
Merge remote-tracking branch 'origin/dduf' into dduf
SunMarc Dec 12, 2024
1eb25dc
typing
SunMarc Dec 12, 2024
0cb1b98
remove check for subfolder
SunMarc Dec 12, 2024
5ec3951
quality
SunMarc Dec 12, 2024
1785eaa
revert setup changes
SunMarc Dec 12, 2024
7486016
oups
SunMarc Dec 12, 2024
73e81a5
more readable condition
SunMarc Dec 12, 2024
ea0126d
add loading from the hub test
sayakpaul Dec 13, 2024
3ebdcff
add basic docs.
sayakpaul Dec 13, 2024
5943a60
Merge branch 'main' into dduf
sayakpaul Dec 13, 2024
021abf0
Apply suggestions from code review
SunMarc Dec 13, 2024
af2ca07
add example
SunMarc Dec 13, 2024
9d70b6c
Merge branch 'main' into dduf
sayakpaul Dec 13, 2024
47cb92c
Merge remote-tracking branch 'origin/dduf' into dduf
SunMarc Dec 13, 2024
c9734ab
add
SunMarc Dec 13, 2024
27ebf9e
make functions private
SunMarc Dec 13, 2024
d5dbb5c
Apply suggestions from code review
SunMarc Dec 13, 2024
627aec0
resolve conflicts.
sayakpaul Dec 18, 2024
f0e21a9
Merge branch 'main' into dduf
sayakpaul Dec 18, 2024
e9b7429
minor.
sayakpaul Dec 18, 2024
b8b699a
fixes
sayakpaul Dec 18, 2024
6003176
Merge branch 'main' into dduf
sayakpaul Dec 18, 2024
0e54b06
fix
sayakpaul Dec 18, 2024
a026055
change the precdence of parameterized.
sayakpaul Dec 18, 2024
03e30b4
Merge remote-tracking branch 'upstream/main' into dduf
SunMarc Dec 23, 2024
da48dcb
Merge branch 'main' into dduf
SunMarc Dec 23, 2024
0fbea9a
Merge branch 'main' into dduf
sayakpaul Dec 30, 2024
6a163c7
error out when custom pipeline is passed with dduf_file.
sayakpaul Dec 30, 2024
67b617e
updates
sayakpaul Dec 31, 2024
b40272e
fix
sayakpaul Dec 31, 2024
ce237f3
updates
sayakpaul Dec 31, 2024
454b9b9
fixes
sayakpaul Dec 31, 2024
366aa2f
updates
sayakpaul Dec 31, 2024
6648995
fix xfail condition.
sayakpaul Dec 31, 2024
21ae7ee
fix xfail
sayakpaul Dec 31, 2024
15d4569
fixes
sayakpaul Dec 31, 2024
f3a4ddc
sharded checkpoint compat
SunMarc Jan 3, 2025
a032025
Merge branch 'dduf' of github.com:huggingface/diffusers into dduf
SunMarc Jan 3, 2025
faa0cac
Merge branch 'main' into dduf
sayakpaul Jan 3, 2025
0205cc8
add test for sharded checkpoint
SunMarc Jan 3, 2025
9cda4c1
Merge branch 'dduf' of github.com:huggingface/diffusers into dduf
SunMarc Jan 3, 2025
cd0734e
Merge branch 'main' into dduf
sayakpaul Jan 4, 2025
5037d39
add suggestions
SunMarc Jan 6, 2025
c9e08da
Merge branch 'dduf' of github.com:huggingface/diffusers into dduf
SunMarc Jan 6, 2025
02a368b
Update src/diffusers/models/model_loading_utils.py
SunMarc Jan 7, 2025
7bc9347
from suggestions
SunMarc Jan 7, 2025
fff5954
add class attributes to flag dduf tests
SunMarc Jan 7, 2025
da402da
last one
SunMarc Jan 7, 2025
9ebbf84
Merge branch 'main' into dduf
sayakpaul Jan 8, 2025
aaaa947
Merge branch 'main' into dduf
sayakpaul Jan 8, 2025
290b88d
resolve conflicts.
sayakpaul Jan 12, 2025
ac420af
fix logic
SunMarc Jan 13, 2025
f62527f
remove comment
SunMarc Jan 13, 2025
c34ce42
Merge remote-tracking branch 'upstream/main' into dduf
SunMarc Jan 13, 2025
c899fd0
revert changes
SunMarc Jan 13, 2025
bb1cff8
Merge branch 'main' into dduf
sayakpaul Jan 14, 2025
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
8 changes: 6 additions & 2 deletions src/diffusers/models/model_loading_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,12 @@ def _merge_sharded_checkpoints(
# Load tensors from each unique file
for file_name in files_to_load:
part_file_path = os.path.join(sharded_ckpt_cached_folder, file_name)
if not os.path.exists(part_file_path) or (dduf_entries and part_file_path not in dduf_entries):
raise FileNotFoundError(f"Part file {file_name} not found.")
if dduf_entries:
if part_file_path not in dduf_entries:
raise FileNotFoundError(f"Part file {file_name} not found.")
else:
if not os.path.exists(part_file_path):
raise FileNotFoundError(f"Part file {file_name} not found.")
Comment on lines +348 to +353
Copy link
Member Author

@SunMarc SunMarc Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with that !
This could be more concise with :

if part_file_path not in dduf_entries if dduf_entries else not os.path.exists(part_file_path):
    raise FileNotFoundError(f"Part file {file_name} not found.")

LMK what you prefer @sayakpaul


if is_safetensors:
if dduf_entries:
Expand Down
9 changes: 7 additions & 2 deletions src/diffusers/models/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
use_safetensors = kwargs.pop("use_safetensors", None)
quantization_config = kwargs.pop("quantization_config", None)
dduf_entries: Optional[Dict[str, DDUFEntry]] = kwargs.pop("dduf_entries", None)
disable_mmap = kwargs.pop("disable_mmap", False)

allow_pickle = False
if use_safetensors is None:
Expand Down Expand Up @@ -895,7 +896,9 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
# TODO (sayakpaul, SunMarc): remove this after model loading refactor
else:
param_device = torch.device(torch.cuda.current_device())
state_dict = load_state_dict(model_file, variant=variant, dduf_entries=dduf_entries)
state_dict = load_state_dict(
model_file, variant=variant, dduf_entries=dduf_entries, disable_mmap=disable_mmap
)
model._convert_deprecated_attention_blocks(state_dict)

# move the params from meta device to cpu
Expand Down Expand Up @@ -991,7 +994,9 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
else:
model = cls.from_config(config, **unused_kwargs)

state_dict = load_state_dict(model_file, variant=variant, dduf_entries=dduf_entries)
state_dict = load_state_dict(
model_file, variant=variant, dduf_entries=dduf_entries, disable_mmap=disable_mmap
)
model._convert_deprecated_attention_blocks(state_dict)

model, missing_keys, unexpected_keys, mismatched_keys, error_msgs = cls._load_pretrained_model(
Expand Down
8 changes: 6 additions & 2 deletions src/diffusers/utils/hub_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,12 @@ def _get_checkpoint_shard_files(
For the description of each arg, see [`PreTrainedModel.from_pretrained`]. `index_filename` is the full path to the
index (downloaded and cached if `pretrained_model_name_or_path` is a model ID on the Hub).
"""
if not os.path.isfile(index_filename) and (dduf_entries and index_filename not in dduf_entries):
raise ValueError(f"Can't find a checkpoint index ({index_filename}) in {pretrained_model_name_or_path}.")
if dduf_entries:
if index_filename not in dduf_entries:
raise ValueError(f"Can't find a checkpoint index ({index_filename}) in {pretrained_model_name_or_path}.")
else:
if not os.path.isfile(index_filename):
raise ValueError(f"Can't find a checkpoint index ({index_filename}) in {pretrained_model_name_or_path}.")

if dduf_entries:
index = json.loads(dduf_entries[index_filename].read_text())
Expand Down
Loading