[perf] optimize whisper GPU performance - #43139
Draft
JaredforReal wants to merge 9 commits into
Draft
Conversation
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: glmasr, whisper |
Collaborator
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?
Optimize WhisperFeatureExtractor GPU performance
Problem
The current
WhisperFeatureExtractor._torch_extract_fbank_features()has significant performance overhead when using GPU:torch.hann_window()on every callmel_filtersfrom CPU→GPU on every callSolution
Implement lazy caching mechanism to reuse GPU tensors across calls:
Key Changes:
_ensure_gpu_cache): Cachehann_windowandmel_filterson target devicenp.ndarrayandtorch.Tensorinputsreturn_tensorsparameter: Keep results on GPU whendevice != "cpu"andreturn_tensors="pt"torch.amax()instead of chained.max()callsPerformance Impact
Backward Compatibility
✅ Fully backward compatible:
device="cpu")Testing
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.