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.

GPT OSS MXFP4 fix

Daniel Han64dff1456ba0
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index d0b7d4dc4cc..93415f56479 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -621,6 +621,7 @@ class FastModel(FastBaseModel):
"if hasattr(module, x): "\
"setattr(module, x, torch.nn.Parameter(getattr(module, x).to(torch.float32)) if isinstance(getattr(module, x), torch.nn.Parameter) else getattr(module, x).to(torch.float32))\n"\
"x = 'down_proj_bias'\n"\
+ "setattr(module, x, torch.nn.Parameter(getattr(module, x).to(torch.float32)) if isinstance(getattr(module, x), torch.nn.Parameter) else getattr(module, x).to(torch.float32))\n"\
";"
else:
# Set down projection compute dtype to be float32 for float16 machines
diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py
index 5524d8f16d3..a5de457cef5 100644
--- a/unsloth/models/vision.py
+++ b/unsloth/models/vision.py
@@ -457,8 +457,10 @@ class FastBaseModel:
# Edit data-types
if custom_datatype is not None:
- for jj, (name, module) in enumerate(model.named_modules()):
- exec(custom_datatype)
+ with torch.no_grad():
+ for jj, (name, module) in enumerate(model.named_modules()):
+ exec(custom_datatype)
+ pass
pass
pass
# Clear deleted GPU items