Skip to content

Conversation

@a-r-r-o-w
Copy link
Contributor

What does this PR do?

When using .save_pretrained to save different modeling components, we lose control over being able to specify max shard size. Being able to store smaller shards of all modeling components without saving each component individually would be a nice control to have. This is particularly useful in the case of CogVideoX where having both text encoder and transformer in shard size of 10GB results in OOM on a Colab CPU. One needs to save the smaller shards in order to make loading the components possible and create the pipeline, which can then be inferred with something like enable_sequential_cpu_offload.

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@yiyixuxu @sayakpaul

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thanks!

@a-r-r-o-w
Copy link
Contributor Author

Thank you. Failing test seems unrelated

@a-r-r-o-w a-r-r-o-w merged commit 2454b98 into main Sep 16, 2024
17 of 18 checks passed
@a-r-r-o-w a-r-r-o-w deleted the max-shard-size-pipeline branch September 16, 2024 03:06
save_directory: Union[str, os.PathLike],
safe_serialization: bool = True,
variant: Optional[str] = None,
max_shard_size: Union[int, str] = "10GB",
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we leave the default at None, 5GB is the recommended default size we want to have across all huggingface libraries, we kept is at 10GB so that we won't start to automatically shard sdxl checkpoints. I don't think we should change this default value for our text encoders now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, let me open a quick follow-up PR

leisuzz pushed a commit to leisuzz/diffusers that referenced this pull request Oct 11, 2024
…e#9440)

allow max shard size to be specified when saving pipeline
sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
allow max shard size to be specified when saving pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants