Repository navigation
[megatron][vlm] Allow sequence packing for VLMs incl. Qwen3.5-VL (CP=1) #2357
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
Open
xinyuangui2
wants to merge
10
commits into
NovaSky-AI:main
Choose a base branch
from
xinyuangui2:vlm-megatron-packing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a4c748b
[megatron][vlm] Allow remove_microbatch_padding for VLMs (CP=1)
xinyuangui2 a08b6b8
[megatron][vlm] Refuse sample packing only for Qwen3VLModel with Gate…
xinyuangui2 1321590
[megatron][vlm] Remove the Qwen3VLModel double-packing guard
xinyuangui2 dc535ae
[megatron][vlm] Add packed-vs-unpacked per-token logprob test for Qwe…
xinyuangui2 ba4ad23
[megatron][vlm] Fix packed-vs-unpacked test alignment; score answer t…
xinyuangui2 094a8ef
[megatron][vlm] Packing parity test: compare against each sample run …
xinyuangui2 a20c0a9
[megatron][vlm] Packing parity test: add PP=2 cases
xinyuangui2 10a1d77
[megatron][vlm] Gate VLM sample packing on models that pack themselves
xinyuangui2 8c835f3
[test] VLM packing parity: init Ray with the CI env per forward; shap…
xinyuangui2 b26cf01
[train] Note that VLM SFT stays unpacked; packing is enabled for RL
xinyuangui2 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
35 changes: 35 additions & 0 deletions
35
tests/backends/skyrl_train/distributed/test_model_owns_vlm_packing.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,35 @@ | ||
| """model_owns_vlm_packing: which VLMs may use sample packing on the Megatron backend.""" | ||
|
|
||
| import pytest | ||
| import torch.nn as nn | ||
|
|
||
| megatron_utils = pytest.importorskip("skyrl.backends.skyrl_train.distributed.megatron.megatron_utils") | ||
|
|
||
|
|
||
| class _OptIn(nn.Module): | ||
| model_owns_packing = True | ||
|
|
||
|
|
||
| def test_plain_model_does_not_own_packing(): | ||
| assert not megatron_utils.model_owns_vlm_packing([nn.Linear(2, 2)]) | ||
|
|
||
|
|
||
| def test_opt_in_attribute(): | ||
| assert megatron_utils.model_owns_vlm_packing([_OptIn()]) | ||
| assert megatron_utils.model_owns_vlm_packing(_OptIn()) | ||
|
|
||
|
|
||
| def test_every_chunk_must_own_packing(): | ||
| assert not megatron_utils.model_owns_vlm_packing([_OptIn(), nn.Linear(2, 2)]) | ||
|
|
||
|
|
||
| def test_no_chunks(): | ||
| assert not megatron_utils.model_owns_vlm_packing([]) | ||
|
|
||
|
|
||
| def test_qwen3_vl_model_class(): | ||
| model_mod = pytest.importorskip("megatron.bridge.models.qwen_vl.modelling_qwen3_vl.model") | ||
| # Skip construction: an uninitialized instance is enough for the isinstance check. | ||
| fake = model_mod.Qwen3VLModel.__new__(model_mod.Qwen3VLModel) | ||
| nn.Module.__init__(fake) | ||
| assert megatron_utils.model_owns_vlm_packing([fake]) |
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
Oops, something went wrong.
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.