huggingface / trl

Train transformer language models with reinforcement learning.
http://hf.co/docs/trl
Apache License 2.0
9.98k stars 1.26k forks source link

Overflow with padding left warning. #1842

Open ChristianPala opened 3 months ago

ChristianPala commented 3 months ago

Hi folks!

I've been trying to figure out why you have the warning in the code below for a while now, can you clarify?

if tokenizer.padding_side is not None and tokenizer.padding_side != "right": warnings.warn( "You passed a tokenizer withpadding_sidenot equal torightto the SFTTrainer. This might lead to some unexpected behaviour due to overflow issues when training a model in half-precision. You might consider addingtokenizer.padding_side = 'right'to your code." )

Thanks!

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

MAOJIASONG commented 2 months ago

I also have the same question! @ChristianPala

qgallouedec commented 2 months ago

Thanks for raising the question.

There seems to be a specific breaking case that has been observed here:

https://gist.github.com/younesbelkada/9f7f75c94bdc1981c8ca5cc937d4a4da?permalink_comment_id=4636728#gistcomment-4636728

The solution was to force the padding side to the right. I'm not able to provide much more information.

Related: https://github.com/huggingface/trl/pull/550

I'm leaving the issue open for visibility, if anyone is able to give more information and if possible solve the problem.