diff --git a/pyproject.toml b/pyproject.toml index b538578fd5..ae46d7aaf5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,11 +37,11 @@ triton = [ ] huggingface = [ - "unsloth_zoo>=2025.7.2", + "unsloth_zoo>=2025.7.4", "packaging", "tyro", - "transformers>=4.51.3,!=4.47.0,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3", - "datasets>=3.4.1", + "transformers>=4.51.3,!=4.47.0,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0", + "datasets>=3.4.1,<4.0.0", "sentencepiece>=0.2.0", "tqdm", "psutil", @@ -381,11 +381,11 @@ colab-ampere-torch220 = [ "flash-attn>=2.6.3", ] colab-new = [ - "unsloth_zoo>=2025.7.2", + "unsloth_zoo>=2025.7.4", "packaging", "tyro", - "transformers>=4.51.3,!=4.47.0,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3", - "datasets>=3.4.1", + "transformers>=4.51.3,!=4.47.0,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0", + "datasets>=3.4.1,<4.0.0", "sentencepiece>=0.2.0", "tqdm", "psutil", diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 5076c422c8..c2520a66b5 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.7.2" +__version__ = "2025.7.3" __all__ = [ "SUPPORTS_BFLOAT16", diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.py index 002e4d1863..4d5b4d7a4d 100644 --- a/unsloth/models/rl_replacements.py +++ b/unsloth/models/rl_replacements.py @@ -176,7 +176,7 @@ def grpo_trainer__prepare_inputs(function_name, function): import re # This matches the function signature, decorators and any comments immediately following pattern = r"(\s*@profiling_decorator\s*\n\s*def _prepare_inputs\s*\([^\)]*\)\s*(->\s*[^:]+)?\s*:\s*\n(?:[ ]*#[^\n]*\n)*)" - + match = re.search(pattern, function) insert = ( " if hasattr(self, 'llm'):\n" @@ -196,7 +196,7 @@ def grpo_trainer__prepare_inputs(function_name, function): rest_of_function, flags=re.DOTALL | re.MULTILINE ) - + # We also need to remove the old wake up call from the beginning of the function # since it's injected before the comments. header_and_comments = re.sub( @@ -373,7 +373,11 @@ def grpo_trainer_compute_loss(function_name, function): _input_ids = input_ids _logits_to_keep = logits_to_keep - get_logps_func = lambda model, input_ids, attention_mask, logits_to_keep, batch_size=None, compute_entropy=False: self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep, batch_size) if hasattr(self, "_get_per_token_logps") else self._get_per_token_logps_and_entropies(model, input_ids, attention_mask, logits_to_keep, batch_size, compute_entropy)['logps'] + get_logps_func = \ + lambda model, input_ids, attention_mask, logits_to_keep, batch_size=None, compute_entropy=False: \ + self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep) \ + if hasattr(self, "_get_per_token_logps") else \ + self._get_per_token_logps_and_entropies(model, input_ids, attention_mask, logits_to_keep, batch_size, compute_entropy)['logps'] per_token_logps = get_logps_func(model, input_ids, attention_mask, logits_to_keep)