trl icon indicating copy to clipboard operation
trl copied to clipboard

Completions Only Loss is incompatible with use_liger_kernel set as true

Open arashpreetsinghmor opened this issue 1 year ago • 4 comments

Hi Team, discovered that completions only loss does not work when use_liger_kernel is set as true, since this line drops the completion_mask. Is this an expected behavior?

https://github.com/huggingface/trl/blob/65245f6be8dea3d559a58788eca439f9c2d0f1e2/trl/trainer/sft_trainer.py#L670

arashpreetsinghmor avatar May 22 '25 23:05 arashpreetsinghmor

Has anyone solved this issue?

BlueZeros avatar Jun 05 '25 15:06 BlueZeros

@qgallouedec or @kashif Can you help with this question? I think this came in from this change: https://github.com/huggingface/trl/commit/5b9236d1e8d062ad76f088b0730e36c724ec170c

shimizust avatar Jun 17 '25 00:06 shimizust

I've been running into this issue too.

You can bypass it by processing your datasets manually, and passing dataset_kwargs={'skip_prepare_dataset': True} to SFTConfig:

training_args = SFTConfig(
    ...,
    dataset_kwargs = {'skip_prepare_dataset': True}
)

Alternatively I believe you could edit

https://github.com/huggingface/trl/blob/6a6d4345c9e0ded5bdcfc67ca2d8d20ecb75d309/trl/trainer/sft_trainer.py#L794-L795

to include 'completion_mask' as well:

if args.use_liger_kernel:
    dataset = dataset.select_columns({"input_ids", "position_ids", "completion_mask"}.intersection(dataset.column_names))

kswhitecross avatar Jun 28 '25 23:06 kswhitecross

closing this issue in favor of the fix here #3674

shirinyamani avatar Jul 02 '25 18:07 shirinyamani