Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix: fix config.torch_dtype bug (#874)

moontidef8ee7c42a32f1
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index e6c9280bc5c..445e5026f04 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -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