diff --git a/pyproject.toml b/pyproject.toml index 1d206913a9..01636e75f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ triton = [ ] huggingface = [ - "unsloth_zoo>=2025.3.4", + "unsloth_zoo>=2025.3.5", "packaging", "tyro", "transformers>=4.46.1,!=4.47.0", @@ -354,7 +354,7 @@ colab-ampere-torch220 = [ "flash-attn>=2.6.3", ] colab-new = [ - "unsloth_zoo>=2025.3.4", + "unsloth_zoo>=2025.3.5", "packaging", "tyro", "transformers>=4.46.1,!=4.47.0", diff --git a/unsloth/__init__.py b/unsloth/__init__.py index 4336ec494b..9ed356db54 100644 --- a/unsloth/__init__.py +++ b/unsloth/__init__.py @@ -198,7 +198,7 @@ pass # Check for unsloth_zoo try: unsloth_zoo_version = importlib_version("unsloth_zoo") - if Version(unsloth_zoo_version) < Version("2025.3.4"): + if Version(unsloth_zoo_version) < Version("2025.3.5"): try: os.system("pip install --upgrade --no-cache-dir --no-deps unsloth_zoo") except: diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index c01e0ccc82..7ac35d71b4 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.6" +__version__ = "2025.3.7" __all__ = [ "SUPPORTS_BFLOAT16", @@ -1052,8 +1052,7 @@ def _unsloth_pre_compute_loss(self, model, inputs, *args, **kwargs): # Get gradient accumulation steps if possible if num_items_in_batch is None and \ - getattr(self, "args", {}).get("gradient_accumulation_steps", 1) != 1: - + getattr(getattr(self, "args", self), "gradient_accumulation_steps", 1) != 1: name = (model.base_model.model if hasattr(model, "base_model") else model).__class__.__name__ logger.warning_once( f"Unsloth: Not an error, but {name} does not accept `num_items_in_batch`.\n"\ diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index 3dacf5cdd5..a490fb8ab4 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -1843,7 +1843,7 @@ class FastLlamaModel: else: inner_training_loop = Trainer._original_training_loop except: - raise RuntimeError('Unsloth currently does not support multi GPU setups - but we are working on it!') + raise RuntimeError('Unsloth: Unsuccessfully patched inner_training_loop') pass import transformers.trainer @@ -1869,7 +1869,7 @@ class FastLlamaModel: f"{chr(92)} / Data Parallel GPUs = {args.world_size} | Total batch size ({self._train_batch_size} x {args.gradient_accumulation_steps} x {args.world_size}) = {total_train_batch_size:,}\\n"\\ f' "-____-" Trainable parameters = {get_model_param_count(model, trainable_only=True):,}/{get_model_param_count(model):,} ({get_model_param_count(model, trainable_only=True)/get_model_param_count(model)*100:.2f}% trained)' logger.warning(debug_info) - import subprocess, re, gc + import gc for _ in range(3): gc.collect() torch.cuda.empty_cache()""" @@ -1897,9 +1897,6 @@ class FastLlamaModel: "_inner_training_loop", "_fast_inner_training_loop", 1, ) - exec(inner_training_loop, globals()) - - Trainer._inner_training_loop = _fast_inner_training_loop inner_training_loop = inner_training_loop.replace( "is_torch_tpu_available()", "False",