use scale=1.0 in floats_tensor called in speech model testers #17007
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?
Fix the failure of
Speech2TextModelTest.test_pt_tf_model_equivalence
. This is caused bytransformers/tests/speech_to_text/test_modeling_speech_to_text.py
Lines 134 to 136 in e6f00a1
where the
input_features
get a large magnitude of1e2
(fromself.vocab_size=99
).(probably this happens because we just copied the
input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
from NLP models?)I changed it to
scale=1.0
, but need @patrickvonplaten's expertise to make sure there was no particular reason to useself.vocab_size
.Details
Current speech model testers have
The
self.vocab_size
argument is thescale
, so the generated dummyinput_values
has the magnitude ofself.vocab_size
.For
Speech2TextModelTester
, we havevocab_size=99
.Furthermore,
Speech2TextEncoder
hastransformers/src/transformers/models/speech_to_text/modeling_speech_to_text.py
Line 705 in e6f00a1
and from the tester's
hidden_size=16,
we getembed_scale=4
.The
input_features
goes through the conv layer(s) and being scaled:transformers/src/transformers/models/speech_to_text/modeling_speech_to_text.py
Lines 767 to 768 in e6f00a1
On
CPU
however, the conv layers of PT/TF gives diff. with a magnitude of1e-7
for input values with 1s. So with the above 2 scalings, this error becomes4e-5
, and the PT/TF equiv. test fails.