Skip to content

Align Liger loss naming across core trainers#6243

Merged
albertvillanova merged 4 commits into
mainfrom
align-liger-loss-name
Jul 2, 2026
Merged

Align Liger loss naming across core trainers#6243
albertvillanova merged 4 commits into
mainfrom
align-liger-loss-name

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Jul 2, 2026

Copy link
Copy Markdown
Member

Align Liger loss naming across core trainers.

This PR standardizes the naming of the Liger loss attribute in both the DPO and GRPO trainers, changing it from liger_loss_fn or liger_grpo_loss to a consistent liger_loss. It also updates all references in the code and associated tests to use the new attribute name. This change improves code readability and maintainability by ensuring a single, clear attribute name is used throughout.

Changes

Attribute renaming and code consistency

  • Renamed the Liger loss attribute from liger_grpo_loss and liger_loss_fn to liger_loss in both trl/trainer/grpo_trainer.py and trl/trainer/dpo_trainer.py, and updated all internal references accordingly.
  • Updated method calls to use self.liger_loss instead of the previous attribute names in both trainers.

Test updates

  • Updated all test assertions and mocks in tests/test_grpo_trainer.py to use liger_loss instead of liger_grpo_loss.

Note

Low Risk
Rename-only refactor across trainers and tests with no logic changes; any external code that referenced the old attribute names would break at import/runtime.

Overview
Standardizes how DPO and GRPO trainers expose the fused Liger loss module by using a single liger_loss attribute instead of liger_loss_fn (DPO) and liger_grpo_loss (GRPO).

Initialization and forward paths in dpo_trainer.py and grpo_trainer.py now assign and call self.liger_loss with the same LigerFusedLinear* instances as before. GRPO tests that mock or assert on the Liger module were updated to use trainer.liger_loss.

This is a naming-only change; loss computation and trainer behavior are unchanged.

Reviewed by Cursor Bugbot for commit 16d0d51. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

bot-ci-comment Bot commented Jul 2, 2026

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

better. cc @kashif fyi

@albertvillanova albertvillanova merged commit 85e9a1f into main Jul 2, 2026
13 checks passed
@albertvillanova albertvillanova deleted the align-liger-loss-name branch July 2, 2026 14:59
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.

3 participants