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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistral nits #57

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Mistral nits #57

merged 3 commits into from
Jun 19, 2024

Conversation

tengomucho
Copy link
Collaborator

@tengomucho tengomucho commented Jun 18, 2024

  • Add missing dependency on sentencepiece that is making the nightly CI fail.
  • Serve mistral in bfloat16 by default.

@tengomucho tengomucho requested a review from mfuntowicz June 18, 2024 12:52
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@mfuntowicz mfuntowicz left a comment

Choose a reason for hiding this comment

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

LGTM - One small comment to discuss

@classmethod
def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs):
# Unless specified otherwise, the model weights type will be bfloat16
torch_dtype = kwargs.pop("torch_dtype", torch.bfloat16)
Copy link
Member

Choose a reason for hiding this comment

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

Should we force torch.bfloat16 or rely on the config.json and use torch_dtype="auto" to respect the original checkpoint format?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should force to bfloat16 here, because that is what works faster on these TPUs

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with forcing bfloat16 for the compilation phase, but I'm not so sure about from_pretrained ? Wouldnt a user get the exact same model from the hub and then do whatever he wants with it?

And if going to compile, use bfloat16? Your call if you think this is the way to go, but just maybe print something to say the dtype was changed somehow to inform the end user in this case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you use from_pretrained, the model ends up being loaded in float32, that is the default for transformers, unless something else is specified, and disregarding the config (that says how the model was trained if I got it right). What I am doing here then is changing the default dtype, I think it should OK and that is aligned with the torch_dtype in Mistral.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ended up adding the warning as suggested.

@tengomucho tengomucho merged commit e86f08a into main Jun 19, 2024
4 checks passed
@tengomucho tengomucho deleted the mistral-nits branch June 19, 2024 13:33
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