-
Notifications
You must be signed in to change notification settings - Fork 31k
make test_eager_matches_sdpa_inference less flaky
#34512
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
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. |
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.
LGTM 👍 Thank you for fixing
Extra note: L4170 (model_sdpa = model_class.from_pretrained(tmpdirname, torch_dtype=torch_dtype)) should also have attn_implementation="sdpa", in case we update the default.
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.
thanks !
| 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) |
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.
do sample is random no?
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.
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.
* try * try * try * try * try * try * update * update * update * update * update * update * update --------- Co-authored-by: ydshieh <[email protected]>
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.