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

Bugfix: last minibatch padding #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

ojh31
Copy link
Collaborator

@ojh31 ojh31 commented Feb 7, 2024

To avoid the error TypeError: TransformerWithHead.forward() missing 1 required positional argument: 'input_ids' , similar to pytorch/pytorch#15161 when using dataparallel and the last minibatch gets truncated, we add right-padding to input_ids and then take off the extra logits/labels that this creates.

@CLAassistant
Copy link

CLAassistant commented Feb 7, 2024

CLA assistant check
All committers have signed the CLA.

# Ensure only the actual predictions and labels are extended,
# not the padded ones
all_logits.extend(logits[:mbatch_len].to(io_device))
all_labels.extend(labels[:mbatch_len])
all_logits = torch.stack(all_logits)
Copy link
Collaborator

Choose a reason for hiding this comment

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

One edge case to consider is what happens if mbatch_len is 0

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.

None yet

3 participants