Repository navigation
Closed
Labels
Description
- Did you update?
pip install --upgrade unsloth unsloth_zoo- yes ColaborKaggleor local / cloud - local- Number GPUs used, use
nvidia-smi- 1 L40s - Which notebook? Please link!
- Which Unsloth version, TRL version, transformers version, PyTorch version?
Name: unsloth
Version: 2026.2.1
Name: trl
Version: 0.24.0
Name: transformers
Version: 4.57.6
Name: torch
Version: 2.9.
- Which trainer?
SFTTrainer,GRPOTraineretc
GRPOTrainer
🦥 You can also ask via our Reddit page: https://reddit.com/r/unsloth/
Unsloth: Will smartly offload gradients to save VRAM!
Traceback (most recent call last):
File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/decomposer/unsloth/grpo_lora.py", line 202, in <module>
main(args)
File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/decomposer/unsloth/grpo_lora.py", line 170, in main
trainer.train(resume_from_checkpoint=resume_from_checkpoint)
File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 66, in wrapper
output = f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/.venv/lib/python3.12/site-packages/transformers/trainer.py", line 2325, in train
return inner_training_loop(
^^^^^^^^^^^^^^^^^^^^
File "<string>", line 330, in _fast_inner_training_loop
File "<string>", line 40, in _unsloth_training_step
File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 3698, in compute_loss
low_clip = masked_batch_mean(is_low_clipped.float())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 3687, in masked_batch_mean
return (x * completion_mask).sum() / completion_token_count
~~^~~~~~~~~~~~~~~~~
RuntimeError: The size of tensor a (828) must match the size of tensor b (824) at non-singleton dimension 1
[rank0]: Traceback (most recent call last):
[rank0]: File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/decomposer/unsloth/grpo_lora.py", line 202, in <module>
[rank0]: main(args)
[rank0]: File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/decomposer/unsloth/grpo_lora.py", line 170, in main
[rank0]: trainer.train(resume_from_checkpoint=resume_from_checkpoint)
[rank0]: File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 66, in wrapper
[rank0]: output = f(self, *args, **kwargs)
[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/.venv/lib/python3.12/site-packages/transformers/trainer.py", line 2325, in train
[rank0]: return inner_training_loop(
[rank0]: ^^^^^^^^^^^^^^^^^^^^
[rank0]: File "<string>", line 330, in _fast_inner_training_loop
[rank0]: File "<string>", line 40, in _unsloth_training_step
[rank0]: File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 3698, in compute_loss
[rank0]: low_clip = masked_batch_mean(is_low_clipped.float())
[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: File "/umbc/ada/ferraro/users/sroydip1/DecomposeRL/unsloth_compiled_cache/UnslothGRPOTrainer.py", line 3687, in masked_batch_mean
[rank0]: return (x * completion_mask).sum() / completion_token_count
[rank0]: ~~^~~~~~~~~~~~~~~~~
[rank0]: RuntimeError: The size of tensor a (828) must match the size of tensor b (824) at non-singleton dimension 1
Reacted by Shilong Deng
Activity
[-][Bug] Please fill in your issue title here.[/-][+][Bug] The size of tensor a (828) must match the size of tensor b (824) at non-singleton dimension 1[/+]GhostWalkers commentedon Feb 22, 2026
I have the same problem
GhostWalkers commentedon Feb 22, 2026
I can confirm that the issue only occurs in the current version; everything is fine in version 2026.1.4.
Regarding @darshjme-codes comment, I think this is a solution to the symptom, not the problem.
Datta0 commentedon Feb 23, 2026
@pluesclues something with masking. Can you please check
ingambe commentedon Mar 2, 2026
Same issue from my side
cmunley1 commentedon Mar 4, 2026
same here
Datta0 commentedon Mar 4, 2026
Hey guys, the PR linked above #4140 should fix it. Please wait till the changes are merged :)
danielhanchen commentedon Mar 8, 2026
Fixed by unslothai/unsloth-zoo#528 and #4140
We're going to do a Pypi release, so to update Unsloth, please do
pip install --upgrade --force-reinstall --no-deps --no-cache-dir unsloth unsloth_zoo