Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Qwen3 ASR and Forced Aligner#43838

Merged
ebezzam merged 165 commits into
huggingface:mainfrom
mbtariq82:qwen3-asr
Jun 26, 2026
Merged

Qwen3 ASR and Forced Aligner#43838
ebezzam merged 165 commits into
huggingface:mainfrom
mbtariq82:qwen3-asr

Conversation

@mbtariq82

@mbtariq82 mbtariq82 commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR adds Qwen3-ASR to the Transformers library.

Fixes #43837

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@mbtariq82 mbtariq82 mentioned this pull request Feb 8, 2026
2 tasks
@vasqu

vasqu commented Feb 9, 2026

Copy link
Copy Markdown
Collaborator

I think this is a good one to add! cc @ebezzam @eustlb

@vasqu vasqu added the Audio label Feb 9, 2026
@ebezzam

ebezzam commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

@mbtariq82 thanks for opening the PR! we're definitely interested to add the model and were planning to work on it. Could you go ahead with the rest of the model? And I can iterate with you on it.

I see you started with a modular file which is great. Below are some pointers of recent audio LM models that may help you with the other files / get an idea of our conventions:

thanks 🤗

@mbtariq82

Copy link
Copy Markdown
Contributor Author

I'm struggling to get test_apply_chat_template_audio from test_processing_common.py to pass.

Specifically, the final part of the test where we apply_chat_template with continue_final_message=True fails with ValueError(continue_final_message is set but the final message does not appear in the chat after applying the chat template!...)

I've verified that the chat_template is being correctly loaded from the model checkpoint: Qwen/Qwen3-ASR-0.6B.

According to ChatGPT, the chat_template provided by Qwen is not correctly rendering the final assistant message so I think the only way to solve this is to override the apply_chat_template method and add some custom logic before calling super().apply_chat_template?

@ebezzam

@ebezzam

ebezzam commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

@mbtariq82 it's only about getting the test to pass but the model is behaving as expected, let's avoid overwriting apply_chat_template.

For now you can leave the test failing, and if necessary we can overwrite or even skip the test later on

@ebezzam

ebezzam commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

when you finish the modeling, and integration tests that produce equivalent outputs to the original, e.g. for audio flamingo:

I can already take a look to give some feedback! and we can take a look at the test after that

Create integration test

Setup Qwen3ASRModelTester
@mbtariq82

mbtariq82 commented Feb 15, 2026

Copy link
Copy Markdown
Contributor Author

So between the current version and v4.57.6, the "default" key was removed from ROPE_INIT_FUNCTIONS. Qwen3-ASR was built using v4.57.6 and the checkpoint uses the "default" key. I've changed the rope_type to "linear" in Qwen3ASRThinkerTextRotaryEmbedding for now but I'm not sure if this is correct.

I also changed the "attentions" PyTorch hooks, it was set to Qwen3ASRThinkerTextAttention which is not used at all in the base class - maybe they plan to use it in the future but I'm not sure. I've changed it to Qwen3ASRTextAttention to get the tests to pass.

I've added the entire model. All the tests are passing.

@mbtariq82 mbtariq82 changed the title Proposal to add Qwen3-ASR support Proposal to add Qwen3-ASR support [WIP] Feb 15, 2026
Add property methods to config

Add base_model_prefix and wrapper method to generation class
…n to Qwen3ASRTextAttention, Qwen3ASRThinkerTextAttention is never instantiated and so 'attentions' was not being properly propogated

Fix integration tests

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

Hi @mbtariq82 thanks for working on this integration! I'm doing a small review because I noticed you started a modular file, but aren't making full use of its functionality to generate the configuration, processing, and modeling from existing components in Transformers. I gave some pointers for the configuration and processing but will let you check out the rest for the modeling components.

I encourage reading this page on using modular to contribute models: https://huggingface.co/docs/transformers/en/modular_transformers

And for practical examples you can see other modular files:

Note: I think you will have to use "Asr" instead of "ASR" in your model naming because the modular script prefers camelcase.

Comment thread src/transformers/models/qwen3_asr/modular_qwen3_asr.py Outdated
Comment thread src/transformers/models/qwen3_asr/modular_qwen3_asr.py Outdated
Comment thread src/transformers/models/qwen3_asr/modular_qwen3_asr.py Outdated
Comment thread src/transformers/models/qwen3_asr/modular_qwen3_asr.py Outdated
Comment thread src/transformers/models/qwen3_asr/modular_qwen3_asr.py Outdated
Comment thread src/transformers/models/qwen3_asr/modular_qwen3_asr.py Outdated
…gn RoPE position handling with cache_position

 Refactor position_ids construction to be fully cache_position-driven and generation-safe.
 - Compute batch_size/seq_length from inputs_embeds
 - Initialize cache_position when absent
 - Build 3D position_ids from cache_position
 - Compute rope_deltas once during prefill
 - Reuse rope_deltas for subsequent decode steps
 Removes legacy attention_mask-dependent branch that was incompatible with static cache generation.
 Ensures correct RoPE offsets for multimodal inputs under both dynamic and static cache modes.
@mbtariq82

Copy link
Copy Markdown
Contributor Author

I made some big changes in the base model's forward in this commit: 0b3248d. I also removed get_rope_index.

Comment thread tests/models/qwen3_asr/test_modeling_qwen3_asr.py Outdated
Comment thread src/transformers/models/qwen3_asr/modular_qwen3_asr.py Outdated
@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: audioflamingo3, auto, dac, glmasr, qwen2_5_omni, qwen3_asr, qwen3_omni_moe, vibevoice_asr

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: audioflamingo3, auto, dac, glmasr, qwen2_5_omni, qwen3_asr, qwen3_omni_moe, vibevoice_asr

@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: audioflamingo3, auto, dac, glmasr, qwen2_5_omni, qwen3_asr, qwen3_omni_moe, vibevoice_asr

@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: audioflamingo3, auto, dac, glmasr, qwen2_5_omni, qwen3_asr, qwen3_omni_moe, vibevoice_asr

@ebezzam

ebezzam commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

run-slow: qwen3_asr

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

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

models: ["models/qwen3_asr"]
quantizations: []

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 06823aea workflow commit (merge commit)
PR c3600407 branch commit (from PR)
main ed7d6c8d base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: audioflamingo3, auto, dac, glmasr, qwen2_5_omni, qwen3_asr, qwen3_omni_moe, vibevoice_asr

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: audioflamingo3, auto, dac, glmasr, qwen2_5_omni, qwen3_asr, qwen3_omni_moe, vibevoice_asr

@ebezzam

ebezzam commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

run-slow: qwen3_asr

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

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

models: ["models/qwen3_asr"]
quantizations: []

@ebezzam ebezzam added this pull request to the merge queue Jun 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 26, 2026
@ebezzam ebezzam added this pull request to the merge queue Jun 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 0c4e90e5 workflow commit (merge commit)
PR 3c1e29ba branch commit (from PR)
main 252b7b18 base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: audioflamingo3, auto, dac, glmasr, qwen2_5_omni, qwen3_asr, qwen3_omni_moe, vibevoice_asr

@ebezzam ebezzam enabled auto-merge June 26, 2026 16:07
@ebezzam ebezzam added this pull request to the merge queue Jun 26, 2026
Merged via the queue into huggingface:main with commit 9672039 Jun 26, 2026
103 checks passed
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.

Proposal to add Qwen3-ASR support