-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[SFT] Add seq_lengths
to signature columns
#3699
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
[SFT] Add seq_lengths
to signature columns
#3699
Conversation
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. |
waiting to merge until we've confirmed this fixes the issues raised in #3705 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!
This line of code may need to be adjusted as well (edit: nvm just saw the new commit) |
@jiosephlee fixed and tested and works thanks! |
Co-authored-by: Kashif Rasul <kashif.rasul@gmail.com>
What does this PR do?
To avoid cross-contamination when training with packed sequences, we pass
position_ids
to FA2. This was introduced in PR #3526, which calculatedposition_ids
during packing and added them to the dataset. To ensure these are retained,position_ids
must be set as a signature column; otherwise, theTrainer
will discard them as unused.https://github.com/huggingface/transformers/blob/ca7e1a3756c022bf31429c452b2f313f043f32de/src/transformers/trainer.py#L1007
While this was implemented correctly, PR #3649 introduced an optimized approach where
position_ids
are computed within the data collator using a new dataset column,seq_lengths
. However, the latter PR failed to update the signature column fromposition_ids
toseq_lengths
. As a result,seq_lengths
is not passed to the collator, causing it to behave as if the sequences are not packed.Before submitting
Pull Request section?
to it if that's the case.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.