-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
use scale=1.0 in floats_tensor called in speech model testers #17007
use scale=1.0 in floats_tensor called in speech model testers #17007
Conversation
The documentation is not available anymore as the PR was closed or merged. |
@@ -116,7 +116,7 @@ def __init__( | |||
self.adapter_output_seq_length = (self.output_seq_length - 1) // adapter_stride + 1 | |||
|
|||
def prepare_config_and_inputs(self): | |||
input_values = floats_tensor([self.batch_size, self.seq_length], self.vocab_size) | |||
input_values = floats_tensor([self.batch_size, self.seq_length], scale=1.0) |
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.
wow good catch!
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.
You're 100% right - this was indeed a bad copy paste!
Thanks for fixing all the tests! |
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 fix! Thanks a lot!
…gface#17007) Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
…gface#17007) Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
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.