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:
moontidef 2024-08-05 14:45:34 +08:00 committed by GitHub
commit e3fa7aa908

View file

@ -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