You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Port GRPO chunked/hidden-state optimizations to ORPO/DPO/CPO trainers #5291
Hi guys! First off, thank you for the great library!
When I read about all the optimizations you did to enable RL GRPO with 7x longer context, I was super excited. However, I was a bit sad to find out that this optimization doesn't seem to be wired into the other preference trainer types yet.
Reading through the auto-generated unsloth_compiled_cache/UnslothORPOTrainer.py (and the DPO/CPO equivalents), I noticed the loss-computation methods (concatenated_forward, get_batch_logps, odds_ratio_loss, get_batch_loss_metrics) are essentially stock TRL.
Specifically, concatenated_forward materializes the full [2*B, S, V] logits tensor and runs a standard nn.CrossEntropyLoss over it. So, as far as I can tell:
ORPO/DPO/CPO end up running TRL's preference loss math on top of an Unsloth-patched model and training loop.
But the loss path itself doesn't use any of the memory-efficient chunked / hidden-state infrastructure that SFT and GRPO use to avoid materializing the full vocab tensor.
I think the other trainer types would massively benefit from the same optimizations you built for GRPO. Is there a plan to add these optimizations in the future, or am I missing some technical limitation why it won't work for these loss types?
I'd love to hear your thoughts 😄
Reacted by Lior Samuel, assafmu, vdryarden and daniella184
Same! I've noticed the improvement for GRPO, but was kinda surprised I didn't notice any change for ORPO. Thought I mis-configured something, turns out the optimization wasn't implemented yet.
Super interesting issue! I’ve seen the GRPO speed/memory gains too and was also hoping ORPO/DPO/CPO would benefit from the same tricks..
Curious if you already have some workaround or internal approach for this, or if it’s something that’s planned soon
Activity
liordon commentedon May 17, 2026
huh, I encountered the same issue and was wondering whether that was on purpose. thatnks for bringing this up!
is there a reason not to optimize this specific part?
assafmu commentedon May 17, 2026
Same! I've noticed the improvement for GRPO, but was kinda surprised I didn't notice any change for ORPO. Thought I mis-configured something, turns out the optimization wasn't implemented yet.
daniella184 commentedon May 17, 2026
Super interesting issue! I’ve seen the GRPO speed/memory gains too and was also hoping ORPO/DPO/CPO would benefit from the same tricks..
Curious if you already have some workaround or internal approach for this, or if it’s something that’s planned soon