Skip to content
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

Request cancellation test #19

Merged
merged 12 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions ci/L0_backend_vllm/request_cancel/request_cancel_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
pskiran1 marked this conversation as resolved.
Show resolved Hide resolved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sys
import unittest
from functools import partial

import tritonclient.grpc as grpcclient
from tritonclient.utils import *

sys.path.append("../../common")
from test_util import TestResultCollector, UserData, callback, create_vllm_request


class VLLMRequestCancelTest(TestResultCollector):
def test_request_cancel(self, send_parameters_as_tensor=True):
with grpcclient.InferenceServerClient(url="localhost:8001") as triton_client:
user_data = UserData()
model_name = "vllm_opt"
stream = False
sampling_parameters = {"temperature": "0.75", "top_p": "0.9"}

triton_client.start_stream(callback=partial(callback, user_data))

for i in range(100):
prompt = (
f"Write an original and creative poem of at least {100 + i} words."
)
request_data = create_vllm_request(
prompt,
i,
stream,
sampling_parameters,
model_name,
send_parameters_as_tensor,
)
triton_client.async_stream_infer(
model_name=model_name,
request_id=request_data["request_id"],
inputs=request_data["inputs"],
outputs=request_data["outputs"],
parameters=sampling_parameters,
)

triton_client.stop_stream(cancel_requests=True)
self.assertFalse(user_data._completed_requests.empty())

result = user_data._completed_requests.get()
self.assertIsInstance(result, InferenceServerException)
self.assertEqual(result.status(), "StatusCode.CANCELLED")
self.assertTrue(user_data._completed_requests.empty())


if __name__ == "__main__":
unittest.main()
85 changes: 85 additions & 0 deletions ci/L0_backend_vllm/request_cancel/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

source ../../common/util.sh

TRITON_DIR=${TRITON_DIR:="/opt/tritonserver"}
SERVER=${TRITON_DIR}/bin/tritonserver
BACKEND_DIR=${TRITON_DIR}/backends
SERVER_ARGS="--model-repository=`pwd`/models --backend-directory=${BACKEND_DIR} --log-verbose=1"
SERVER_LOG="./request_cancel_server.log"
CLIENT_LOG="./request_cancel_client.log"
TEST_RESULT_FILE='test_results.txt'
CLIENT_PY="./request_cancel_test.py"
SAMPLE_MODELS_REPO="../../../samples/model_repository"
EXPECTED_NUM_TESTS=1

rm -rf models && mkdir -p models
cp -r ${SAMPLE_MODELS_REPO}/vllm_model models/vllm_opt
sed -i 's/"model":"facebook\/opt-125m"/"model": "facebook\/opt-350m"/' models/vllm_opt/1/model.json
pskiran1 marked this conversation as resolved.
Show resolved Hide resolved

RET=0

run_server
if [ "$SERVER_PID" == "0" ]; then
cat $SERVER_LOG
echo -e "\n***\n*** Failed to start $SERVER\n***"
exit 1
fi

set +e
python3 $CLIENT_PY -v > $CLIENT_LOG 2>&1

if [ $? -ne 0 ]; then
cat $CLIENT_LOG
echo -e "\n***\n*** Running $CLIENT_PY FAILED. \n***"
RET=1
else
check_test_results $TEST_RESULT_FILE $EXPECTED_NUM_TESTS
if [ $? -ne 0 ]; then
cat $CLIENT_LOG
echo -e "\n***\n*** Test Result Verification FAILED.\n***"
RET=1
fi
fi
set -e

kill $SERVER_PID
wait $SERVER_PID
rm -rf models/

if [ $RET -eq 1 ]; then
cat $CLIENT_LOG
cat $SERVER_LOG
echo -e "\n***\n*** Request Cancel test FAILED. \n***"
else
echo -e "\n***\n*** Request Cancel test PASSED. \n***"
fi

collect_artifacts_from_subdir

exit $RET
4 changes: 2 additions & 2 deletions ci/L0_backend_vllm/stream_enabled/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ rm -rf models/
if [ $RET -eq 1 ]; then
cat $CLIENT_LOG
cat $SERVER_LOG
echo -e "\n***\n*** Straem Enabled test FAILED. \n***"
echo -e "\n***\n*** Stream Enabled test FAILED. \n***"
else
echo -e "\n***\n*** Straem Enabled test PASSED. \n***"
echo -e "\n***\n*** Stream Enabled test PASSED. \n***"
fi

collect_artifacts_from_subdir
Expand Down
4 changes: 2 additions & 2 deletions ci/L0_backend_vllm/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

RET=0
SUBTESTS="accuracy_test stream_enabled vllm_backend"
SUBTESTS="accuracy_test request_cancel stream_enabled vllm_backend"

pip3 install tritonclient grpcio
python3 -m pip install --upgrade pip && pip3 install tritonclient[all]

for TEST in ${SUBTESTS}; do
(cd ${TEST} && bash -ex test.sh && cd ..)
Expand Down
2 changes: 1 addition & 1 deletion ci/L0_multi_gpu/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rm -rf models && mkdir -p models
cp -r ${SAMPLE_MODELS_REPO}/vllm_model models/vllm_opt
sed -i '3s/^/ "tensor_parallel_size": 2,\n/' models/vllm_opt/1/model.json

pip3 install tritonclient grpcio nvidia-ml-py3
python3 -m pip install --upgrade pip && pip3 install tritonclient[all] nvidia-ml-py3
pskiran1 marked this conversation as resolved.
Show resolved Hide resolved

RET=0

Expand Down
Loading