Skip to content

Remove use_safetensors from diffusers codebase #4243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
patrickvonplaten opened this issue Jul 24, 2023 · 8 comments · Fixed by #4521
Closed

Remove use_safetensors from diffusers codebase #4243

patrickvonplaten opened this issue Jul 24, 2023 · 8 comments · Fixed by #4521
Assignees

Comments

@patrickvonplaten
Copy link
Contributor

patrickvonplaten commented Jul 24, 2023

safetensors is now a required dependency as can be seen here: #4177

This means we can remove all of the following is_safetensors_available codesnippets:

scripts/convert_original_audioldm_to_diffusers.py
41:from diffusers.utils import is_omegaconf_available, is_safetensors_available
827:        if not is_safetensors_available():

src/diffusers/loaders.py
42:    is_safetensors_available,
48:if is_safetensors_available():
178:        if use_safetensors and not is_safetensors_available():
185:            use_safetensors = is_safetensors_available()
590:        if use_safetensors and not is_safetensors_available():
597:            use_safetensors = is_safetensors_available()
807:        if use_safetensors and not is_safetensors_available():
814:            use_safetensors = is_safetensors_available()
1055:        if use_safetensors and not is_safetensors_available():
1062:            use_safetensors = is_safetensors_available()
1389:        use_safetensors = kwargs.pop("use_safetensors", None if is_safetensors_available() else False)

examples/community/checkpoint_merger.py
7:from diffusers.utils import is_safetensors_available
10:if is_safetensors_available():
232:                        if (is_safetensors_available() and checkpoint_path_1.endswith(".safetensors"))
239:                            if (is_safetensors_available() and checkpoint_path_2.endswith(".safetensors"))

src/diffusers/utils/import_utils.py
302:def is_safetensors_available():

src/diffusers/utils/__init__.py
67:    is_safetensors_available,

src/diffusers/pipelines/pipeline_utils.py
55:    is_safetensors_available,
877:        use_safetensors = kwargs.pop("use_safetensors", None if is_safetensors_available() else False)
1169:        if use_safetensors and not is_safetensors_available():
1176:            use_safetensors = is_safetensors_available()

src/diffusers/models/modeling_utils.py
39:    is_safetensors_available,
59:if is_safetensors_available():
303:        if safe_serialization and not is_safetensors_available():
460:        if use_safetensors and not is_safetensors_available():
467:            use_safetensors = is_safetensors_available()

src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
51:from ...utils import is_omegaconf_available, is_safetensors_available, logging
1100:        if not is_safetensors_available():
1388:        if not is_safetensors_available():
@chiral-carbon
Copy link
Contributor

Hi! Does this entail that only all occurrences of is_safetensors_available should be cleaned out from the code and the subsequent if statements pertaining to it be removed?
If yes then I'd like to take up this issue as it seems like a very good starting point for contribution.
If it is more complicated than what I have assumed above then feel free to let me know, I'd still love to give it a shot.

@patrickvonplaten
Copy link
Contributor Author

Sounds great - @DN6 maybe you can help here?

@DN6
Copy link
Collaborator

DN6 commented Jul 25, 2023

Hi @chiral-carbon. Please go ahead and open a PR for this issue whenever you're ready. Additionally, you may need to update a few tests to reflect your changes. (see issue below)
#4244

I'd be happy to review your PR or answer any questions that you might have.

Thank you for taking the initiative here 🙌🏽

@chiral-carbon
Copy link
Contributor

@DN6 thank you! I will get started on this!

@patrickvonplaten
Copy link
Contributor Author

patrickvonplaten commented Aug 7, 2023

@DN6 maybe you could take the PR over here since it seems to have been stalled for a bit too long now

@chiral-carbon
Copy link
Contributor

chiral-carbon commented Aug 7, 2023

Hi, I’ll send a PR by the end of the week if you think that timeline works? I was held up due to travel, but I had started on it.
If it is too late tho then I understand, sorry re: the hold up!

@DN6
Copy link
Collaborator

DN6 commented Aug 8, 2023

Hi @chiral-carbon thanks for your PR. I'll do a review later today.

@peepeepeepoopoopoo
Copy link

Is that why I have this error? how do I solve it?

image

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 a pull request may close this issue.

4 participants