-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test: Add C++ gRPC cancellation tests to L0_request_cancellation #8775
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||
| # Copyright 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||||||||||||||||||||||
| # Copyright 2023-2026, 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 | ||||||||||||||||||||||
|
|
@@ -42,8 +42,10 @@ export CUDA_VISIBLE_DEVICES=0 | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| SERVER=/opt/tritonserver/bin/tritonserver | ||||||||||||||||||||||
| source ../common/util.sh | ||||||||||||||||||||||
| CANCEL_LOG_LINE="Cancellation notification received for" | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably needs a trailing space.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sentence looks odd. There should be something after 'for'.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two locations server/src/grpc/infer_handler.cc Lines 718 to 722 in 0c063cf
server/src/grpc/stream_infer_handler.cc Lines 152 to 156 in 0c063cf
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As J said, there is a trailing space after 'for'. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| RET=0 | ||||||||||||||||||||||
| rm -f *.log | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # Unit tests | ||||||||||||||||||||||
|
|
@@ -66,7 +68,7 @@ if [ $? -ne 0 ]; then | |||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # gRPC cancellation tests | ||||||||||||||||||||||
| # Python gRPC cancellation tests | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| rm -rf models && mkdir models | ||||||||||||||||||||||
| mkdir -p models/custom_identity_int32/1 && (cd models/custom_identity_int32 && \ | ||||||||||||||||||||||
|
|
@@ -121,7 +123,7 @@ for TEST_CASE in "test_grpc_async_infer" \ | |||||||||||||||||||||
| RET=1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| count=$(grep -o "Cancellation notification received for" $SERVER_LOG | wc -l) | ||||||||||||||||||||||
| count=$(grep -o "$CANCEL_LOG_LINE" $SERVER_LOG | wc -l) | ||||||||||||||||||||||
| if [ $count == 0 ]; then | ||||||||||||||||||||||
| echo -e "\n***\n*** Cancellation not received by server on $TEST_CASE\n***" | ||||||||||||||||||||||
| cat $SERVER_LOG | ||||||||||||||||||||||
|
|
@@ -170,6 +172,66 @@ for TEST_CASE in "test_grpc_async_infer" \ | |||||||||||||||||||||
| fi | ||||||||||||||||||||||
| done | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # C++ gRPC cancellation tests | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| GRPC_CANCELLATION_TEST_CPP=../clients/grpc_cancellation_test | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| for ENTRY in "TestGrpcAsyncInfer 1" \ | ||||||||||||||||||||||
| "TestGrpcAsyncInferCancelAfterCompletionIsNoOp 0" \ | ||||||||||||||||||||||
| "TestGrpcAsyncInferWithoutContextStillCompletes 0" \ | ||||||||||||||||||||||
| "TestGrpcAsyncInferMulti 2" \ | ||||||||||||||||||||||
| "TestGrpcStreamInfer 1" \ | ||||||||||||||||||||||
| "TestGrpcStreamCancelWithoutInfer 1" \ | ||||||||||||||||||||||
| "TestGrpcStreamCancelThenRestart 1"; do | ||||||||||||||||||||||
| read -r TEST_CASE EXPECTED_CANCEL_COUNT <<< "$ENTRY" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| TEST_LOG="./grpc_cancellation_test_cpp.$TEST_CASE.log" | ||||||||||||||||||||||
| SERVER_LOG="./grpc_cancellation_test_cpp.$TEST_CASE.server.log" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # AsyncInferMulti fans out N concurrent requests; bump to 3 CPU | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a check for N >= 3?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate? Check N requests, instances or cancellation?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For N concurrent requests to fan out to 3 CPU, shouldn't we have N > 3?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this test, each request execution takes 10 seconds. To avoid backlog in the request queue (reduce overall test time), the model configuration is increased to 3 instances. If N > 3, requests after 3rd will wait in the queue until the first 3 requests have completed execution, which will take 10 seconds.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you mean. Here we are testing requests that are cancelled during execution. I can also add a test for in-queue request cancellation.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Yes, let's test for in-queue cancellation also. |
||||||||||||||||||||||
| # instances so each can execute in parallel. Reverted after the test | ||||||||||||||||||||||
| # so subsequent cases keep the default single-instance config. | ||||||||||||||||||||||
| if [ "$TEST_CASE" == "TestGrpcAsyncInferMulti" ]; then | ||||||||||||||||||||||
| sed -i 's|instance_group .*|instance_group [{ count: 3, kind: KIND_CPU }]|' \ | ||||||||||||||||||||||
| models/custom_identity_int32/config.pbtxt | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| SERVER_ARGS="--model-repository=`pwd`/models --log-verbose=2" | ||||||||||||||||||||||
| run_server | ||||||||||||||||||||||
| if [ "$SERVER_PID" == "0" ]; then | ||||||||||||||||||||||
| echo -e "\n***\n*** Failed to start $SERVER\n***" | ||||||||||||||||||||||
| cat $SERVER_LOG | ||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| set +e | ||||||||||||||||||||||
| LD_LIBRARY_PATH=/opt/tritonserver/lib:$LD_LIBRARY_PATH \ | ||||||||||||||||||||||
| $GRPC_CANCELLATION_TEST_CPP \ | ||||||||||||||||||||||
| --gtest_filter="GrpcCancellationTest.$TEST_CASE" > $TEST_LOG 2>&1 | ||||||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||||||
| echo -e "\n***\n*** C++ gRPC Cancellation Tests Failed on $TEST_CASE\n***" | ||||||||||||||||||||||
| cat $TEST_LOG | ||||||||||||||||||||||
| RET=1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| cancel_count=$(grep -c "$CANCEL_LOG_LINE" $SERVER_LOG || true) | ||||||||||||||||||||||
| if [ $cancel_count -ne $EXPECTED_CANCEL_COUNT ]; then | ||||||||||||||||||||||
| echo -e "\n***\n*** Unexpected cancellation count on $TEST_CASE. Expected $EXPECTED_CANCEL_COUNT but received $cancel_count.\n***" | ||||||||||||||||||||||
| cat $SERVER_LOG | ||||||||||||||||||||||
| RET=1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| set -e | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| kill $SERVER_PID | ||||||||||||||||||||||
| wait $SERVER_PID | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if [ "$TEST_CASE" == "TestGrpcAsyncInferMulti" ]; then | ||||||||||||||||||||||
| sed -i 's|instance_group .*|instance_group [{ kind: KIND_CPU }]|' \ | ||||||||||||||||||||||
| models/custom_identity_int32/config.pbtxt | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| done | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # End-to-end scheduler tests | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
This change is not going in r26.05.
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.
Try to cherry-pick since internal team is waiting for this feature.
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.
kind of a big overhaul this late into the release, no?
what is the risk assessment? (discuss offline)