Repository navigation
Closed
Labels
Description
Bug Description
When attempting to train with GRPO (Group Relative Policy Optimization) using Unsloth, a TypeError occurs due to a method signature mismatch in the compiled cache.
- Did you update? Yes
ColaborKaggleor local / cloud: Remote Server/Notebook- Number GPUs used, use
nvidia-smi: 1 - Which notebook? Qwen2.5-3B and Gemma-3-1B-it
- Which Unsloth version, TRL version, transformers version, PyTorch version? (see below)
- Which trainer?
GRPOTrainer
Environment
- Unsloth version: 2025.7.1
- unsloth_zoo version: 2025.7.1
- TRL version: 0.19.1
- Transformers version: 4.53.1
- PyTorch version: 2.7.0
- bitsandbytes version: 0.46.1
- Python version: 3.11
- Operating System: Linux
- GPU: CUDA-enabled
Steps to Reproduce
- Install Unsloth 2025.7.1 with TRL 0.19.1
- Set up a GRPO trainer with Qwen2.5 model
- Call
trainer.train()on the GRPO trainer
Expected Behavior
Training should proceed without errors.
Actual Behavior
The following error occurs:
TypeError: _UnslothGRPOTrainer._get_per_token_logps() takes 5 positional arguments but 6 were given
Full Error Traceback
File ~/GRPO-Unsloth-Finetuning/GRPO-Qwen-Finetuning-Unsloth/unsloth_compiled_cache/UnslothGRPOTrainer.py:1988, in
_UnslothGRPOTrainer.compute_loss.<locals>.<lambda>(model, input_ids, attention_mask, logits_to_keep, batch_size, compute_entropy)
-> 1988 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']
TypeError: _UnslothGRPOTrainer._get_per_token_logps() takes 5 positional arguments but 6 were given
Root Cause
The issue is in the generated UnslothGRPOTrainer.py file at line 1958, where the lambda function calls self._get_per_token_logps() with a batch_size parameter, but the
method signature only accepts 4 parameters plus self:
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']
Additional Context
This appears to be a compatibility issue between the latest versions of Unsloth and TRL, likely introduced in recent updates to the method signatures.
Activity
rolandtannous commentedon Jul 10, 2025
@behroozazarkhalili
we just made a new release that should solve this problem for you.
If you're running the code on a local vm, make sure to upgrade your install of unsloth via
On the other hand, If you're running the notebooks on colab no need to do introduce any changes to the install cells as the notebook will grab the newest version from pypi for you anyway.
Make sure to leave a comment if this doesn't work out for you and we'll take it from there.
MadBonzz commentedon Jul 10, 2025
I am getting the same issue. Using unsloth/Qwen3-1.7B-Base model. The error comes when I run trainer.train().
This is the link to the colab notebook : https://colab.research.google.com/drive/1JcdaNYhwP4iYyzoRxjdaKs53pGJX_qcq?usp=sharing
I am running running it on colab via the kaggle jupyter server. On kaggle, the model itself is unable to load. This is the error I get on kaggle for loading the model :
Unsupported conversion from f16 to f16
LLVM ERROR: Unsupported rounding mode for conversion.
RuntimeError: PassManager::run failed
behroozazarkhalili commentedon Jul 10, 2025
Environment
No! The issue is still there! I have followed all the instructions you gave. :(
The identical error was raised again.
I specifically mentioned the line issue, and it seems that it has been changed in the new version.
Lucas-Fernandes-Martins commentedon Jul 10, 2025
Hi, I think the problem is line 376 of rl_replacements.py:
Function _get_per_token_logps accepts only 5 parameters:
So it seems one must add the batch_size argument to the function signature?
rolandtannous commentedon Jul 10, 2025
@Lucas-Fernandes-Martins already pushed a fix , Should be hopefully merged soon :)
Lucas-Fernandes-Martins commentedon Jul 10, 2025
Thank you :) that was so quick
behroozazarkhalili commentedon Jul 11, 2025
#863 and #2910 back again after this update to the merged version.
rolandtannous commentedon Jul 12, 2025
closing this as _get_per_token_logps() issue is resolved
let's follow up on the absmax issue on thread #2910