Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Liger] add native liger-kernel orpo loss #2482

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

[Liger] add native liger-kernel orpo loss #2482

wants to merge 15 commits into from

Conversation

kashif
Copy link
Collaborator

@kashif kashif commented Dec 15, 2024

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

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
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

@qgallouedec
Copy link
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 kashif changed the title [Liger] add native liger-kernl orpo loss [Liger] add native liger-kernel orpo loss Dec 15, 2024
Copy link

@SumanthRH SumanthRH left a comment

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!)

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

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
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

def test_orpo_trainer_with_liger(self):
"""Test ORPO trainer with Liger loss enabled."""
with tempfile.TemporaryDirectory() as tmp_dir:
training_args = ORPOConfig(

This comment was marked as outdated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so the plot was with the same parameters with and without the liger_loss flag... rather than in general... so trying to figure out why there is a difference between the two settings...

@kashif
Copy link
Collaborator Author

kashif commented Dec 18, 2024

waiting on linkedin/Liger-Kernel#486

@kashif
Copy link
Collaborator Author

kashif commented Dec 19, 2024

waiting on #2502

@qgallouedec
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants