Skip to content

Commit

Permalink
Add test with explicit resource
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui committed Jun 5, 2023
1 parent 409c9f0 commit b9b2c93
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
48 changes: 35 additions & 13 deletions qa/L0_model_update/instance_update_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ def test_infer_while_updating(self):
# Unload model
self.__unload_model()

# Test instance resource requirement update
@unittest.skipUnless(os.environ["RATE_LIMIT_MODE"] == "execution_count",
# Test instance resource requirement increase
@unittest.skipUnless("execution_count" in os.environ["RATE_LIMIT_MODE"],
"Rate limiter precondition not met for this test")
def test_instance_resource_update(self):
def test_instance_resource_increase(self):
# Load model
self.__load_model(
1,
Expand All @@ -365,19 +365,41 @@ def infer():
time.sleep(infer_count / 2) # each infer should take < 0.5 seconds
self.assertNotIn(False, infer_complete, "Infer possibly stuck")
infer_thread.result()
# Decrease the resource requirement
self.__update_instance_count(
1, 1,
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 6\n}\n]\n}\n}"
# Unload model
self.__unload_model()

# Test instance resource requirement increase above explicit resource
@unittest.skipUnless(os.environ["RATE_LIMIT_MODE"] ==
"execution_count_with_explicit_resource",
"Rate limiter precondition not met for this test")
def test_instance_resource_increase_above_explicit(self):
# Load model
self.__load_model(
1,
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 2\n}\n]\n}\n}"
)
# Further decrease the resource requirement. The previous decrease
# should have lower the max resource in the rate limiter, which the
# error "Should not print this ..." should not be printed into the
# server log because the max resource is above the previously set limit
# and it will be checked by the main bash test script.
# Increase resource requirement
with self.assertRaises(InferenceServerException):
self.__update_instance_count(
1, 1,
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 32\n}\n]\n}\n}"
)
# Unload model
self.__triton.unload_model(self.__model_name)

# Test instance resource requirement decrease
@unittest.skipUnless("execution_count" in os.environ["RATE_LIMIT_MODE"],
"Rate limiter precondition not met for this test")
def test_instance_resource_decrease(self):
# Load model
self.__load_model(
1,
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 4\n}\n]\n}\n}"
)
# Decrease resource requirement
self.__update_instance_count(
1, 1,
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 4\n}\n]\n}\n}"
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 2\n}\n]\n}\n}"
)
# Unload model
self.__unload_model()
Expand Down
11 changes: 8 additions & 3 deletions qa/L0_model_update/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,20 @@ function setup_models() {

RET=0

# Test model instance update with and without rate limiting enabled
for RATE_LIMIT_MODE in "off" "execution_count"; do
# Test model instance update with rate limiting on/off and explicit resource
for RATE_LIMIT_MODE in "off" "execution_count" "execution_count_with_explicit_resource"; do

RATE_LIMIT_ARGS="--rate-limit=$RATE_LIMIT_MODE"
if [ "$RATE_LIMIT_MODE" == "execution_count_with_explicit_resource" ]; then
RATE_LIMIT_ARGS="--rate-limit=execution_count --rate-limit-resource=R1:10"
fi

export RATE_LIMIT_MODE=$RATE_LIMIT_MODE
TEST_LOG="instance_update_test.rate_limit_$RATE_LIMIT_MODE.log"
SERVER_LOG="./instance_update_test.rate_limit_$RATE_LIMIT_MODE.server.log"

setup_models
SERVER_ARGS="--model-repository=models --model-control-mode=explicit --rate-limit=$RATE_LIMIT_MODE --log-verbose=2"
SERVER_ARGS="--model-repository=models --model-control-mode=explicit $RATE_LIMIT_ARGS --log-verbose=2"
run_server
if [ "$SERVER_PID" == "0" ]; then
echo -e "\n***\n*** Failed to start $SERVER\n***"
Expand Down

0 comments on commit b9b2c93

Please sign in to comment.