-
Notifications
You must be signed in to change notification settings - Fork 1.6k
refactor: Update the response queue in the server to reuse response slots #7879
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
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c9bcbd9
Reuse response allocations
pskiran1 2fba1dd
ResponseQueue Threshold
pskiran1 16d347a
Update copyright
pskiran1 12cc2d2
Merge branch 'main' of https://github.com/triton-inference-server/ser…
pskiran1 740d167
Test case
pskiran1 9020014
Update copyright
pskiran1 6ccee17
Merge branch 'main' into spolisetty_dlis_7657
nnshah1 62e719c
Merge branch 'main' into spolisetty_dlis_7657
pskiran1 477a0a3
Test case
pskiran1 f49203c
Fix pre-commit
pskiran1 dcbc0b7
Merge branch 'main' into spolisetty_dlis_7657
pskiran1 0752b3f
Fix pre-commit
pskiran1 31347a8
Update
pskiran1 1a6a497
Update
pskiran1 77555bb
Update
pskiran1 85ea2b1
Update
pskiran1 b82eda0
Update documentation
pskiran1 5cfab02
Update
pskiran1 6bce04f
Update
pskiran1 ba16414
Update
pskiran1 34f766a
Update
pskiran1 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
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,122 @@ | ||
# Copyright (c) 2025, NVIDIA CORPORATION. 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. | ||
|
||
|
||
import os | ||
import queue | ||
import unittest | ||
from functools import partial | ||
|
||
import numpy as np | ||
import tritonclient.grpc as grpcclient | ||
from tritonclient.utils import InferenceServerException | ||
|
||
OUTPUT_NUM_ELEMENTS = int(os.getenv("OUTPUT_NUM_ELEMENTS", 1)) | ||
|
||
|
||
class UserData: | ||
def __init__(self): | ||
self._completed_requests = queue.Queue() | ||
|
||
|
||
def callback(user_data, result, error): | ||
if error: | ||
user_data._completed_requests.put(error, timeout=100) | ||
else: | ||
user_data._completed_requests.put(result, timeout=100) | ||
|
||
|
||
class TestTritonInference(unittest.TestCase): | ||
def setUp(self): | ||
self.triton_client = grpcclient.InferenceServerClient(url="localhost:8001") | ||
|
||
def tearDown(self): | ||
self.triton_client.stop_stream() | ||
|
||
def test_inference(self): | ||
model_name = "repeat_int32" | ||
num_responses = 256 | ||
in_data = np.random.randint(0, 1000, num_responses, dtype=np.int32) | ||
delay_data = np.zeros(num_responses, dtype=np.uint32) | ||
wait_data = np.zeros(1, dtype=np.uint32) | ||
user_data = UserData() | ||
|
||
inputs = [ | ||
grpcclient.InferInput("IN", [num_responses], "INT32"), | ||
grpcclient.InferInput("DELAY", [num_responses], "UINT32"), | ||
grpcclient.InferInput("WAIT", [1], "UINT32"), | ||
] | ||
outputs = [ | ||
grpcclient.InferRequestedOutput("OUT"), | ||
grpcclient.InferRequestedOutput("IDX"), | ||
] | ||
|
||
inputs[0].set_data_from_numpy(in_data) | ||
inputs[1].set_data_from_numpy(delay_data) | ||
inputs[2].set_data_from_numpy(wait_data) | ||
|
||
self.triton_client.start_stream(callback=partial(callback, user_data)) | ||
self.triton_client.async_stream_infer( | ||
model_name=model_name, | ||
inputs=inputs, | ||
outputs=outputs, | ||
) | ||
|
||
recv_count = 0 | ||
while recv_count < num_responses: | ||
data_item = user_data._completed_requests.get() | ||
|
||
if isinstance(data_item, InferenceServerException): | ||
self.fail(f"InferenceServerException: {data_item}") | ||
try: | ||
response_idx = data_item.as_numpy("IDX")[0] | ||
response_data = data_item.as_numpy("OUT") | ||
expected_data = in_data[response_idx] | ||
|
||
self.assertEqual( | ||
response_data[0], | ||
expected_data, | ||
f"Validation failed at index {response_idx} - response_data[0]: {response_data[0]}, expected_data: {expected_data}", | ||
) | ||
self.assertEqual( | ||
response_data.size, | ||
OUTPUT_NUM_ELEMENTS, | ||
f"Validation failed - response_data.size: {response_data.size}, OUTPUT_NUM_ELEMENTS: {OUTPUT_NUM_ELEMENTS}", | ||
) | ||
|
||
except Exception as e: | ||
self.fail(f"Error processing response: {str(e)}") | ||
recv_count += 1 | ||
|
||
self.assertEqual( | ||
user_data._completed_requests.qsize(), | ||
0, | ||
"Did not receive the expected number of responses.", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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
Oops, something went wrong.
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.
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.
Can you add a test plan in the description on what we are trying to test here?
Why have we set
--grpc-max-response-pool-size
only to1
?Also can we add a test to confirm memory footprint decreses with using
--grpc-max-response-pool-size
VS not using--grpc-max-response-pool-size
?Uh oh!
There was an error while loading. Please reload this page.
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.
I have added a new test case in L0_memory to evaluate memory utilization when running the server with different values for
--grpc-max-response-pool-size
(1, 25, and 50), as well as without this flag.Regarding setting
--grpc-max-response-pool-size
to 1, I included this specific test to evaluate the lowest possible value. And, running the decoupled model tests takes a long time, with additional pool sizes it is leading to timeouts. The new test case inL0_memory
covers different values.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.
Also, updated description with higher level details about tests. Please let me know if we are missing something.