-
Notifications
You must be signed in to change notification settings - Fork 169
Implement integration tests in CI pipeline #639
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| def pytest_addoption(parser): | ||
| """Adds custom command-line options to pytest.""" | ||
| parser.addoption("--tensor-parallel-size", | ||
| type=int, | ||
| default=1, | ||
| help="The tensor parallel size to use for the test.") | ||
| parser.addoption( | ||
| "--expected-value", | ||
| type=float, | ||
| default=None, | ||
| help= | ||
| "This value will be used to compare the measure value and determine if the test passes or fails." | ||
| ) | ||
| parser.addoption("--model-name", | ||
| type=str, | ||
| default=None, | ||
| help="Model name to test (e.g., 'model1')") | ||
| parser.addoption("--fp8-kv-model-name", | ||
| type=str, | ||
| default=None, | ||
| help="Model name to test fp8-kv (e.g., 'model1')") |
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,114 @@ | ||
| # Copied from vLLM: https://github.com/vllm-project/vllm/blob/839ab00/tests/entrypoints/llm/test_accuracy.py | ||
|
|
||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| """ | ||
| This file test accuracy of the vLLM server via LMEval. | ||
| It uses local-completions, which interacts with vLLM | ||
| through the OAI API with N concurrent connections. | ||
| This simulates real work usage of the API and makes | ||
| sure that the zmq frontend mp RPC message passing and | ||
| AsyncLLMEngine are working correctly. | ||
| """ | ||
|
|
||
| import threading | ||
|
|
||
| import lm_eval | ||
| import pytest | ||
| from vllm.platforms import current_platform | ||
|
|
||
| MODEL_NAMES = [] | ||
| FP8_KV_MODEL_NAMES = [] | ||
| NUM_CONCURRENT = 500 | ||
| TASK = "gsm8k" | ||
| FILTER = "exact_match,strict-match" | ||
| RTOL = 0.03 | ||
| _JSON_WRITE_LOCK = threading.Lock() | ||
|
|
||
|
|
||
| def run_test(model_name, expected_value, more_args=None): | ||
| """Run the end to end accuracy test.""" | ||
| print(f"Running test for model: {model_name}") | ||
|
|
||
| model_args = f"pretrained={model_name},max_model_len=4096" | ||
| if more_args is not None: | ||
| model_args = "{},{}".format(model_args, more_args) | ||
|
|
||
| results = lm_eval.simple_evaluate( | ||
| model="vllm", | ||
| model_args=model_args, | ||
| tasks="gsm8k", | ||
| batch_size="auto", | ||
| ) | ||
|
|
||
| measured_value = results["results"][TASK][FILTER] | ||
| assert (measured_value - RTOL < expected_value < measured_value + | ||
| RTOL), f"Expected: {expected_value} | Measured: {measured_value}" | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not current_platform.is_cuda() | ||
| and not current_platform.is_tpu(), | ||
| reason="V1 is currently only supported on CUDA and TPU") | ||
| def test_lm_eval_accuracy_v1_engine(monkeypatch: pytest.MonkeyPatch, | ||
| request: pytest.FixtureRequest): | ||
| """Run with the V1 Engine.""" | ||
| model = request.config.getoption("--model-name") | ||
| print(f"Testing model: {model}...") | ||
|
|
||
| tp_size = request.config.getoption("--tensor-parallel-size") | ||
| expected_value = request.config.getoption("--expected-value") | ||
|
|
||
| if expected_value is None: | ||
| raise ValueError | ||
|
|
||
| if tp_size is None: | ||
| tp_size = 1 | ||
| elif tp_size < 1 or tp_size > 8: | ||
| raise ValueError | ||
|
|
||
| with monkeypatch.context() as m: | ||
| m.setenv("VLLM_USE_V1", "1") | ||
|
|
||
| more_args = None | ||
| if current_platform.is_tpu(): | ||
| more_args = "max_model_len=2048,max_num_seqs=64" | ||
| tp_size_str = f"tensor_parallel_size={tp_size}" | ||
| more_args += ",{}".format(tp_size_str) | ||
|
|
||
| print(f"common args: {more_args}") | ||
|
|
||
| run_test(model, expected_value, more_args) | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not current_platform.is_cuda() | ||
| and not current_platform.is_tpu(), | ||
| reason="V1 is currently only supported on CUDA and TPU") | ||
| def test_lm_eval_accuracy_v1_engine_fp8_kv_cache( | ||
| monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureRequest): | ||
| """Run with the V1 Engine.""" | ||
| fp8_kv_model = request.config.getoption("--fp8-kv-model-name") | ||
| print(f"Testing fp8_kv_model: {fp8_kv_model}...") | ||
|
|
||
| tp_size = request.config.getoption("--tensor-parallel-size") | ||
| expected_value = request.config.getoption("--expected-value") | ||
|
|
||
| if expected_value is None: | ||
| raise ValueError | ||
|
|
||
| if tp_size is None: | ||
| tp_size = 1 | ||
| elif tp_size < 1 or tp_size > 8: | ||
| raise ValueError | ||
|
|
||
| with monkeypatch.context() as m: | ||
| m.setenv("VLLM_USE_V1", "1") | ||
|
|
||
| more_args = None | ||
| if current_platform.is_tpu(): | ||
| more_args = "max_model_len=2048,max_num_seqs=128,kv_cache_dtype=fp8" | ||
| tp_size_str = f"tensor_parallel_size={tp_size}" | ||
| more_args += ",{}".format(tp_size_str) | ||
|
|
||
| print(f"common args: {more_args}") | ||
|
|
||
| run_test(fp8_kv_model, expected_value, more_args) |
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 |
|---|---|---|
| @@ -1,4 +1,91 @@ | ||
| #!/bin/sh | ||
| #!/bin/bash | ||
|
|
||
| # TODO : to be added by https://github.com/vllm-project/tpu_commons/pull/639 | ||
| echo "[placeholder] accuracy test passed" | ||
| test_model="" | ||
| tensor_parallel_size=1 | ||
| minimum_accuracy_threshold=0 | ||
|
|
||
| extra_serve_args=() | ||
| echo extra_serve_args: "${extra_serve_args[@]}" | ||
|
|
||
| root_dir=/workspace | ||
| exit_code=0 | ||
|
|
||
| helpFunction() | ||
| { | ||
| echo "" | ||
| echo "Usage: $0 [-r full_path_to_root_dir -m model_id]" | ||
| echo -e "\t-r The path your root directory containing both 'vllm' and 'tpu_commons' (default: /workspace/, which is used in the Dockerfile)" | ||
| exit 1 | ||
| } | ||
|
|
||
| while [[ "$#" -gt 0 ]]; do | ||
| case "$1" in | ||
| -r|--root-dir-path) | ||
| root_dir="$2" | ||
| shift | ||
| shift | ||
| ;; | ||
| -h|--help) | ||
| helpFunction | ||
| ;; | ||
| *) # unknown option | ||
| echo "Unknown option: $1" | ||
| helpFunction | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ -n "$TEST_MODEL" ]; then | ||
| test_model="$TEST_MODEL" | ||
| fi | ||
|
|
||
| if [ -n "$MINIMUM_ACCURACY_THRESHOLD" ]; then | ||
| minimum_accuracy_threshold="$MINIMUM_ACCURACY_THRESHOLD" | ||
| fi | ||
|
|
||
| if [ -n "$TENSOR_PARALLEL_SIZE" ]; then | ||
| tensor_parallel_size="$TENSOR_PARALLEL_SIZE" | ||
| fi | ||
|
|
||
| # Check if test_model is provided and not empty | ||
| if [[ -z "$test_model" ]]; then | ||
| echo "Error: Test model name (-m) is a required argument." >&2 | ||
| has_error=1 | ||
| fi | ||
|
|
||
| # Check if tensor_parallel_size is an integer and greater than 0 | ||
| if ! [[ "$tensor_parallel_size" =~ ^[1-9][0-9]*$ ]]; then | ||
| echo "Error: Tensor parallel size (-t) must be an integer greater than 0. Got: '$tensor_parallel_size'" >&2 | ||
| has_error=1 | ||
| fi | ||
|
|
||
| # Check if minimum_accuracy_threshold is a float and greater than 0 | ||
| if ! awk -v num="$minimum_accuracy_threshold" 'BEGIN { exit !(num > 0) }'; then | ||
| echo "Error: Minimum accuracy threshold (-e) must be a number greater than 0. Got: '$minimum_accuracy_threshold'" >&2 | ||
| has_error=1 | ||
| fi | ||
|
|
||
| # If any validation failed, print help and exit | ||
| if [[ "$has_error" -ne 0 ]]; then | ||
| helpFunction | ||
| fi | ||
|
|
||
|
|
||
| echo "Using the root directory at $root_dir" | ||
|
|
||
| cd "$root_dir"/vllm/tests/entrypoints/llm || exit | ||
|
|
||
| # Overwrite a few of the vLLM benchmarking scripts with the TPU Commons ones | ||
| cp "$root_dir"/tpu_commons/scripts/vllm/integration/*.py "$root_dir"/vllm/tests/entrypoints/llm/ | ||
|
|
||
| echo "--------------------------------------------------" | ||
| echo "Running integration for model: $test_model" | ||
| echo "--------------------------------------------------" | ||
|
|
||
| # Default action | ||
| python -m pytest -rP test_accuracy.py::test_lm_eval_accuracy_v1_engine \ | ||
| --tensor-parallel-size="$tensor_parallel_size" \ | ||
| --model-name="$test_model" \ | ||
| --expected-value="$minimum_accuracy_threshold" | ||
|
|
||
| exit $exit_code | ||
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.