make test_eager_matches_sdpa_inference less flaky#34512
Merged
Conversation
ydshieh
commented
Oct 30, 2024
ydshieh
commented
Oct 30, 2024
ydshieh
commented
Oct 30, 2024
|
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. |
gante
approved these changes
Oct 31, 2024
ArthurZucker
approved these changes
Oct 31, 2024
| if model.get_output_embeddings() is None: | ||
| self.skipTest("DoLa is not supported for models that don't have output embeddings") | ||
|
|
||
| logits_processor_kwargs = self._get_logits_processor_kwargs(do_sample=True, config=model.config) |
Collaborator
There was a problem hiding this comment.
do sample is random no?
Collaborator
Author
There was a problem hiding this comment.
I am using the same value as in generation_kwargs = {...} a few line below.
Yes it is random but this method is test_...._sample so makes sense.
BernardZach
pushed a commit
to BernardZach/transformers
that referenced
this pull request
Dec 5, 2024
* try * try * try * try * try * try * update * update * update * update * update * update * update --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
With
torch.bfloat16the numerical difference/instability occurs quite often, especially with multiple hidden layers.This PR first changes
test_eager_matches_sdpa_inferenceto create models with only 1 hidden layer.number of failures per 500 runs
Then it relaxes the condition a bit: only checks 80% of the sequences. If the results match on those 80%, the test pass.
This makes the test much less flaky. On 500 runs, it pass (for llama, mistral, idefics2 and Llava)
Finally, change the image size of
llavaandVipLlavafrom30to8so the sequence length is much smaller and avoid numerical issues.