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

fix forward batching for seq2seq and right padding models. #139

Merged
merged 10 commits into from
Feb 9, 2023

Conversation

lvwerra
Copy link
Member

@lvwerra lvwerra commented Feb 8, 2023

This PR fixes issues with forward batching of models that pad to the right (e.g. bloom) and seq2seq models (e.g. T5).

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Feb 8, 2023

The documentation is not available anymore as the PR was closed or merged.

@lvwerra lvwerra marked this pull request as ready for review February 9, 2023 11:42
@lvwerra lvwerra requested a review from younesbelkada February 9, 2023 11:47
Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

This looks great to me! 💯
[optional] My only comment:

  • We can maybe not rely on self.datacollator and create the attention_mask ourselves (for e.g. attention_mask = q.ne(self.tokenizer.pad_token_id) * 1.0 ) ? This way if a user wants to build something on top of that can directly see where the correct attention_mask is created. i.e. passing a full-ones to data_collator to retrieve the correct one is IMO not very intuitive - maybe at least worth commenting it

@lvwerra
Copy link
Member Author

lvwerra commented Feb 9, 2023

Both runs seem to be converging normally:
GPT2: https://wandb.ai/lvwerra/trl/runs/9ufqpv3w
T5: https://wandb.ai/lvwerra/trl/runs/4rphjty6

@lvwerra lvwerra merged commit ccd2641 into main Feb 9, 2023
@lvwerra lvwerra deleted the forward_batching branch February 9, 2023 15:16
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