Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make safetensors the default #2120

Merged
merged 15 commits into from
Nov 8, 2023
Merged

Make safetensors the default #2120

merged 15 commits into from
Nov 8, 2023

Conversation

muellerzr
Copy link
Collaborator

What does this PR do?

Similar to transformers, makes safetensors the default and a library requirement 馃

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

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.

@LysandreJik @SunMarc @BenjaminBossan

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 3, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Looks great! Something that we're doing in transformers as well that you might want to do here, is to continue testing for safe_serialization=False in the common pathways.

By removing testing of the serialization of pytorch_model.bin (which we're doing as the default isn't explicitly defined in the tests and the default just changed), we're risking breaking that code without noticing.

You implemented another test, do you think maybe others would need implementing? That's what we did on transformers side (not merged yet): huggingface/transformers#27242

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

In general, this LGTM. I have a few questions for my understanding, the implementation looks clean though.

The whole of fsdp_utils.py still relies on torch.save, should this also be adjusted?

src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
src/accelerate/accelerator.py Show resolved Hide resolved
src/accelerate/checkpointing.py Show resolved Hide resolved
@BenjaminBossan
Copy link
Member

By removing testing of the serialization of pytorch_model.bin (which we're doing as the default isn't explicitly defined in the tests and the default just changed), we're risking breaking that code without noticing.

Good point.

You implemented another test, do you think maybe others would need implementing?

I think this is something where test coverage could be helpful, as it would reveal if we have code paths that are no longer taken but which used to be taken.

@muellerzr
Copy link
Collaborator Author

@LysandreJik @BenjaminBossan I've updated all of our tests that do anything with save/saving the model to use both .bin and .safetensors :)

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

LGTM ! I've left a few comments.

src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
src/accelerate/checkpointing.py Show resolved Hide resolved
src/accelerate/checkpointing.py Outdated Show resolved Hide resolved
Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Zach. I have a few comments but none are blockers.

src/accelerate/checkpointing.py Show resolved Hide resolved
src/accelerate/test_utils/testing.py Outdated Show resolved Hide resolved
Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Great, LGTM, thanks.

Comment on lines +67 to +68
If `safe_serialization` is `True`, models will be saved with `safetensors` while the rest are saved using native
`pickle`.
Copy link
Member

Choose a reason for hiding this comment

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

馃憤

return f"{func.__name__}_{param_based_name}"


@parameterized_class(("use_safetensors",), [[True], [False]], class_name_func=parameterized_custom_name_func)
Copy link
Member

Choose a reason for hiding this comment

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

TIL about parameterized_class.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Thanks for iterating @muellerzr! LGTM

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks for iterating !

@muellerzr muellerzr merged commit e638b1e into main Nov 8, 2023
26 checks passed
@muellerzr muellerzr deleted the safetensors-default-1 branch November 8, 2023 14:07
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.

None yet

5 participants