-
Notifications
You must be signed in to change notification settings - Fork 433
Add preprocessing utils for Qwen3-Omni #2613
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -580,6 +580,8 @@ def _apply_embedding( | |
| image_masks=image_masks, | ||
| ) | ||
| # TODO(hengtaoguo): Add support for other multimodal models such as Llama4, refactor if needed | ||
| elif cfg.model_name in ["qwen3-omni-30b-a3b"]: | ||
|
||
| pass | ||
| else: | ||
| raise ValueError(f"Unsupported model_name for multimodal: {cfg.model_name}") | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright 2023–2025 Google LLC | ||
| # | ||
| # 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 | ||
| # | ||
| # https://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. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,47 @@ | ||||||||||||||||||||||||||||||||||||
| # Copyright 2023–2025 Google LLC | ||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||
| # 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 | ||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||
| # https://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. | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| """Multimodal data preprocessor router.""" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| from MaxText import multimodal_utils # TODO(hengtaoguo): deprecate this file and refactor to MaxText/multimodal/utils.py | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 The |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def preprocess_mm_data(config): | ||||||||||||||||||||||||||||||||||||
| """Preprocesses multimodal data based on the provided configuration. | ||||||||||||||||||||||||||||||||||||
| Routes to the appropriate preprocessing function based on the model name. | ||||||||||||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||||||||||||
| config: A `pyconfig.Config` object containing configuration parameters. | ||||||||||||||||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||||||||||||||
| A `PreprocessorOutput` object containing the processed multimodal data. | ||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||
| processor_outputs = multimodal_utils.PreprocessorOutput() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if config.model_name in ["gemma3-4b", "gemma3-12b", "gemma3-27b"]: | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| images = [multimodal_utils.load_image_from_path(p) for p in config.image_path.split(",")] | ||||||||||||||||||||||||||||||||||||
| processor_outputs = multimodal_utils.pre_process_gemma3_image(images) | ||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe rename the functions to maybe it would be better to use a factory pattern here |
||||||||||||||||||||||||||||||||||||
| elif config.model_name in ["llama4-17b-16e", "llama4-17b-128e"]: | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 The
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| images = [multimodal_utils.load_image_from_path(p) for p in config.image_path.split(",")] | ||||||||||||||||||||||||||||||||||||
| processor_outputs = multimodal_utils.pre_process_llama4_image(images) | ||||||||||||||||||||||||||||||||||||
| elif config.model_name in ["qwen3-omni-30b-a3b"]: | ||||||||||||||||||||||||||||||||||||
| from MaxText.multimodal.qwen3_omni_processor import preprocess_mm_data_qwen3_omni # pylint: disable=import-outside-toplevel | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| processor_outputs = preprocess_mm_data_qwen3_omni(config) | ||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does it accept a config? |
||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||
| raise ValueError(f"Model {config.model_name} not supported for multimodal preprocessing.") | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| return processor_outputs | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 This
passstatement indicates that multimodal embedding forqwen3-omni-30b-a3bis not yet implemented. While it unblocks the current integration, it's crucial to implement the actual embedding logic for this model to ensure full multimodal functionality. Consider creating a follow-up task to address this.