-
Notifications
You must be signed in to change notification settings - Fork 836
[Feat] add GLM-Image SP support #1983
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
11 commits
Select commit
Hold shift + click to select a range
0556b51
[Feat]: add GLM-Image SP support
RuixiangMa 38ba652
upd
RuixiangMa 1b74b8f
upd
RuixiangMa 5d7d6e9
Merge branch 'main' into glmspkv
RuixiangMa 21d0714
add pytest marker
wtomin f0a0944
Merge remote-tracking branch 'origin/main' into glmspkv
RuixiangMa 56930fa
Merge remote-tracking branch 'origin/main' into glmspkv
RuixiangMa ac61234
upd
RuixiangMa 4b50851
upd
RuixiangMa c29fde6
Merge remote-tracking branch 'origin/main' into glmspkv
RuixiangMa faa4f3e
upd
RuixiangMa 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
Some comments aren't visible on the classic Files Changed page.
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 |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| """Tests for GLM-Image Sequence Parallelism support.""" | ||
|
|
||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
|
|
||
| from vllm_omni.diffusion.data import DiffusionParallelConfig | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function", autouse=True) | ||
| def setup_sp_groups(): | ||
| """Set up SP and TP groups for each test function.""" | ||
| with patch("vllm_omni.diffusion.distributed.parallel_state.get_sp_group") as mock_get_sp_group: | ||
| with patch("vllm.model_executor.layers.linear.get_tensor_model_parallel_world_size", return_value=1): | ||
| with patch("vllm.distributed.parallel_state.get_tp_group") as mock_get_tp_group: | ||
| mock_sp_group = MagicMock() | ||
| mock_sp_group.world_size = 4 | ||
| mock_get_sp_group.return_value = mock_sp_group | ||
|
|
||
| mock_tp_group = MagicMock() | ||
| mock_tp_group.world_size = 1 | ||
| mock_get_tp_group.return_value = mock_tp_group | ||
| yield | ||
|
|
||
|
|
||
| pytestmark = [pytest.mark.core_model, pytest.mark.cpu] | ||
|
|
||
|
|
||
| def test_glm_image_sp_plan_defined(): | ||
| """Test that _sp_plan is properly defined on GlmImageTransformer2DModel.""" | ||
| from vllm_omni.diffusion.models.glm_image.glm_image_transformer import ( | ||
| GlmImageTransformer2DModel, | ||
| ) | ||
|
|
||
| assert hasattr(GlmImageTransformer2DModel, "_sp_plan") | ||
| plan = GlmImageTransformer2DModel._sp_plan | ||
| assert plan is not None | ||
|
|
||
| # Verify plan structure | ||
| assert "prepare" in plan | ||
| assert "proj_out" in plan | ||
|
|
||
|
|
||
| def test_glm_image_sp_plan_valid(): | ||
| """Validate _sp_plan structure.""" | ||
| from vllm_omni.diffusion.distributed.sp_plan import validate_sp_plan | ||
| from vllm_omni.diffusion.models.glm_image.glm_image_transformer import ( | ||
| GlmImageTransformer2DModel, | ||
| ) | ||
|
|
||
| plan = GlmImageTransformer2DModel._sp_plan | ||
| validate_sp_plan(plan) | ||
|
|
||
|
|
||
| def test_glm_image_prepare_module_exists(): | ||
| """Test that GlmImagePrepare module exists.""" | ||
| from vllm_omni.diffusion.models.glm_image.glm_image_transformer import ( | ||
| GlmImagePrepare, | ||
| ) | ||
|
|
||
| assert GlmImagePrepare is not None | ||
|
|
||
|
|
||
| def test_glm_image_attention_accepts_parallel_config(): | ||
| """Test that GlmImageAttention accepts parallel_config parameter.""" | ||
| from vllm_omni.diffusion.models.glm_image.glm_image_transformer import ( | ||
| GlmImageAttention, | ||
| ) | ||
|
|
||
| parallel_config = DiffusionParallelConfig( | ||
| ulysses_degree=2, | ||
| ring_degree=2, | ||
| tensor_parallel_size=1, | ||
| sequence_parallel_size=4, | ||
| ) | ||
|
|
||
| attn = GlmImageAttention( | ||
| dim=2560, | ||
| num_heads=64, | ||
| head_dim=40, | ||
| parallel_config=parallel_config, | ||
| ) | ||
|
|
||
| assert attn.parallel_config is not None | ||
| assert attn.parallel_config.sequence_parallel_size == 4 | ||
|
|
||
|
|
||
| def test_glm_image_transformer_block_accepts_parallel_config(): | ||
| """Test that GlmImageTransformerBlock accepts parallel_config parameter.""" | ||
| from vllm_omni.diffusion.models.glm_image.glm_image_transformer import ( | ||
| GlmImageTransformerBlock, | ||
| ) | ||
|
|
||
| parallel_config = DiffusionParallelConfig( | ||
| ulysses_degree=2, | ||
| ring_degree=2, | ||
| tensor_parallel_size=1, | ||
| sequence_parallel_size=4, | ||
| ) | ||
|
|
||
| block = GlmImageTransformerBlock( | ||
| dim=2560, | ||
| num_attention_heads=64, | ||
| attention_head_dim=40, | ||
| time_embed_dim=512, | ||
| parallel_config=parallel_config, | ||
| ) | ||
|
|
||
| assert block.attn1.parallel_config is not None | ||
| assert block.attn1.parallel_config.sequence_parallel_size == 4 | ||
|
|
||
|
|
||
| def test_glm_image_has_sp_support(): | ||
| """Test that GLM-Image has SP support implemented.""" | ||
| from vllm_omni.diffusion.models.glm_image.glm_image_transformer import ( | ||
| GlmImageTransformer2DModel, | ||
| ) | ||
|
|
||
| # Check that the model has parallel_config support | ||
| assert hasattr(GlmImageTransformer2DModel, "__init__") | ||
|
|
||
| # Verify the model can be instantiated with SP config | ||
|
|
||
| # This test just verifies the structure exists | ||
| # Actual SP testing requires multi-GPU setup | ||
|
|
||
|
|
||
| @pytest.mark.cuda | ||
| @pytest.mark.sp | ||
| def test_glm_image_sp_inference(): | ||
| """Test SP inference (requires multi-GPU setup).""" | ||
| pytest.skip("Requires multi-GPU SP setup") | ||
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.
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.
please add mark, you can refer to: https://github.com/vllm-project/vllm-omni/blob/main/docs/contributing/ci/tests_markers.md