Let ASR models support bfloat16 dtype and cuda device #173
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.
This pull request improves device and dtype handling across the ExecuTorch export pipeline, ensuring that models, tensors, and modules are consistently placed on the correct device and use the appropriate data type. Additionally, it introduces a new test to validate exporting Whisper models with bfloat16 precision and checks the resulting file size.
Device and dtype consistency improvements:
optimum/exporters/executorch/integrations.pyto usemodel.deviceandmodel.dtypefor all relevant tensors and modules, replacing hardcoded"cpu"andtorch.float32values. This ensures exported models and caches are created on the correct device with the correct data type. [1] [2] [3] [4] [5]load_seq2seq_speech_modelinoptimum/exporters/executorch/tasks/asr.pyto acceptdeviceanddtypeas keyword arguments, passing them to the underlying model loading and export logic.Testing enhancements:
test_whisper_large_v3_turbo_export_bfloat16intests/models/test_modeling_whisper.pyto export the Whisper large v3 turbo model with bfloat16 precision, verify the output file exists, and check that its size is approximately 1.2GB with a 10% tolerance.