Skip to content

🐯 [Liger] add native liger-kernel ORPO loss#2482

Closed
kashif wants to merge 25 commits into
mainfrom
liger-orpo
Closed

🐯 [Liger] add native liger-kernel ORPO loss#2482
kashif wants to merge 25 commits into
mainfrom
liger-orpo

Conversation

@kashif

@kashif kashif commented Dec 15, 2024

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds support for Liger ORPO loss kernel to the ORPO Trainer natively.

@kashif kashif requested a review from qgallouedec December 15, 2024 12:55
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qgallouedec

Copy link
Copy Markdown
Member

2 questions/remarks:

  • can you run benchmark so that we can (1) quantify the improvement and (2) check that results with and without liger are the same
  • we could have an additional tag for the hub when a model is trained with liger

Comment thread tests/test_orpo_trainer.py Outdated
Comment thread trl/trainer/orpo_trainer.py
@qgallouedec

Copy link
Copy Markdown
Member

I think we should bump liger version to v0.5 (it doesn't include the loss before), see https://github.com/linkedin/Liger-Kernel/releases/tag/v0.5.0

kashif and others added 2 commits December 15, 2024 16:52
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Comment thread trl/trainer/orpo_trainer.py Outdated
Comment thread trl/trainer/orpo_trainer.py
@kashif kashif changed the title [Liger] add native liger-kernl orpo loss [Liger] add native liger-kernel orpo loss Dec 15, 2024

@SumanthRH SumanthRH left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! I stumbled upon this and wanted to highlight an important point (maybe this change is in progress already, in which case, great!)

Comment thread trl/trainer/orpo_trainer.py Outdated
Comment thread trl/trainer/orpo_trainer.py Outdated
loss = loss_fct(logits, labels)
return loss
if self.args.use_liger_loss:
# skip the lm head and get the last hidden state

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

I guess we don't have much of an option beyond using a config parameter for now.

Given that we run forward pass on a submodule, it would be very nice to have some validation so that there are no unexpected failures etc with different distributed training settings. But in this case, I feel there might be compatibility issues with FSDP given the limitation from the docs: https://pytorch.org/docs/stable/fsdp.html

"FSDP does not support running the forward pass of a submodule that is contained in an FSDP instance. This is because the submodule’s parameters will be sharded, but the submodule itself is not an FSDP instance, so its forward pass will not all-gather the full parameters appropriately."

(might be fixed by just making the base model attribute an FSDP instance as well, coz why not)

Beyond that this looks fine! I have a couple nits (don't matter that much):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @SumanthRH yes you are right get_decoder() will work

Yes next is to verify the distributed training cases

Comment thread tests/test_orpo_trainer.py Outdated
@kashif

kashif commented Dec 18, 2024

Copy link
Copy Markdown
Collaborator Author

waiting on linkedin/Liger-Kernel#486

@kashif

kashif commented Dec 19, 2024

Copy link
Copy Markdown
Collaborator Author

waiting on #2502

@qgallouedec

Copy link
Copy Markdown
Member

@kashif can you share the curves once it's ready?

@kashif

kashif commented Dec 29, 2024

Copy link
Copy Markdown
Collaborator Author

tests fail as they need: linkedin/Liger-Kernel#503

Comment thread setup.py Outdated
@kashif kashif requested a review from qgallouedec February 20, 2025 12:23

@qgallouedec qgallouedec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@shimizust

Copy link
Copy Markdown

Hi @kashif @qgallouedec thanks for the effort here! I was wondering what is the status? Can this be merged? Looks like one test failed, but not sure if it was a real issue

@qgallouedec qgallouedec changed the title [Liger] add native liger-kernel orpo loss 🐯 [Liger] add native liger-kernel ORPO loss Aug 20, 2025
@qgallouedec

Copy link
Copy Markdown
Member

closing as stale

@qgallouedec qgallouedec closed this May 4, 2026
@albertvillanova albertvillanova added the 😴 stale No update from the author, will be closed soon label Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

😴 stale No update from the author, will be closed soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants