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.

Bug fixes

Daniel Han6a03ea2f811e
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 0f0d4c159fe..2423e8f9424 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__version__ = "2025.3.1"
+__version__ = "2025.3.4"
__all__ = [
"SUPPORTS_BFLOAT16",
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index bcabbd51256..a5bc8712e97 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -1538,6 +1538,7 @@ def _wrap_fast_inference(generate, device_type, dtype, model):
# Wraps inference with bfloat16 / float16
@torch.inference_mode
def _fast_generate(*args, **kwargs):
+ if hasattr(model, "for_inference"): model.for_inference()
if hasattr(model, "config") and hasattr(model.config, "max_position_embeddings"):
if "input_ids" in kwargs and kwargs["input_ids"] is not None and "max_new_tokens" in kwargs:
@@ -1603,6 +1604,9 @@ def _wrap_fast_inference(generate, device_type, dtype, model):
accelerate.utils.operations.send_to_device = accelerate_old_send_to_device
pass
+ # Return to training state
+ if hasattr(model, "for_training"): model.for_training()
+
return output
pass
return _fast_generate
@@ -2416,6 +2420,9 @@ class FastLlamaModel:
model.load_lora = partial(load_lora, model)
pass
+ # Add for_inference and for_training
+ model.for_training = partial(FastLlamaModel.for_training, model)
+ model.for_inference = partial(FastLlamaModel.for_inference, model)
return model
pass