-
Notifications
You must be signed in to change notification settings - Fork 59
Add a SP e2e test. #1209
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
vanbasten23
wants to merge
9
commits into
main
Choose a base branch
from
xiowei/add_sp_e2e_test
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
Add a SP e2e test. #1209
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d77baf9
added a sp e2e test
vanbasten23 82ab9eb
i'm able to run the test as pytest -s -vv tests/e2e/test_sequence_par…
vanbasten23 8653c01
Added more test cases.
vanbasten23 f257cb7
Add sp e2e test to the CI.
vanbasten23 e9ba556
improve the err msg
vanbasten23 7afe8fe
fix up
vanbasten23 59899b0
try to make the test capture the log
vanbasten23 dab3ec6
still couldnt capture log. consider revert this and the last commit.
vanbasten23 decf212
change logger.info to logger.debug
vanbasten23 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| import logging | ||
| import os | ||
| import time | ||
| from dataclasses import asdict | ||
|
|
||
| import pytest | ||
| from vllm import LLM, EngineArgs, SamplingParams | ||
| from vllm.config import CompilationConfig | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def setup_new_model_design(): | ||
| os.environ['MODEL_IMPL_TYPE'] = 'vllm' | ||
| os.environ['SKIP_JAX_PRECOMPILE'] = '1' | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def test_prompts(): | ||
| """Simple test prompts for data parallelism testing.""" | ||
| return [ | ||
| # having a long prompt to trigger a edge case. | ||
| "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone, Nine for Mortal Men doomed to die, One for the Dark Lord on his dark throne In the Land of Mordor where the Shadows lie. One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them In the Land of Mordor where the Shadows lie.", | ||
| "Hello, my name is", | ||
| "The capital of France is", | ||
| "The colors of the rainbow are", | ||
| "The future of AI is", | ||
| "The president of the United States is", | ||
| "How many players are on a standard soccer team?", | ||
| "In Greek mythology, who is the god of the sea?", | ||
| "What is the capital of Australia?", | ||
| "What is the largest planet in our solar system?", | ||
| "Who developed the theory of general relativity?", | ||
| ] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sampling_params(): | ||
| """Standard sampling parameters for testing.""" | ||
| return SamplingParams( | ||
| temperature=0.0, | ||
| max_tokens=32, | ||
| ignore_eos=True, | ||
| logprobs=1, | ||
| ) | ||
|
|
||
|
|
||
| def _run_inference_with_config(model_name: str, | ||
| test_prompts: list, | ||
| sampling_params: SamplingParams, | ||
| tensor_parallel_size: int = 1, | ||
| additional_config: dict = {}, | ||
| kv_cache_dtype: str = "auto", | ||
| enable_prefix_caching: bool = False, | ||
| async_scheduling: bool = False) -> list: | ||
| """Helper function to run inference with specified configuration.""" | ||
|
|
||
| # Create LLM args using parser-based approach similar to offline_inference.py | ||
| compilation_config = CompilationConfig(pass_config={ | ||
| "enable_sequence_parallelism": True, | ||
| }, ) | ||
| engine_args = EngineArgs( | ||
| model=model_name, | ||
| max_model_len=128, | ||
| compilation_config=compilation_config, | ||
| tensor_parallel_size=tensor_parallel_size, | ||
| gpu_memory_utilization=0.98, | ||
| max_num_batched_tokens=128, | ||
| max_num_seqs=16, | ||
| enable_prefix_caching=enable_prefix_caching, | ||
| additional_config=additional_config, | ||
| kv_cache_dtype=kv_cache_dtype, | ||
| async_scheduling=async_scheduling, | ||
| ) | ||
|
|
||
| engine_args_dict = asdict(engine_args) | ||
| llm = LLM(**engine_args_dict) | ||
|
|
||
| try: | ||
| outputs = llm.generate(test_prompts, sampling_params) | ||
| return outputs | ||
| finally: | ||
| del llm | ||
| # Wait for TPUs to be released | ||
| time.sleep(5) | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def temporary_enable_log_propagate(): | ||
| import logging | ||
|
|
||
| logger = logging.getLogger("vllm") | ||
| logger.propagate = True | ||
| yield | ||
| logger.propagate = False | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def caplog_vllm(temporary_enable_log_propagate, caplog): | ||
| # To capture vllm log, we should enable propagate=True temporarily | ||
| # because caplog depends on logs propagated to the root logger. | ||
| yield caplog | ||
|
|
||
|
|
||
| def test_model_sequence_parallelism( | ||
| caplog_vllm: pytest.LogCaptureFixture, | ||
| test_prompts: list, | ||
| sampling_params: SamplingParams, | ||
| ): | ||
| # Use Llama 1B for this test | ||
| test_model = "Qwen/Qwen2.5-32B" | ||
| caplog_vllm.clear() | ||
|
|
||
| # Set the logging level for the test | ||
| with caplog_vllm.at_level( | ||
| logging.INFO, | ||
| logger="vllm.tpu_inference.layers.vllm.quantization.common"): | ||
|
|
||
| # Test with data parallelism enabled | ||
| outputs = _run_inference_with_config( | ||
| model_name=test_model, | ||
| test_prompts=test_prompts, | ||
| sampling_params=sampling_params, | ||
| tensor_parallel_size=8, | ||
| async_scheduling=True, | ||
| ) | ||
|
|
||
| # Verify we got outputs for all prompts | ||
| assert len(outputs) == len(test_prompts) | ||
|
|
||
| # Verify each output has generated text | ||
| for output in outputs: | ||
| assert len(output.outputs) > 0 | ||
| assert len(output.outputs[0].text.strip()) > 0 | ||
| print(f"Output: {output.outputs[0].text.strip()}") | ||
|
|
||
| # caplog.text contains all the captured log output | ||
| print(f'xw32 {caplog_vllm.records[0].getMessage()}') | ||
| print( | ||
| f"✓ Model sequence parallelism test passed with {len(outputs)} outputs" | ||
| ) | ||
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
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.