fix: fix config.torch_dtype bug (#874)
fix the bug #404 and the bug https://github.com/hiyouga/LLaMA-Factory/issues/4698#issue-2393500878
This commit is contained in:
parent
65d1330dc4
commit
e3fa7aa908
1 changed files with 8 additions and 1 deletions
|
|
@ -570,7 +570,14 @@ def LlamaModel_fast_forward(
|
|||
# Embed positions
|
||||
if inputs_embeds is None:
|
||||
inputs_embeds = self.embed_tokens(input_ids)
|
||||
|
||||
|
||||
if self.config.torch_dtype == "float32":
|
||||
self.config.torch_dtype = torch.float32
|
||||
elif self.config.torch_dtype == "bfloat16":
|
||||
self.config.torch_dtype = torch.bfloat16
|
||||
elif self.config.torch_dtype == "float16":
|
||||
self.config.torch_dtype = torch.float16
|
||||
|
||||
inputs_embeds = inputs_embeds.to(self.config.torch_dtype)
|
||||
|
||||
# Normalized from Gemma
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue