Skip to content

Implement VibeVoice #40546

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

Implement VibeVoice #40546
pengzhiliang wants to merge 238 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

CI recap

Dashboard: View test results in Grafana
Latest run: 28458306538:2
Result: failure | Jobs: 13 | Tests: 44,325 | Failures: 57 | Duration: 14h 22m

@ebezzam

ebezzam commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

run-slow: vibevoice

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/vibevoice"]
quantizations: []

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 36208e7a workflow commit (merge commit)
PR bbe259f6 branch commit (from PR)
main 181beb3b base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

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

Some initial comments from my side 🤗 mainly took a look at generation/modeling for now

Comment on lines +29 to +30
- [bezzam/VibeVoice-1.5B-hf](https://huggingface.co/bezzam/VibeVoice-1.5B-hf)
- [bezzam/VibeVoice-7B-hf](https://huggingface.co/bezzam/VibeVoice-7B-hf)

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.

Rebump before it gets lost, ig a community org or we have contact to transfer?

Comment thread docs/source/en/model_doc/vibevoice.md Outdated
Comment thread docs/source/en/model_doc/vibevoice.md Outdated
Comment thread docs/source/en/model_doc/vibevoice.md Outdated
Comment on lines +105 to +110
noise_scheduler = diffusers.DPMSolverMultistepScheduler(
beta_schedule="squaredcos_cap_v2",
prediction_type="v_prediction",
)
model.generation_config.noise_scheduler = noise_scheduler
audio = model.generate(**inputs)

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.

My main idea would be to add a custom dict like entry that we resolve for vibevoice only as custom entries are passed along and saved so we can make use of that and integrate it into our own generate pipeline in the end --> create the scheduler at runtime then

Comment thread docs/source/en/model_doc/vibevoice.md Outdated
Padding mask to remove padded parts of audio.
"""

with torch.no_grad():

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.

why?

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.

taken from original and because the acoustic tokenizer (audio tower) is only meant for inference within this architecture, even during training ("During VIBEVOICE training, the pre-trained acoustic and semantic tokenizers remained frozen, with only the LLM and diffusion head parameters being learnable", bottom of p.3 of paper).

is there better way to do this?

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.

Let's add a small comment but should be fine. Was just surprised

inputs_embeds: torch.FloatTensor | None = None,
input_values: torch.FloatTensor | None = None,
padding_mask: torch.BoolTensor | None = None,
**kwargs,

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.

typing of kwargs

Comment on lines +402 to +403
num_diffusion_steps (`int`, *optional*, defaults to config.num_diffusion_steps):
For training, the number of diffusion steps to use.

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.

hmm ok here it is, let's avoid the double trouble and only have it as config value?

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.

how about only as a forward parameter? like ddpm_batch_multiplier and noise_scheduler so all training-related parameters are passed this way

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.

Yep glad with either version just dont want both 😬

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.

makes sense!

Comment thread src/transformers/models/vibevoice/modular_vibevoice.py
Comment thread src/transformers/pipelines/text_to_audio.py
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 3, 2026

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

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 3, 2026

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

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

github-actions Bot commented Jul 3, 2026

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

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

github-actions Bot commented Jul 3, 2026

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

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 3, 2026

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

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

run-slow: auto, csm, vibevoice, vibevoice_acoustic_tokenizer

@github-actions

github-actions Bot commented Jul 3, 2026

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 requested a review from vasqu July 3, 2026 16:42

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

Some more comments in the meantime, did not go full deep dive but still a few details here and there

print(f"Saved output to {fn}")
```

### Batched inference

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.

Yup much better imo!

Comment on lines +423 to +426
# Compute losses
lm_loss = outputs.loss
diffusion_loss = outputs.diffusion_loss
total_loss = lm_loss + diffusion_loss

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.

this is weird why are we outputting both separately and not directly the final one? Otherwise the trainer will also not work OOB

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.

I think it's better to output separately, because some training schemes may weight them differently as training progresses.

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.

I'll put a comment that this is a sum just for demo purposes

_ = model(**inputs)
torch.cuda.synchronize()
print(f"Warmup complete in {time.time() - warmup_start:.2f}s.")
# Warmup complete in 46.39s

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.

feels like we should add a final forward after the warmup?

Comment on lines +86 to +87
device = kwargs.get("device")
processors.append(VibeVoiceTokenConstraintProcessor(valid_tokens, device=device))

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.

Hmm self.device maybe? Or is this the better way, havent seen this in kwargs tbh

Comment on lines +87 to +100
if noise_scheduler is None:
raise ValueError(
"VibeVoice generation requires a `noise_scheduler` to be provided, e.g., "
"`diffusers.DPMSolverMultistepScheduler(beta_schedule='squaredcos_cap_v2', prediction_type='v_prediction')`."
)
if not (
hasattr(noise_scheduler, "set_timesteps")
and hasattr(noise_scheduler, "step")
and hasattr(noise_scheduler, "timesteps")
):
raise ValueError(
f"The provided noise_scheduler ({type(noise_scheduler).__name__}) is not compatible with VibeVoice "
"generation. It must implement `set_timesteps` and `step` methods, and have a `timesteps` attribute."
)

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.

Yup, it looked very awkward in the docs tbh

Comment on lines +78 to +86
base_model_tp_plan = {
"language_model.layers.*.self_attn.q_proj": "colwise",
"language_model.layers.*.self_attn.k_proj": "colwise",
"language_model.layers.*.self_attn.v_proj": "colwise",
"language_model.layers.*.self_attn.o_proj": "rowwise",
"language_model.layers.*.mlp.gate_proj": "colwise",
"language_model.layers.*.mlp.up_proj": "colwise",
"language_model.layers.*.mlp.down_proj": "rowwise",
}

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.

Hmm does it not automatically be applied on submodels with the correct config? Can you double check?

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.

yep can do without


# NOTE (ebezzam) for modular usage of `LlamaMLP`
@property
def hidden_size(self) -> int:

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.

should we have a setter?

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.

or actually can avoid this altogether by doing

class VibeVoiceMLP(LlamaMLP):
    def __init__(self, config):
        super().__init__(config)
        self.hidden_size = config.text_config.hidden_size

Comment on lines +96 to +102
num_head_layers: int = 4
intermediate_size: int = 4608
rms_norm_eps: float = 1e-5
hidden_act: str = "silu"
frequency_embedding_size: int = 256
diffusion_max_period: int = 10000
mlp_bias: bool = False

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.

Might be a big nit but maybe also a subconfig?


@auto_docstring
class VibeVoicePreTrainedModel(VoxtralPreTrainedModel):
_supports_cache_class = False

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.

Hmm so we have no cache or more like we have a super custom cache?

Comment thread src/transformers/models/vibevoice/modular_vibevoice.py
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.