Skip to content

Implement VibeVoice - #40546

Open
pengzhiliang wants to merge 264 commits into
huggingface:mainfrom
pengzhiliang:main
Open

Implement VibeVoice #40546
pengzhiliang wants to merge 264 commits into
huggingface:mainfrom
pengzhiliang:main

Conversation

@pengzhiliang

@pengzhiliang pengzhiliang commented Aug 29, 2025

Copy link
Copy Markdown

@ebezzam ebezzam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pengzhiliang thanks for the PR! This is an exciting model to add 🔥

My first comments are mainly on rearranging content to be consistent with the other models in Transformers, and creating a modular file to better optimize copying components from other models in Transformers.

There are also some other files to modify:

  • in src/transformers/models/auto
  • in docs
  • and eventually some tests (for which a lot of code can be copied from other models)

As an example of typical files to create/modify, you can check out the Qwen2.5-Omni PR, which is also multimodal.

Comment thread src/transformers/models/vibevoice/__init__.py
Comment thread src/transformers/models/vibevoice/audio_streamer.py Outdated
Comment thread src/transformers/models/vibevoice/configuration_vibevoice.py Outdated
Comment thread src/transformers/models/vibevoice/configuration_vibevoice.py Outdated
Comment thread src/transformers/models/vibevoice/configuration_vibevoice.py Outdated
Comment thread src/transformers/models/vibevoice/vibevoice_processor.py Outdated
Comment thread src/transformers/models/vibevoice/vibevoice_processor.py Outdated
Comment thread src/transformers/models/vibevoice/vibevoice_audio_processor.py Outdated
Comment thread src/transformers/models/vibevoice/vibevoice_audio_processor.py Outdated
Comment thread src/transformers/models/vibevoice/vibevoice_audio_processor.py Outdated
@fakerybakery

Copy link
Copy Markdown

Hopefully this PR can get merged, since the deletion of the VibeVoice repo not sure the original authors can continue contributing to this PR

Galigator added a commit to Galigator/transformers that referenced this pull request Oct 8, 2025
@fakerybakery

Copy link
Copy Markdown

Glad to see that someone has picked this PR up, thanks 🤗

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@ebezzam ebezzam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@eustlb an idea for getting the desired labels for training via the chat template.

I'm not super convinced (also because we don't have a precedent) but happy to get your thoughts!

Comment on lines +81 to +82
# Default to the feature extractor's own sampling rate
kwargs.setdefault("sampling_rate", self.feature_extractor.sampling_rate)

@ebezzam ebezzam Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ugly hack to avoid the warning:

[transformers] It is strongly recommended to pass the `sampling_rate` argument to `VibeVoiceAcousticTokenizerFeatureExtractor()`. Failing to do so can result in silent errors that might be hard to debug.

because _defaults needs to be empty to satisfy this new style check

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.

You can add a trf ignore instead of this workaround

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks, and I wonder if we really need to keep this type of guard for future feature extractors? otherwise new models will always need this ignore

cc @eustlb maybe something for #44394

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.

We need it, it's an opinionated choice that's been made and that is still of great importance IMO. It means that the style check will have to get adapted to take this into account thought

Comment on lines +139 to +141
# NOTE: mask padding through the attention mask, as the padding and EOS token share the same ID
if "attention_mask" in data:
labels[data["attention_mask"] == 0] = -100

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

because padding and EOS tokens are the same as per Qwen2 here

Comment on lines +136 to +138
{%- if not add_generation_prompt %}
{%- if has_target_audio %}{{ audio_token }}{{ audio_eos_token }}{% endif %}{{ eos_token }}
{%- endif %}"""

@ebezzam ebezzam Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one idea for distinguishing between training/inference regime

  • add_generation_prompt=True (inference) -> no eos_token
  • add_generation_prompt=False (training) -> append eos_token

here is a script to see the chat template rendering before tokenization.

there is one TRL chat template that does this, but in reality TRL doesn't have a strict requirement on the chat template as they often create their own to make sure they are compatible with training. See their collection of chat templates here and guidelines here.

although I'm still not sure if this is the best approach. As Higgs still sets add_generation_prompt=True for training here

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.

add_generation_prompt=True on higgs shouldn't be there, nice catch !!
nevertheless we got lucky there because eos comes from the codebooks, so this has no detrimental effect

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.

ahhhhh it's really tricky here, I'd be tempted to say yes, let's use add_generation_prompt for that but it means overloading a parameter for a behavior it was not intended for...

Nevertheless TRL does use it to that end, so I am ok with that!

Comment on lines +176 to +187
# Processor kwargs are passed separately from Jinja2 template kwargs.
processor_kwargs = kwargs.pop("processor_kwargs", None) or {}
chat_template_kwargs = {
"tokenize": True,
"return_dict": True,
"add_generation_prompt": True,
"processor_kwargs": processor_kwargs,
**kwargs,
}
output = preprocessor.apply_chat_template(
text.messages,
tokenize=True,
return_dict=True,
**kwargs,
**chat_template_kwargs,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(this file in general needs a revamp, but I think worth adding things as we see them?)

We should be passing "add_generation_prompt": True? As do all of Higgs audio examples and if we do go with using add_generation_prompt to distinguish between training/inference for Vibevoice

as well as passing processor_kwargs separately

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@eustlb eustlb 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.

Clean 👏👏👏 Great work!!

Comment on lines 532 to 533
[conversation1, conversation2],
add_generation_prompt=True,
tokenize=True,

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.

indeed!

Comment on lines +174 to +175
if not is_soundfile_available():
raise ImportError("Please install `soundfile` to save audio files.")

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.

updating to main you'll be able to use requires_backends(self, ["soundfile"])

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 30251954355:2
Result: success | Jobs: 16 | Tests: 175,446 | Failures: 1 | Duration: 9h 49m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.