Skip to content

Fix text-to-speech pipeline crash when generation config contains None values#45107

Merged
Rocketknight1 merged 6 commits intohuggingface:mainfrom
jiqing-feng:dev
Apr 8, 2026
Merged

Fix text-to-speech pipeline crash when generation config contains None values#45107
Rocketknight1 merged 6 commits intohuggingface:mainfrom
jiqing-feng:dev

Conversation

@jiqing-feng
Copy link
Copy Markdown
Contributor

Description

The text-to-speech pipeline crashes when loading models whose generation_config contains fields set to None (e.g. use_cache=None). This is because TextToAudioPipeline.__init__ blindly copies all generation config values into the model config via config.update(gen_config.to_dict()), which triggers huggingface_hub's strict dataclass field validation when a None value is assigned to a typed field (e.g. bool).

The fix filters out None values before updating the config.

Reproduction

from transformers import pipeline

synthesiser = pipeline("text-to-speech", "sesame/csm-1b", device="cpu")
huggingface_hub.errors.StrictDataclassFieldValidationError: Validation error for field 'use_cache':
    TypeError: Field 'use_cache' expected bool, got NoneType (value: None)

Fix

- config.update(gen_config.to_dict())
+ config.update({k: v for k, v in gen_config.to_dict().items() if v is not None})

@jiqing-feng jiqing-feng marked this pull request as ready for review March 30, 2026 02:32
@jiqing-feng
Copy link
Copy Markdown
Contributor Author

Hi @ydshieh . Would you please review this PR? Thanks!

@jiqing-feng
Copy link
Copy Markdown
Contributor Author

Hi @Rocketknight1 . Would you please review this PR? Thanks!

Copy link
Copy Markdown
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

Yeah, makes sense to me! None values probably do not want to override any existing config settings anyway.

@Rocketknight1 Rocketknight1 enabled auto-merge April 8, 2026 16:57
@Rocketknight1 Rocketknight1 added this pull request to the merge queue Apr 8, 2026
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Merged via the queue into huggingface:main with commit 380e3cc Apr 8, 2026
16 checks passed
bigshanedogg pushed a commit to bigshanedogg/transformers that referenced this pull request Apr 9, 2026
…None` values (huggingface#45107)

fix text-to-audio pipeline config

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
sirzechs66 pushed a commit to sirzechs66/transformers that referenced this pull request Apr 18, 2026
…None` values (huggingface#45107)

fix text-to-audio pipeline config

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
@jiqing-feng jiqing-feng deleted the dev branch April 20, 2026 02:29
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.

3 participants