From c51468c40c9a60573a086bb9ef96c584ef578a0f Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 26 Oct 2025 22:39:38 -0700 Subject: [PATCH] Fixes --- unsloth/import_fixes.py | 4 ++-- unsloth/models/llama.py | 8 ++------ unsloth/models/mistral.py | 4 +++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.py index 85253a05f9..cac76909d9 100644 --- a/unsloth/import_fixes.py +++ b/unsloth/import_fixes.py @@ -150,8 +150,8 @@ def patch_ipykernel_hf_xet(): Version(importlib_version("ipykernel")) == Version("7.0.0") ): print( - "#### Unsloth: `hf_xet==1.1.10` and `ipykernel>6.30.1` breaks progress bars. Disabling for now in XET.\n"\ - "#### Unsloth: To re-enable progress bars, please downgrade to `ipykernel==6.30.1` or wait for a fix to\n"\ + "#### Unsloth: `hf_xet==1.1.10` and `ipykernel==7.0.0` breaks progress bars. Disabling for now in XET.\n"\ + "#### Unsloth: To re-enable progress bars, please upgrade to `ipykernel>7.0.0` or wait for a fix to\n"\ "https://github.com/huggingface/xet-core/issues/526" ) from huggingface_hub.utils import disable_progress_bars diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index 24d1fdfd06..874f5d91d0 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -1203,12 +1203,8 @@ def CausalLM_fast_forward(fast_forward_inference): else: RETURN_LOGITS = os.environ.get("UNSLOTH_RETURN_LOGITS", "0") == "1" # < 1024 Normal Unsloth uses less VRAM! - if DEVICE_TYPE == "hip": - # [TODO] AMD GPUs fail on chunked_cross_entropy loss! - # RuntimeError: Triton Error [HIP]: Code: 1, Messsage: invalid argument - RETURN_LOGITS = False - elif bsz*q_len <= 1024: - # Uses 800MB more VRAM it seems than fused CE Loss + if bsz * q_len <= 1024 and not RETURN_LOGITS: + # Use unsloth_fused_ce_loss which actually calculates the best chunk size to reduce VRAM usage RETURN_LOGITS = False if not RETURN_LOGITS and labels is not None: diff --git a/unsloth/models/mistral.py b/unsloth/models/mistral.py index faab2d30b1..4db712b078 100644 --- a/unsloth/models/mistral.py +++ b/unsloth/models/mistral.py @@ -298,7 +298,9 @@ def MistralForCausalLM_fast_forward( else: RETURN_LOGITS = os.environ.get("UNSLOTH_RETURN_LOGITS", "0") == "1" # < 1024 Normal Unsloth uses less VRAM! - if bsz * q_len <= 1024: RETURN_LOGITS = True + if bsz * q_len <= 1024 and not RETURN_LOGITS: + # Use unsloth_fused_ce_loss which actually calculates the best chunk size to reduce VRAM usage + RETURN_LOGITS = False if not RETURN_LOGITS and labels is not None: n_items = kwargs.get("num_items_in_batch", None) or kwargs.get("n_items", None)