-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Generate: left-padding test, revisited #29515
Conversation
cc @zucchini-nlp -- this is a good example of us adding ugly flakiness-related loops because we didn't understand the cause for flakiness. Now that we understand that left-padding == not exactly the same results, we can write a clean test. |
next_logits_wo_padding = model(**model_kwargs).logits[:, -1, :] | ||
|
||
# With left-padding (length 32) | ||
pad_size = (input_ids.shape[0], 32) |
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.
Note that the test is now much harder (padding size went from 1 to 32)
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.
💘
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. |
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.
Nice refactor!
next_logits_wo_padding = model(**model_kwargs).logits[:, -1, :] | ||
|
||
# With left-padding (length 32) | ||
pad_size = (input_ids.shape[0], 32) |
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.
💘
next_logits_with_padding = model(**model_kwargs).logits[:, -1, :] | ||
|
||
# They should result in very similar logits | ||
self.assertTrue(torch.allclose(next_logits_wo_padding, next_logits_with_padding, atol=1e-5)) |
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.
surprised that this is enough to make it pass!
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
What does this PR do?
Now that we understand why left-padding doesn't produce the exact same outputs (see comment), this PR revisits the left-padding test.
In a nutshell: