Skip to content

Improve consistency of Liger Kernel initialization in DPO#6242

Merged
albertvillanova merged 3 commits into
mainfrom
align-liger-kernel-if
Jul 2, 2026
Merged

Improve consistency of Liger Kernel initialization in DPO#6242
albertvillanova merged 3 commits into
mainfrom
align-liger-kernel-if

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Jul 2, 2026

Copy link
Copy Markdown
Member

Improve consistency of Liger Kernel initialization in DPO.

This PR refactors how the Liger kernel is integrated into the DPOTrainer. The main changes improve consistency and clarity around enabling and initializing the Liger kernel and its associated loss function. It aligns the corresponding comments in the and KTOTrainer class.

Changes

Integration and initialization improvements for Liger kernel:

  • Standardized the assignment and checking of use_liger_kernel to use self.use_liger_kernel instead of directly referencing args.use_liger_kernel in both DPOTrainer and KTOTrainer constructors.
  • Moved the initialization of self.liger_loss_fn for the Liger kernel in DPOTrainer to after PEFT model checks, ensuring it is only set when appropriate.

Note

Low Risk
Small constructor reordering and comment/consistency changes in trainer init; no change to loss computation paths for valid configurations.

Overview
Aligns Liger kernel setup in DPOTrainer and KTOTrainer with a shared # Liger loss section and consistent use of self.use_liger_kernel in conditionals (DPO previously gated on args.use_liger_kernel).

In DPOTrainer, self.liger_loss_fn (LigerFusedLinearDPOLoss) is now created after all Liger validation, including PEFT checks for lm_head adapters and prompt-learning methods, instead of immediately after the single-loss-type check. Invalid configs fail before the fused loss object is constructed; supported setups are unchanged.

KTOTrainer only gets the matching comment tweak; behavior is unchanged.

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

@albertvillanova albertvillanova changed the title Improve consistency of Liger Kernel intialization in DPO Improve consistency of Liger Kernel initialization in DPO Jul 2, 2026
@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.

@albertvillanova albertvillanova merged commit 7140eec into main Jul 2, 2026
15 checks passed
@albertvillanova albertvillanova deleted the align-liger-kernel-if branch July 2, 2026 14:55
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.

2 participants