Skip to content

[Whisper] Make tests faster#24105

Merged
sanchit-gandhi merged 1 commit into
huggingface:mainfrom
sanchit-gandhi:whisper-tests
Jun 20, 2023
Merged

[Whisper] Make tests faster#24105
sanchit-gandhi merged 1 commit into
huggingface:mainfrom
sanchit-gandhi:whisper-tests

Conversation

@sanchit-gandhi

Copy link
Copy Markdown
Contributor

What does this PR do?

Reduces the input seq length of the Whisper tests from 1500 -> 60 frames. This in turn should speed up the tests quite considerably.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to override this method to ensure that we init the Flax weights with the downsampled sequence length correctly (e.g. pass input_shape=init_shape)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused here. If you look at FlaxWhisperModelTest, there is no such overriding to pass input_shape. However, FlaxWhisperModelTester uses the low number as in this PR.

Why we don't need to pass init_shape in FlaxWhisperModelTest?

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@ydshieh

ydshieh commented Jun 8, 2023

Copy link
Copy Markdown
Collaborator

Sorry, I am asking not because I see a test being slow, but just I saw some more Whisper test failures on daily CI, which is tests/models/whisper/test_modeling_whisper.py::WhisperModelTest::test_cpu_offload.

But yes, in general, it's best to use low number. I will take a look.

@sanchit-gandhi

Copy link
Copy Markdown
Contributor Author

Note that the Whisper tests have already been flagged as being slow (#23736) so this should help combat this issue!

@ydshieh

ydshieh commented Jun 8, 2023

Copy link
Copy Markdown
Collaborator

It's not because it's slow test that we use large value without really valid reason :-). Always better to make them use low values is the goal, unless it's absolute necessary.

I still have questions on why we don't need to pass input_shape in the corresponding flax test file.

@ydshieh

ydshieh commented Jun 8, 2023

Copy link
Copy Markdown
Collaborator

OK, in flax test file, I see

        self.all_model_classes = (
            make_partial_class(model_class, input_shape=self.init_shape) for model_class in self.all_model_classes
        )

probably it's the reason.

@ydshieh ydshieh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @sanchit-gandhi LGTM. I convinced myself regarding the input_shape thing.
But any comment is welcomed.

@sanchit-gandhi

Copy link
Copy Markdown
Contributor Author

Yep agreed - the seq len was unnecessarily high here :) You're spot on regarding the init shape: we have to change this based on the sequence length since Flax Whisper initialises the positional embeddings based on the context window, so if we change the seq len (= context window) we need to init the weights with the new shape

@sgugger sgugger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sanchit-gandhi
sanchit-gandhi merged commit 6c13444 into huggingface:main Jun 20, 2023
@sanchit-gandhi
sanchit-gandhi deleted the whisper-tests branch June 20, 2023 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants