Repository navigation
[model] Add initial Qwen3-Omni support in Megatron-Bridge #2831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bd917ea
[model,docs,test] feat: add qwen3 omni stage1 scaffolding
hbhflw2000 f92d8cc
[model,test] feat: add qwen3 omni vision runtime
hbhflw2000 866b5d5
[model,test] feat: add qwen3 omni audio runtime
hbhflw2000 2b2ef81
[model,test] fix: add qwen3 omni functional smoke coverage
hbhflw2000 2ba2be9
[docs,test] fix: align qwen3 omni docs and test paths
hbhflw2000 a8d7ed9
[model,test,docs] fix: address qwen3 omni review feedback
hbhflw2000 7ae0f55
[docs] chore: improve qwen3 omni docstring coverage
hbhflw2000 3f9d7f7
[examples,model,test] feat: add qwen3 omni repro scripts
hbhflw2000 4f03b90
[model,docs,test] fix: refine qwen3 omni rope and doc review items
hbhflw2000 382d144
[examples,docs] fix: remove local qwen3 omni path defaults
hbhflw2000 1240ba7
[test,ci] feat: add qwen3 omni toy functional coverage
hbhflw2000 0c1ff02
[test,ci] fix: rename qwen3 omni launcher to l0
hbhflw2000 6468712
[test,ci] fix: resolve qwen3 omni workflow conflict
hbhflw2000 31e2295
[model,test] fix: forward-port qwen3 omni onto upstream qwen layout
hbhflw2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ glm-45v.md | |
| ministral3.md | ||
| nemotron-nano-v2-vl.md | ||
| qwen2.5-vl.md | ||
| qwen3-omni.md | ||
| qwen3-vl.md | ||
| qwen35-vl.md | ||
| ``` | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Qwen3-Omni | ||
|
|
||
| Qwen3-Omni is a multimodal Qwen family model with text, image, video, and audio inputs. Megatron Bridge support for Qwen3-Omni reuses the existing Qwen3-VL language and vision path, and adds Qwen3-Omni-specific audio handling and checkpoint mappings. | ||
|
|
||
| The current implementation is focused on checkpoint conversion and training-oriented multimodal forward paths. It supports single-rank functional validation for text, vision, and audio inputs, and keeps distributed parallel validation as a follow-up step. | ||
|
|
||
| ## Current Support | ||
|
|
||
| - Hugging Face to Megatron Bridge checkpoint conversion for `Qwen/Qwen3-Omni-30B-A3B-Instruct` | ||
| - Megatron Bridge to Hugging Face export for the same model family | ||
| - Text, image, video, and audio multimodal forward paths | ||
| - Qwen3-Omni-specific multimodal RoPE handling for Megatron Bridge runtime | ||
| - Single-GPU smoke validation with a vertically trimmed checkpoint | ||
|
|
||
| ## Implementation Notes | ||
|
|
||
| - The language backbone uses Megatron-Core modules through the existing Qwen3-VL GPT path. | ||
| - The vision and audio towers currently reuse Hugging Face Qwen3-Omni components. | ||
| - Multimodal embeddings are fused before the language decoder. | ||
| - The current validation path focuses on correctness and checkpoint interoperability rather than distributed performance tuning. | ||
|
|
||
| ## Validation | ||
|
hbhflw2000 marked this conversation as resolved.
Resolved
|
||
|
|
||
| The current test coverage includes: | ||
|
|
||
| - Provider unit tests | ||
| - Bridge unit tests | ||
| - Model unit tests for text, vision, and audio paths | ||
| - Functional checkpoint conversion tests | ||
| - End-to-end smoke tests using user-provided multimodal assets | ||
|
|
||
| ## Hugging Face Model Cards | ||
|
|
||
| - Qwen3-Omni-30B-A3B-Instruct: `https://huggingface.co/Qwen/Qwen3-Omni-30B-A3B-Instruct` | ||
|
|
||
| ## Related Docs | ||
|
|
||
| - Related VLM: [Qwen3-VL](qwen3-vl.md) | ||
| - Related VLM: [Qwen 3.5](qwen35-vl.md) | ||
| - Recipe usage: [Recipe usage](../../recipe-usage.md) | ||
| - Customizing the training recipe configuration: [Configuration overview](../../training/config-container-overview.md) | ||
| - Training entry points: [Entry points](../../training/entry-points.md) | ||
|
hbhflw2000 marked this conversation as resolved.
Resolved
|
||
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
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
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
24 changes: 24 additions & 0 deletions
24
src/megatron/bridge/models/qwen_omni/modeling_qwen3_omni/__init__.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from megatron.bridge.models.qwen_omni.modeling_qwen3_omni.model import Qwen3OmniModel | ||
| from megatron.bridge.models.qwen_omni.modeling_qwen3_omni.transformer_config import ( | ||
| Qwen3OmniTransformerConfig, | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "Qwen3OmniModel", | ||
| "Qwen3OmniTransformerConfig", | ||
| ] |
107 changes: 107 additions & 0 deletions
107
src/megatron/bridge/models/qwen_omni/modeling_qwen3_omni/model.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import torch | ||
| from megatron.core import InferenceParams | ||
| from megatron.core.packed_seq_params import PackedSeqParams | ||
| from megatron.core.process_groups_config import ProcessGroupCollection | ||
| from megatron.core.transformer import MegatronModule | ||
| from megatron.core.transformer.spec_utils import ModuleSpec | ||
| from transformers.models.qwen3_omni_moe.configuration_qwen3_omni_moe import ( | ||
| Qwen3OmniMoeCode2WavConfig, | ||
| Qwen3OmniMoeTalkerConfig, | ||
| Qwen3OmniMoeThinkerConfig, | ||
| ) | ||
|
|
||
| from megatron.bridge.models.qwen_omni.modeling_qwen3_omni.thinker_model import Qwen3OmniThinkerModel | ||
| from megatron.bridge.models.qwen_omni.modeling_qwen3_omni.transformer_config import ( | ||
| Qwen3OmniTransformerConfig, | ||
| ) | ||
|
|
||
|
|
||
| class Qwen3OmniModel(MegatronModule): | ||
| """Qwen3-Omni model wrapper.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| language_transformer_config: Qwen3OmniTransformerConfig, | ||
| language_transformer_layer_spec: ModuleSpec, | ||
| thinker_transformer_config: Qwen3OmniMoeThinkerConfig, | ||
| talker_transformer_config: Qwen3OmniMoeTalkerConfig | None = None, | ||
| code2wav_transformer_config: Qwen3OmniMoeCode2WavConfig | None = None, | ||
| parallel_output: bool = True, | ||
| pre_process: bool = True, | ||
| post_process: bool = True, | ||
| add_encoder: bool = True, | ||
| add_decoder: bool = True, | ||
| pg_collection: ProcessGroupCollection | None = None, | ||
| ) -> None: | ||
| super().__init__(config=language_transformer_config) | ||
|
|
||
| self.thinker = Qwen3OmniThinkerModel( | ||
| language_transformer_config, | ||
| language_transformer_layer_spec, | ||
| thinker_transformer_config, | ||
| parallel_output, | ||
| pre_process, | ||
| post_process, | ||
| add_encoder, | ||
| add_decoder, | ||
| pg_collection, | ||
| ) | ||
|
|
||
| self.talker_transformer_config = talker_transformer_config | ||
| self.code2wav_transformer_config = code2wav_transformer_config | ||
|
|
||
| def shared_embedding_or_output_weight(self): | ||
| return self.thinker.shared_embedding_or_output_weight() | ||
|
|
||
| def set_input_tensor(self, input_tensor) -> None: | ||
| return self.thinker.set_input_tensor(input_tensor) | ||
|
|
||
| def freeze( | ||
| self, | ||
| freeze_language_model: bool = False, | ||
| freeze_vision_model: bool = False, | ||
| freeze_audio_model: bool = False, | ||
| ): | ||
| return self.thinker.freeze( | ||
| freeze_language_model=freeze_language_model, | ||
| freeze_vision_model=freeze_vision_model, | ||
| freeze_audio_model=freeze_audio_model, | ||
| ) | ||
|
|
||
| def forward( | ||
| self, | ||
| input_ids: torch.Tensor, | ||
| position_ids: torch.Tensor | None = None, | ||
| attention_mask: torch.Tensor | None = None, | ||
| labels: torch.Tensor | None = None, | ||
| loss_mask: torch.Tensor | None = None, | ||
| inference_params: InferenceParams | None = None, | ||
| packed_seq_params: PackedSeqParams | None = None, | ||
| extra_block_kwargs: dict | None = None, | ||
| **kwargs, | ||
| ) -> torch.Tensor: | ||
| return self.thinker( | ||
| input_ids=input_ids, | ||
| position_ids=position_ids, | ||
| attention_mask=attention_mask, | ||
| labels=labels, | ||
| loss_mask=loss_mask, | ||
| inference_params=inference_params, | ||
| packed_seq_params=packed_seq_params, | ||
| extra_block_kwargs=extra_block_kwargs, | ||
| **kwargs, | ||
| ) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.