Set scale_embedding to False in some TF tests#15952
Merged
ydshieh merged 2 commits intohuggingface:masterfrom Mar 7, 2022
Merged
Set scale_embedding to False in some TF tests#15952ydshieh merged 2 commits intohuggingface:masterfrom
ydshieh merged 2 commits intohuggingface:masterfrom
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
gante
approved these changes
Mar 7, 2022
patrickvonplaten
approved these changes
Mar 7, 2022
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?
This PR set
scale_embedding=FalseinTFSpeech2TextModelTesterto avoidinputs_embedsand the PT/TF difference being scaled by 4 - the objective is to keep a low tolerance1e-5in the PT/TF test, as we see several times this is a strong safe guard!(This is not a real bug. It's also similar to #15684, where we got larger differences between PT/TF simply because the model weights are initialized with larger values).
TF: @gante @Rocketknight1
Speech: @patrickvonplaten
More context
Set
scale_embeddingtoFalsein some TF tests.Current
Speech2TextConfighas default scale_embedding=True. Therefore we havespeech_to_texthas hidden_size=16, and thereforeinputs_embedswill be scaled by 4.transformers/src/transformers/models/speech_to_text/modeling_tf_speech_to_text.py
Lines 843 to 844 in 9932ee4
Since
inputs_embedshere is obtained by some (conv.) layer instead of via look-up table, it contains some tiny difference between PT/TF. This difference is scaled by 4 throughself.embed_scale.This makes
TFSpeech2TextModelthe only one model that will fail the aggressive PT/TF test introduced in #15839 (with low tolerance1e-5). More precisely, the output tensors failed areencoder_hidden_states_0andencoder_hidden_states_1.Results
With this PR, the tolerance
1e-5works for all TF models'test_pt_tf_model_equivalence(in #15839), both on GPU / CPU, tested 100 times per model.