Fix TextToAudioPipeline crash for tokenizer-only models - #48505
Open
jiqing-feng wants to merge 1 commit into
Open
Fix TextToAudioPipeline crash for tokenizer-only models#48505jiqing-feng wants to merge 1 commit into
jiqing-feng wants to merge 1 commit into
Conversation
jiqing-feng
force-pushed
the
fix-tts-pipeline-tokenizer-dtype
branch
from
September 3, 2026 08:50
dd29709 to
8e9a1f7
Compare
jiqing-feng
marked this pull request as ready for review
September 3, 2026 08:51
Since huggingface#40546, `TextToAudioPipeline.preprocess` unconditionally calls `output.to(dtype=self.model.dtype)`. Models without a processor (e.g. VITS / `facebook/mms-tts-eng`) go through a plain tokenizer, which returns a `BatchEncoding` whose `to()` only accepts a device, so this raised `TypeError: BatchEncoding.to() got an unexpected keyword argument 'dtype'`. Only cast when the preprocessor returned a `BatchFeature`; a `BatchEncoding` holds integer tensors only, so the cast was a no-op there anyway.
Contributor
CI recapDashboard: View test results in Grafana |
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.
Overview
Any text-to-audio model without a processor is broken on
main:tests/pipelines/test_pipelines_text_to_audio.py::TextToAudioPipelineTests::test_vits_model_ptfails onmain.Cause
#40546 (VibeVoice) added an unconditional cast at the end of
TextToAudioPipeline.preprocess:Models with a processor get a
BatchFeature, whoseto()acceptsdtype. Models without one (VITS, etc.) go through a plain tokenizer and get aBatchEncoding, whoseto()only accepts a device.Fix
Only cast when the preprocessor returned a
BatchFeature. ABatchEncodingholds integer tensors only, andBatchFeature.tocasts floating point tensors only, so this is a no-op for the tokenizer path either way.Verification
pytest tests/pipelines/test_pipelines_text_to_audio.py -k "vits or speecht5"— passes (fails onmain).facebook/mms-tts-eng, float16, CPU: pipeline runs, returns 45312 samples @ 16 kHz.