Skip to content

Commit

Permalink
Mistral nits (#57)
Browse files Browse the repository at this point in the history
* fix(mistral): add missing sentencepiece dependency

It is required for Mistral models.

* feat(mistral): added bfloat16 dtyle by default

* chore(models): add warning about implicit conversion to bfloat16
  • Loading branch information
tengomucho authored Jun 19, 2024
1 parent 3900bd7 commit e86f08a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions optimum/tpu/modeling_mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,3 +1630,12 @@ def forward(
hidden_states=outputs.hidden_states,
attentions=outputs.attentions,
)

@classmethod
def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs):
# Unless specified otherwise, the model weights type will be bfloat16
if "torch_dtype" not in kwargs:
logger.warning_once("Defaulting to `torch_dtype=torch.bfloat16` for this model")
torch_dtype = kwargs.pop("torch_dtype", torch.bfloat16)
# forward to base implementation
return super().from_pretrained(pretrained_model_name_or_path, *model_args, torch_dtype=torch_dtype, **kwargs)
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ dependencies = [
"transformers == 4.41.1",
"torch >= 2.3.0, <= 2.4.0",
"torch-xla[tpu] >= 2.3.0, <= 2.4.0",
"loguru == 0.6.0"
"loguru == 0.6.0",
"sentencepiece == 0.2.0",
]

[tool.setuptools_scm]
Expand Down
1 change: 1 addition & 0 deletions text-generation-inference/server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies = [
'safetensors == 0.4.2',
'transformers == 4.41.1',
'loguru == 0.6.0',
"sentencepiece == 0.2.0",
]

[tool.setuptools]
Expand Down

0 comments on commit e86f08a

Please sign in to comment.