-
Notifications
You must be signed in to change notification settings - Fork 241
add peft to recipe qwen3vl #2023
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9432fc2
add peft to recipe qwen3vl
yashaswikarnati af84274
fix: add loss_mask parameter to Qwen3VLModel and add CI test
yashaswikarnati 55c5569
fix: sort imports alphabetically in qwen_vl __init__.py
yashaswikarnati 106080b
fix: add --peft argparse flag to avoid config clobbering
yashaswikarnati 69935a6
fix: rename default_peft_config import to private to avoid test disco…
yashaswikarnati 6700f60
Merge branch 'main' into test_qwen3vl_peft
cuichenx 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
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
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
77 changes: 77 additions & 0 deletions
77
tests/functional_tests/recipes/test_qwen3_vl_recipes_finetune.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,77 @@ | ||
| # 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. | ||
|
|
||
| """Functional smoke tests for Qwen3-VL finetuning recipes. | ||
|
|
||
| This test ensures that: | ||
| 1. Qwen3-VL model forward pass works with all required parameters (including loss_mask) | ||
| 2. Training loop completes without errors | ||
| 3. Checkpoints are saved correctly | ||
|
|
||
| This catches regressions like missing parameters in the forward pass signature. | ||
|
|
||
| Run with: | ||
| torchrun --nproc_per_node=2 -m pytest tests/functional_tests/recipes/test_qwen3_vl_recipes_peft.py -v | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from megatron.bridge.recipes.qwen_vl.qwen3_vl import qwen3_vl_8b_finetune_config | ||
| from tests.functional_tests.recipes.utils import run_pretrain_vl_recipe_test | ||
|
|
||
|
|
||
| QWEN3_VL_FINETUNE_RECIPES = [ | ||
| # (config_func, recipe_name, parallelism_overrides, model_overrides) | ||
| # Qwen3-VL 8B finetune - uses TP=2 for 2-GPU CI | ||
| # Note: deepstack_visual_indexes must have len <= num_layers | ||
| ( | ||
| qwen3_vl_8b_finetune_config, | ||
| "qwen3_vl_8b_finetune", | ||
| {"tensor_model_parallel_size": 2, "pipeline_model_parallel_size": 1}, | ||
| {"num_layers": 4, "deepstack_visual_indexes": [0, 1, 2]}, | ||
| ), | ||
| ] | ||
|
|
||
|
|
||
| class TestQwen3VLFinetuneRecipes: | ||
| """Test class for Qwen3-VL finetune recipe functional tests.""" | ||
|
|
||
| @pytest.mark.run_only_on("GPU") | ||
| @pytest.mark.parametrize( | ||
| "config_func,recipe_name,parallelism_overrides,model_overrides", | ||
| QWEN3_VL_FINETUNE_RECIPES, | ||
| ) | ||
| def test_qwen3_vl_finetune_recipes( | ||
| self, | ||
| config_func, | ||
| recipe_name, | ||
| parallelism_overrides, | ||
| model_overrides, | ||
| tmp_path, | ||
| ): | ||
| """Functional test for Qwen3-VL finetune recipes. | ||
|
|
||
| This test runs a minimal training session to verify that: | ||
| 1. The config loads correctly | ||
| 2. Model forward pass accepts all required parameters (loss_mask, etc.) | ||
| 3. Training completes without errors | ||
| 4. Checkpoints are created | ||
| """ | ||
| run_pretrain_vl_recipe_test( | ||
| config_func, | ||
| recipe_name, | ||
| tmp_path, | ||
| model_overrides=model_overrides, | ||
| **parallelism_overrides, | ||
| ) |
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.
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.
Add implementation details for PEFT setup.
This section has motivation and examples, but it doesn’t yet explain how PEFT is wired in the recipe (configuration keys, defaults, and override behavior). The docs requirement for new key features explicitly calls for implementation details.
📌 Suggested doc addition
As per coding guidelines: All new key features (enabling a new model, enabling a new parallelism strategy) must include documentation update explaining motivation, technical approach, usage examples, and implementation details.
📝 Committable suggestion
🤖 Prompt for AI Agents