code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _validate_chat_request(
self,
request: CreateChatCompletionRequest,
metadata: TritonModelMetadata,
lora_name: str | None,
):
"""
Validates a chat request to align with currently supported features.
"""
# Reject missing internal information needed ... |
Validates a chat request to align with currently supported features.
| _validate_chat_request | python | triton-inference-server/server | python/openai/openai_frontend/engine/triton_engine.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/engine/triton_engine.py | BSD-3-Clause |
def _validate_completion_request(
self,
request: CreateCompletionRequest,
metadata: TritonModelMetadata,
lora_name: str | None,
):
"""
Validates a completions request to align with currently supported features.
"""
# Reject missing internal information... |
Validates a completions request to align with currently supported features.
| _validate_completion_request | python | triton-inference-server/server | python/openai/openai_frontend/engine/triton_engine.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/engine/triton_engine.py | BSD-3-Clause |
def get_cached_tokenizer(
tokenizer: Union[PreTrainedTokenizer, PreTrainedTokenizerFast]
) -> Union[PreTrainedTokenizer, PreTrainedTokenizerFast]:
"""Get tokenizer with cached properties.
This will patch the tokenizer object in place.
By default, transformers will recompute multiple tokenizer properti... | Get tokenizer with cached properties.
This will patch the tokenizer object in place.
By default, transformers will recompute multiple tokenizer properties
each time they are called, leading to a significant slowdown. This
function caches these properties for faster access. | get_cached_tokenizer | python | triton-inference-server/server | python/openai/openai_frontend/engine/utils/tokenizer.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/engine/utils/tokenizer.py | BSD-3-Clause |
def get_tokenizer(
tokenizer_name: str,
*args,
tokenizer_mode: str = "auto",
trust_remote_code: bool = False,
tokenizer_revision: Optional[str] = None,
download_dir: Optional[str] = None,
**kwargs,
) -> Union[PreTrainedTokenizer, PreTrainedTokenizerFast]:
"""Gets a tokenizer for the give... | Gets a tokenizer for the given model name via Huggingface/modelscope. | get_tokenizer | python | triton-inference-server/server | python/openai/openai_frontend/engine/utils/tokenizer.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/engine/utils/tokenizer.py | BSD-3-Clause |
def _construct_string_from_pointer(pointer: int, size: int) -> str:
"""Constructs a Python string from a C pointer and size."""
# Create a ctypes string buffer
string_buffer = ctypes.create_string_buffer(size + 1) # +1 for null terminator
# Copy the data from the pointer to the buffer
ctypes.memm... | Constructs a Python string from a C pointer and size. | _construct_string_from_pointer | python | triton-inference-server/server | python/openai/openai_frontend/engine/utils/triton.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/engine/utils/triton.py | BSD-3-Clause |
def extract_intermediate_diff(curr: str, old: str) -> str:
"""
Given two strings, extract the difference in the middle between two strings
that are known to have a common prefix and/or suffix.
This function is provided as a UTILITY for extracting information from JSON
generated by partial_json_pars... |
Given two strings, extract the difference in the middle between two strings
that are known to have a common prefix and/or suffix.
This function is provided as a UTILITY for extracting information from JSON
generated by partial_json_parser, to help in ensuring that the right tokens
are returned in ... | extract_intermediate_diff | python | triton-inference-server/server | python/openai/openai_frontend/engine/utils/tool_call_parsers/utils.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/engine/utils/tool_call_parsers/utils.py | BSD-3-Clause |
async def create_chat_completion(
request: CreateChatCompletionRequest,
raw_request: Request,
) -> CreateChatCompletionResponse | StreamingResponse:
"""
Creates a chat completion for the provided messages and parameters.
"""
if not raw_request.app.engine:
raise HTTPException(status_code=... |
Creates a chat completion for the provided messages and parameters.
| create_chat_completion | python | triton-inference-server/server | python/openai/openai_frontend/frontend/fastapi/routers/chat.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/frontend/fastapi/routers/chat.py | BSD-3-Clause |
async def create_completion(
request: CreateCompletionRequest, raw_request: Request
) -> CreateCompletionResponse | StreamingResponse:
"""
Creates a completion for the provided prompt and parameters.
"""
if not raw_request.app.engine:
raise HTTPException(status_code=500, detail="No attached ... |
Creates a completion for the provided prompt and parameters.
| create_completion | python | triton-inference-server/server | python/openai/openai_frontend/frontend/fastapi/routers/completions.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/frontend/fastapi/routers/completions.py | BSD-3-Clause |
def list_models(request: Request) -> ListModelsResponse:
"""
Lists the currently available models, and provides basic information about each one such as the owner and availability.
"""
if not request.app.engine:
raise HTTPException(status_code=500, detail="No attached inference engine")
mod... |
Lists the currently available models, and provides basic information about each one such as the owner and availability.
| list_models | python | triton-inference-server/server | python/openai/openai_frontend/frontend/fastapi/routers/models.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/frontend/fastapi/routers/models.py | BSD-3-Clause |
def retrieve_model(request: Request, model_name: str) -> Model:
"""
Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
"""
if not request.app.engine:
raise HTTPException(status_code=500, detail="No attached inference engine")
# TODO:... |
Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
| retrieve_model | python | triton-inference-server/server | python/openai/openai_frontend/frontend/fastapi/routers/models.py | https://github.com/triton-inference-server/server/blob/master/python/openai/openai_frontend/frontend/fastapi/routers/models.py | BSD-3-Clause |
def parse_massif_out(filename):
"""
Extract the allocation data from the massif output file, and compile
it into a dictionary.
"""
# Read the file
with open(filename, "r") as f:
contents = f.read()
snapshots = re.findall("snapshot=(.*?)heap_tree", contents, flags=re.DOTALL)
... |
Extract the allocation data from the massif output file, and compile
it into a dictionary.
| parse_massif_out | python | triton-inference-server/server | qa/common/check_massif_log.py | https://github.com/triton-inference-server/server/blob/master/qa/common/check_massif_log.py | BSD-3-Clause |
def is_unbounded_growth(summary, max_allowed_alloc, start_from_middle):
"""
Check whether the heap allocations is increasing
"""
totals = summary["mem_heap_B"]
if len(totals) < 5:
print("Error: Not enough snapshots")
return False
# Measure difference between mean and maximum m... |
Check whether the heap allocations is increasing
| is_unbounded_growth | python | triton-inference-server/server | qa/common/check_massif_log.py | https://github.com/triton-inference-server/server/blob/master/qa/common/check_massif_log.py | BSD-3-Clause |
def check_valgrind_log(log_file):
"""
Counts the definite leaks reported
by valgrind, matches them against
the whitelist.
Parameters
----------
log_file: str
The path to the log file
Returns
-------
list of str
a list of the leak records as strings
"""
... |
Counts the definite leaks reported
by valgrind, matches them against
the whitelist.
Parameters
----------
log_file: str
The path to the log file
Returns
-------
list of str
a list of the leak records as strings
| check_valgrind_log | python | triton-inference-server/server | qa/common/check_valgrind_log.py | https://github.com/triton-inference-server/server/blob/master/qa/common/check_valgrind_log.py | BSD-3-Clause |
def get_endpoint_header(url, data, request_header=None):
"""
Sends a POST request to the given URL with the provided data and returns the value of the "endpoint-load-metrics" header,
or None if the request fails.
"""
HEADER_KEY = "endpoint-load-metrics"
try:
response = None
if re... |
Sends a POST request to the given URL with the provided data and returns the value of the "endpoint-load-metrics" header,
or None if the request fails.
| get_endpoint_header | python | triton-inference-server/server | qa/common/orca_header_test.py | https://github.com/triton-inference-server/server/blob/master/qa/common/orca_header_test.py | BSD-3-Clause |
def parse_header_data(header, orca_format):
"""
Parses the header data into a dictionary based on the given format.
"""
METRIC_KEY = "named_metrics"
try:
if orca_format == "json":
# Parse the header in JSON format
data = json.loads(header.replace("JSON ", ""))
... |
Parses the header data into a dictionary based on the given format.
| parse_header_data | python | triton-inference-server/server | qa/common/orca_header_test.py | https://github.com/triton-inference-server/server/blob/master/qa/common/orca_header_test.py | BSD-3-Clause |
def check_for_keys(data, desired_keys, orca_format):
"""
Checks if all desired keys are present in the given data dictionary.
"""
if all(key in data for key in desired_keys):
print(
"ORCA header present in ",
orca_format,
"format with" "kv_cache_utilization:",... |
Checks if all desired keys are present in the given data dictionary.
| check_for_keys | python | triton-inference-server/server | qa/common/orca_header_test.py | https://github.com/triton-inference-server/server/blob/master/qa/common/orca_header_test.py | BSD-3-Clause |
def check_sequence(
self,
trial,
model_name,
input_dtype,
correlation_id,
sequence_thresholds,
values,
expected_result,
protocol,
batch_size=1,
sequence_name="<unknown>",
tensor_shape=(1,),
):
"""Perform sequence... | Perform sequence of inferences. The 'values' holds a list of
tuples, one for each inference with format:
(flag_str, value, (ls_ms, gt_ms), (pre_delay_ms, post_delay_ms)
| check_sequence | python | triton-inference-server/server | qa/common/sequence_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/sequence_util.py | BSD-3-Clause |
def check_sequence_async(
self,
trial,
model_name,
input_dtype,
correlation_id,
sequence_thresholds,
values,
expected_result,
shm_region_handles,
batch_size=1,
sequence_name="<unknown>",
tensor_shape=(1,),
):
"""... | Perform sequence of inferences using stream async run.
The 'values' holds a list of tuples, one for each inference with format:
(flag_str, value, pre_delay_ms)
| check_sequence_async | python | triton-inference-server/server | qa/common/sequence_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/sequence_util.py | BSD-3-Clause |
def check_sequence_shape_tensor_io(
self,
model_name,
input_dtype,
correlation_id,
sequence_thresholds,
values,
expected_result,
shm_region_handles,
using_dynamic_batcher=False,
sequence_name="<unknown>",
shape_tensor_input_dtype=np... | Perform sequence of inferences using async run. The 'values' holds
a list of tuples, one for each inference with format:
(flag_str, shape_value, value, pre_delay_ms)
| check_sequence_shape_tensor_io | python | triton-inference-server/server | qa/common/sequence_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/sequence_util.py | BSD-3-Clause |
def validate_for_trt_model(
input_dtype, output0_dtype, output1_dtype, input_shape, output0_shape, output1_shape
):
"""Return True if input and output dtypes are supported by a TRT model."""
supported_datatypes = [
bool,
np.int8,
np.int32,
np.uint8,
np.float16,
... | Return True if input and output dtypes are supported by a TRT model. | validate_for_trt_model | python | triton-inference-server/server | qa/common/test_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/test_util.py | BSD-3-Clause |
def validate_for_ensemble_model(
ensemble_type,
input_dtype,
output0_dtype,
output1_dtype,
input_shape,
output0_shape,
output1_shape,
):
"""Return True if input and output dtypes are supported by the ensemble type."""
# Not extending test to uint8 yet
if (
input_dtype ==... | Return True if input and output dtypes are supported by the ensemble type. | validate_for_ensemble_model | python | triton-inference-server/server | qa/common/test_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/test_util.py | BSD-3-Clause |
def validate_for_onnx_model(
input_dtype, output0_dtype, output1_dtype, input_shape, output0_shape, output1_shape
):
"""Return True if input and output dtypes are supported by a Onnx model."""
# Not extending test to uint8 yet
if (
input_dtype == np.uint8
or output0_dtype == np.uint8
... | Return True if input and output dtypes are supported by a Onnx model. | validate_for_onnx_model | python | triton-inference-server/server | qa/common/test_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/test_util.py | BSD-3-Clause |
def validate_for_libtorch_model(
input_dtype,
output0_dtype,
output1_dtype,
input_shape,
output0_shape,
output1_shape,
max_batch=0,
reshape=False,
):
"""Return True if input and output dtypes are supported by a libtorch model."""
# Not extending test to uint8 yet
if (
... | Return True if input and output dtypes are supported by a libtorch model. | validate_for_libtorch_model | python | triton-inference-server/server | qa/common/test_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/test_util.py | BSD-3-Clause |
def validate_for_openvino_model(
input_dtype, output0_dtype, output1_dtype, input_shape, output0_shape, output1_shape
):
"""Return True if input and output dtypes are supported by an OpenVino model."""
# Not extending test to uint8 yet
if (
input_dtype == np.uint8
or output0_dtype == np... | Return True if input and output dtypes are supported by an OpenVino model. | validate_for_openvino_model | python | triton-inference-server/server | qa/common/test_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/test_util.py | BSD-3-Clause |
def check_gpus_compute_capability(min_capability):
"""
Check if all GPUs have a compute capability greater than or equal to the given value.
Args:
min_capability (float): The minimum required compute capability (e.g., 8.0).
Returns:
bool
"""
import pycuda.driver as cuda
cu... |
Check if all GPUs have a compute capability greater than or equal to the given value.
Args:
min_capability (float): The minimum required compute capability (e.g., 8.0).
Returns:
bool
| check_gpus_compute_capability | python | triton-inference-server/server | qa/common/test_util.py | https://github.com/triton-inference-server/server/blob/master/qa/common/test_util.py | BSD-3-Clause |
def _get_gpu_bls_outputs(self, input0_pb, input1_pb):
"""
This function is created to test that the DLPack container works
properly when the inference response and outputs go out of scope.
Returns True on success and False on failure.
"""
logger = pb_utils.Logger
... |
This function is created to test that the DLPack container works
properly when the inference response and outputs go out of scope.
Returns True on success and False on failure.
| _get_gpu_bls_outputs | python | triton-inference-server/server | qa/L0_backend_python/decoupled/models/decoupled_bls/1/model.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_backend_python/decoupled/models/decoupled_bls/1/model.py | BSD-3-Clause |
def finalize(self):
"""`finalize` is called only once when the model is being unloaded.
Implementing `finalize` function is OPTIONAL. This function allows
the model to perform any necessary clean ups before exit.
"""
logger = pb_utils.Logger
logger.log_info("Finalize invo... | `finalize` is called only once when the model is being unloaded.
Implementing `finalize` function is OPTIONAL. This function allows
the model to perform any necessary clean ups before exit.
| finalize | python | triton-inference-server/server | qa/L0_backend_python/decoupled/models/decoupled_bls/1/model.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_backend_python/decoupled/models/decoupled_bls/1/model.py | BSD-3-Clause |
def execute(self, requests):
"""Tries to create a response sender object and use that
for sending the response.
"""
output0_dtype = self.output0_dtype
output1_dtype = self.output1_dtype
responses = []
for request in requests:
in_0 = pb_utils.get_inpu... | Tries to create a response sender object and use that
for sending the response.
| execute | python | triton-inference-server/server | qa/L0_backend_python/decoupled/models/decoupled_return_response_error/1/model.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_backend_python/decoupled/models/decoupled_return_response_error/1/model.py | BSD-3-Clause |
def execute(self, requests):
"""Create a response sender object and use that
for sending the response.
"""
# This model does not support batching, so 'request_count' should always be 1.
if len(requests) != 1:
raise pb_utils.TritonModelException(
"unsu... | Create a response sender object and use that
for sending the response.
| execute | python | triton-inference-server/server | qa/L0_backend_python/decoupled/models/decoupled_send_after_close_error/1/model.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_backend_python/decoupled/models/decoupled_send_after_close_error/1/model.py | BSD-3-Clause |
def execute(self, requests):
"""
Identity model using DLPack in Python backend.
"""
responses = []
for request in requests:
input_tensor = pb_utils.get_input_tensor_by_name(request, "INPUT0")
out_tensor = pb_utils.Tensor.from_dlpack(
"OUTPU... |
Identity model using DLPack in Python backend.
| execute | python | triton-inference-server/server | qa/L0_buffer_attributes/models/identity/1/model.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_buffer_attributes/models/identity/1/model.py | BSD-3-Clause |
def _configure_server(
self,
create_byte_size=DEFAULT_SHM_BYTE_SIZE,
register_byte_size=DEFAULT_SHM_BYTE_SIZE,
device_id=0,
):
"""Creates and registers cuda shared memory regions for testing.
Parameters
----------
create_byte_size: int
Siz... | Creates and registers cuda shared memory regions for testing.
Parameters
----------
create_byte_size: int
Size of each cuda shared memory region to create.
NOTE: This should be sufficiently large to hold the inputs/outputs
stored in shared memory.
... | _configure_server | python | triton-inference-server/server | qa/L0_cuda_shared_memory/cuda_shared_memory_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_cuda_shared_memory/cuda_shared_memory_test.py | BSD-3-Clause |
def test_json_recursion_depth_limit(self):
"""Test that server properly handles and rejects deeply nested JSON."""
def create_nested_json(depth, value):
for _ in range(depth):
value = f"[{value}]"
return json.loads(value)
headers = {"Content-Type": "appl... | Test that server properly handles and rejects deeply nested JSON. | test_json_recursion_depth_limit | python | triton-inference-server/server | qa/L0_http/http_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_http/http_test.py | BSD-3-Clause |
def validate_message(message, escaped):
"""message field validator
Messages can be single line or multi-line. In the multi-line case
messages have the form:
<heading>\n
<object>
Where heading is an optional string (escaped with normal escaping
rules) and object is a structured representat... | message field validator
Messages can be single line or multi-line. In the multi-line case
messages have the form:
<heading>
<object>
Where heading is an optional string (escaped with normal escaping
rules) and object is a structured representation of an object such
as a table or protobuf... | validate_message | python | triton-inference-server/server | qa/L0_logging/log_format_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_logging/log_format_test.py | BSD-3-Clause |
def check_sequence_async(
self,
client_metadata,
trial,
model_name,
input_dtype,
steps,
timeout_ms=DEFAULT_TIMEOUT_MS,
batch_size=1,
sequence_name="<unknown>",
tensor_shape=(1,),
input_name="INPUT",
output_name="OUTPUT",
... | Perform sequence of inferences using async run. The 'steps' holds
a list of tuples, one for each inference with format:
(flag_str, value, expected_result, delay_ms)
| check_sequence_async | python | triton-inference-server/server | qa/L0_long_running_stress/scenarios.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_long_running_stress/scenarios.py | BSD-3-Clause |
def _collect_metrics(self, observed_metrics, interval_secs=1):
"""
Collects metrics at provided 'interval_secs' and stores them in the
provided 'observed_metrics' dictionary for postprocessing.
"""
# Give the test and server some time to begin processing requests
# before... |
Collects metrics at provided 'interval_secs' and stores them in the
provided 'observed_metrics' dictionary for postprocessing.
| _collect_metrics | python | triton-inference-server/server | qa/L0_metrics/cpu_metrics_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_metrics/cpu_metrics_test.py | BSD-3-Clause |
def parse_model_grpc(model_metadata, model_config):
"""
Check the configuration of a model to make sure it is supported
by this client.
"""
if len(model_metadata.inputs) != 1:
raise Exception("expecting 1 input, got {}".format(len(model_metadata.inputs)))
if len(model_metadata.outputs) !... |
Check the configuration of a model to make sure it is supported
by this client.
| parse_model_grpc | python | triton-inference-server/server | qa/L0_perf_pyclients/simple_perf_client.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_perf_pyclients/simple_perf_client.py | BSD-3-Clause |
def setup_server(model_repository="test_model_repository") -> tritonserver.Server:
"""
Using tritonserver, starts a server with the models: identity and delayed_identity
"""
module_directory = os.path.split(os.path.abspath(__file__))[0]
model_path = os.path.abspath(os.path.join(module_directory, mod... |
Using tritonserver, starts a server with the models: identity and delayed_identity
| setup_server | python | triton-inference-server/server | qa/L0_python_api/testing_utils.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/testing_utils.py | BSD-3-Clause |
def setup_service(
server: tritonserver.Server,
frontend: Union[KServeHttp, KServeGrpc, Metrics],
options=None,
) -> Union[KServeHttp, KServeGrpc, Metrics]:
"""
Used to create and start any of the frontends supported by tritonfrontend.
"""
service = frontend(server=server, options=options)
... |
Used to create and start any of the frontends supported by tritonfrontend.
| setup_service | python | triton-inference-server/server | qa/L0_python_api/testing_utils.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/testing_utils.py | BSD-3-Clause |
def setup_client(
frontend_client: Union["tritonclient.http", "tritonclient.grpc"], url: str
):
"""
Sets up a client to communicate with the Server through the respective protocol.
"""
return frontend_client.InferenceServerClient(url=url) |
Sets up a client to communicate with the Server through the respective protocol.
| setup_client | python | triton-inference-server/server | qa/L0_python_api/testing_utils.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/testing_utils.py | BSD-3-Clause |
def send_and_test_inference_identity(
frontend_client: Union[
"tritonclient.http.InferenceServerClient",
"tritonclient.grpc.InferenceServerClient",
],
url: str,
) -> bool:
"""
Sends an inference request to the model at test_model_repository/identity
and verifies input == output
... |
Sends an inference request to the model at test_model_repository/identity
and verifies input == output
| send_and_test_inference_identity | python | triton-inference-server/server | qa/L0_python_api/testing_utils.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/testing_utils.py | BSD-3-Clause |
def send_and_test_stream_inference(
frontend_client: Union[
"tritonclient.http.InferenceServerClient",
"tritonclient.grpc.InferenceServerClient",
],
url: str,
) -> bool:
"""
Sends multiple streaming requests to "delayed_identity" model with negligible delays
and verifies the inpu... |
Sends multiple streaming requests to "delayed_identity" model with negligible delays
and verifies the inputs matches outputs and the ordering is preserved.
| send_and_test_stream_inference | python | triton-inference-server/server | qa/L0_python_api/testing_utils.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/testing_utils.py | BSD-3-Clause |
def send_and_test_generate_inference() -> bool:
"""
Sends an inference request to and identity model through the
HTTP generate endpoint and verifies input == output
"""
model_name = "identity"
url = f"http://localhost:8000/v2/models/{model_name}/generate"
input_text = "testing"
data = {
... |
Sends an inference request to and identity model through the
HTTP generate endpoint and verifies input == output
| send_and_test_generate_inference | python | triton-inference-server/server | qa/L0_python_api/testing_utils.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/testing_utils.py | BSD-3-Clause |
def get_metrics(metrics_url: str, model_name: str = "identity") -> Tuple[int, int]:
"""
Sends a request to the metrics endpoint and returns the following information:
1. Status Code = Indicates whether interaction with Metrics endpoint was successful
2. Inference Count = Indicates whether metrics data b... |
Sends a request to the metrics endpoint and returns the following information:
1. Status Code = Indicates whether interaction with Metrics endpoint was successful
2. Inference Count = Indicates whether metrics data being returned is accurate
| get_metrics | python | triton-inference-server/server | qa/L0_python_api/testing_utils.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/testing_utils.py | BSD-3-Clause |
def _extract_inference_count(metrics_data: str, model_name: str):
"""
Helper function for _get_metrics that parses metrics_data (prometheus-friendly
format) with regex to extract the inference count of model_name.
"""
pattern = (
rf'nv_inference_count\{{.*?model="{re.escape(model_name)}".*?\... |
Helper function for _get_metrics that parses metrics_data (prometheus-friendly
format) with regex to extract the inference count of model_name.
| _extract_inference_count | python | triton-inference-server/server | qa/L0_python_api/testing_utils.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/testing_utils.py | BSD-3-Clause |
def execute(self, requests):
"""
Mock Model that uses the input data to determine how long to wait
before returning identity data
"""
assert len(requests) == 1
delay = 0
request = requests[0]
responses = []
delay_tensor = pb_utils.get_input_tensor... |
Mock Model that uses the input data to determine how long to wait
before returning identity data
| execute | python | triton-inference-server/server | qa/L0_python_api/test_model_repository/delayed_identity/1/model.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_python_api/test_model_repository/delayed_identity/1/model.py | BSD-3-Clause |
def _run_inference_and_validate(self, model):
"""
Helper function that takes model as a parameter to verify the corresponding model's stats
The passed model is composing model for test case `test_ensemble_composing_model_cache_enabled`
For other testcases, the top-level ensemble model st... |
Helper function that takes model as a parameter to verify the corresponding model's stats
The passed model is composing model for test case `test_ensemble_composing_model_cache_enabled`
For other testcases, the top-level ensemble model stats are verified.
* loads the simple_onnx_flo... | _run_inference_and_validate | python | triton-inference-server/server | qa/L0_response_cache/ensemble_cache_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_response_cache/ensemble_cache_test.py | BSD-3-Clause |
def test_ensemble_top_level_response_cache(self):
"""
Test top level response caching when response cache enabled only in
ensemble model's config file.
Expected result: One cache hit in ensemble model stats. No cache related metric counts in
composing model stats.
"""
... |
Test top level response caching when response cache enabled only in
ensemble model's config file.
Expected result: One cache hit in ensemble model stats. No cache related metric counts in
composing model stats.
| test_ensemble_top_level_response_cache | python | triton-inference-server/server | qa/L0_response_cache/ensemble_cache_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_response_cache/ensemble_cache_test.py | BSD-3-Clause |
def test_ensemble_all_models_cache_enabled(self):
"""
Test top level response caching when response cache enabled in
all the models.
Expected result: One cache hit in ensemble model stats. No cache hit in composing model stats.
"""
self._update_config(
self.en... |
Test top level response caching when response cache enabled in
all the models.
Expected result: One cache hit in ensemble model stats. No cache hit in composing model stats.
| test_ensemble_all_models_cache_enabled | python | triton-inference-server/server | qa/L0_response_cache/ensemble_cache_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_response_cache/ensemble_cache_test.py | BSD-3-Clause |
def test_ensemble_composing_model_cache_enabled(self):
"""
Test caching behavior when response cache enabled only in
composing model's config file.
Expected result: One cache hit in composing model stats. No cache related metric counts in
ensemble model stats.
"""
... |
Test caching behavior when response cache enabled only in
composing model's config file.
Expected result: One cache hit in composing model stats. No cache related metric counts in
ensemble model stats.
| test_ensemble_composing_model_cache_enabled | python | triton-inference-server/server | qa/L0_response_cache/ensemble_cache_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_response_cache/ensemble_cache_test.py | BSD-3-Clause |
def test_ensemble_cache_insertion_failure(self):
"""
Test cache insertion failure with cache enabled in
ensemble model's config file.
Expected result: Two cache miss in ensemble model stats indicating request/response not inserted into cache
Reason: The data (input tensors, outpu... |
Test cache insertion failure with cache enabled in
ensemble model's config file.
Expected result: Two cache miss in ensemble model stats indicating request/response not inserted into cache
Reason: The data (input tensors, output tensors and other model information) to be inserted in cac... | test_ensemble_cache_insertion_failure | python | triton-inference-server/server | qa/L0_response_cache/ensemble_cache_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_response_cache/ensemble_cache_test.py | BSD-3-Clause |
def check_sequence_async(
client_metadata,
trial,
model_name,
input_dtype,
steps,
timeout_ms=DEFAULT_TIMEOUT_MS,
sequence_name="<unknown>",
):
"""Perform sequence of inferences using async run. The 'steps' holds
a list of tuples, one for each inference with format:
(flag_str, va... | Perform sequence of inferences using async run. The 'steps' holds
a list of tuples, one for each inference with format:
(flag_str, value, expected_result, delay_ms)
| check_sequence_async | python | triton-inference-server/server | qa/L0_sequence_stress/sequence_stress.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_sequence_stress/sequence_stress.py | BSD-3-Clause |
def _configure_server(
self,
create_byte_size=DEFAULT_SHM_BYTE_SIZE,
register_byte_size=DEFAULT_SHM_BYTE_SIZE,
register_offset=0,
):
"""Creates and registers shared memory regions for testing.
Parameters
----------
create_byte_size: int
Si... | Creates and registers shared memory regions for testing.
Parameters
----------
create_byte_size: int
Size of each system shared memory region to create.
NOTE: This should be sufficiently large to hold the inputs/outputs
stored in shared memory.
... | _configure_server | python | triton-inference-server/server | qa/L0_shared_memory/shared_memory_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_shared_memory/shared_memory_test.py | BSD-3-Clause |
def _parse_trace_log(self, trace_log):
"""
Helper function that parses file, containing collected traces.
Args:
trace_log (str): Name of a file, containing all traces.
Returns:
traces (List[dict]): List of json objects, representing each span.
"""
... |
Helper function that parses file, containing collected traces.
Args:
trace_log (str): Name of a file, containing all traces.
Returns:
traces (List[dict]): List of json objects, representing each span.
| _parse_trace_log | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _check_events(self, span_name, events, is_cancelled):
"""
Helper function that verifies passed events contain expected entries.
Args:
span_name (str): name of a span.
events (List[str]): list of event names, collected for the span with the name `span_name`.
"... |
Helper function that verifies passed events contain expected entries.
Args:
span_name (str): name of a span.
events (List[str]): list of event names, collected for the span with the name `span_name`.
| _check_events | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _test_resource_attributes(self, attributes):
"""
Helper function that verifies passed span attributes.
Currently only test 2 attributes, specified upon tritonserver start:
--trace-config=opentelemetry,resource=test.key=test.value
and
--trace-config=opentelemetry,reso... |
Helper function that verifies passed span attributes.
Currently only test 2 attributes, specified upon tritonserver start:
--trace-config=opentelemetry,resource=test.key=test.value
and
--trace-config=opentelemetry,resource=service.name=test_triton
Args:
att... | _test_resource_attributes | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _verify_contents(self, spans, expected_counts, is_cancelled):
"""
Helper function that:
* iterates over `spans` and for every span it verifies that proper events are collected
* verifies that `spans` has expected number of total spans collected
* verifies that `spans` cont... |
Helper function that:
* iterates over `spans` and for every span it verifies that proper events are collected
* verifies that `spans` has expected number of total spans collected
* verifies that `spans` contains expected number different spans,
specified in `expected_count... | _verify_contents | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _verify_nesting(self, spans, expected_parent_span_dict):
"""
Helper function that checks parent-child relationships between
collected spans are the same as in `expected_parent_span_dict`.
Args:
spans (List[dict]): list of json objects, extracted from the trace and
... |
Helper function that checks parent-child relationships between
collected spans are the same as in `expected_parent_span_dict`.
Args:
spans (List[dict]): list of json objects, extracted from the trace and
containing span info. For this test `name`
... | _verify_nesting | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _verify_headers_propagated_from_client_if_any(self, root_span, headers):
"""
Helper function that checks traceparent's ids, passed in clients
headers/metadata was picked up on the server side.
If `headers` are None, checks that `root_span` does not have
`parentSpanId` specifi... |
Helper function that checks traceparent's ids, passed in clients
headers/metadata was picked up on the server side.
If `headers` are None, checks that `root_span` does not have
`parentSpanId` specified.
Args:
root_span (List[dict]): a json objects, extracted from th... | _verify_headers_propagated_from_client_if_any | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _test_trace(
self,
headers,
expected_number_of_spans,
expected_counts,
expected_parent_span_dict,
):
"""
Helper method that defines the general test scenario for a trace,
described as follows.
1. Parse trace log, exported by OTel collector... |
Helper method that defines the general test scenario for a trace,
described as follows.
1. Parse trace log, exported by OTel collector in self.filename.
2. For each test we re-start OTel collector, so trace log should
have only 1 trace.
3. Test that reported resource... | _test_trace | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _test_simple_trace(self, headers=None):
"""
Helper function, that specifies expected parameters to evaluate trace,
collected from running 1 inference request for `simple` model.
"""
expected_number_of_spans = 3
expected_counts = dict(
{"compute": 1, self.s... |
Helper function, that specifies expected parameters to evaluate trace,
collected from running 1 inference request for `simple` model.
| _test_simple_trace | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _test_custom_identity_trace(self, headers=None):
"""
Helper function, that specifies expected parameters to evaluate trace,
collected from running 1 inference request for `custom_identity_int32`
model.
Number of custom spans defined by the identity backend.
`CUSTOM_AC... |
Helper function, that specifies expected parameters to evaluate trace,
collected from running 1 inference request for `custom_identity_int32`
model.
Number of custom spans defined by the identity backend.
`CUSTOM_ACTIVITY` span will always be there,
`CUSTOM_ACTIVITY<N>` ... | _test_custom_identity_trace | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _test_non_decoupled_trace(self, headers=None):
"""
Helper function, that collects trace for non decoupled model and verifies it.
"""
expected_number_of_spans = 3
expected_counts = dict(
{"compute": 1, self.non_decoupled_model_name_: 1, self.root_span: 1}
)... |
Helper function, that collects trace for non decoupled model and verifies it.
| _test_non_decoupled_trace | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _test_bls_trace(self, headers=None):
"""
Helper function, that specifies expected parameters to evaluate trace,
collected from running 1 inference request for `bls_simple` model.
"""
expected_number_of_spans = 6
expected_counts = dict(
{
"c... |
Helper function, that specifies expected parameters to evaluate trace,
collected from running 1 inference request for `bls_simple` model.
| _test_bls_trace | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _test_ensemble_trace(self, headers=None):
"""
Helper function, that specifies expected parameters to evaluate trace,
collected from running 1 inference request for an
`ensemble_add_sub_int32_int32_int32` model.
"""
expected_number_of_spans = 4
expected_counts ... |
Helper function, that specifies expected parameters to evaluate trace,
collected from running 1 inference request for an
`ensemble_add_sub_int32_int32_int32` model.
| _test_ensemble_trace | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_http_trace_simple_model(self):
"""
Tests trace, collected from executing one inference request
for a `simple` model and HTTP client.
"""
triton_client_http = httpclient.InferenceServerClient(
"localhost:8000", verbose=True
)
inputs = prepare_d... |
Tests trace, collected from executing one inference request
for a `simple` model and HTTP client.
| test_http_trace_simple_model | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_http_trace_simple_model_context_propagation(self):
"""
Tests trace, collected from executing one inference request
for a `simple` model, HTTP client and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
"""
triton_client_h... |
Tests trace, collected from executing one inference request
for a `simple` model, HTTP client and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
| test_http_trace_simple_model_context_propagation | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_grpc_trace_simple_model(self):
"""
Tests trace, collected from executing one inference request
for a `simple` model and GRPC client.
"""
triton_client_grpc = grpcclient.InferenceServerClient(
"localhost:8001", verbose=True
)
inputs = prepare_d... |
Tests trace, collected from executing one inference request
for a `simple` model and GRPC client.
| test_grpc_trace_simple_model | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_grpc_trace_all_input_required_model_cancel(self):
"""
Tests trace, collected from executing one inference request and cancelling the request
for a model and GRPC client. Expects only 2 GRPC stage events
"""
triton_client_grpc = grpcclient.InferenceServerClient(
... |
Tests trace, collected from executing one inference request and cancelling the request
for a model and GRPC client. Expects only 2 GRPC stage events
| test_grpc_trace_all_input_required_model_cancel | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_grpc_trace_model_cancel_in_queue(self):
"""
Tests trace, collected from executing one inference request and cancelling the request
for a model and GRPC client while the request is in queue. Expects 0 compute stage traces
"""
model_name = self.cancel_queue_model_name
... |
Tests trace, collected from executing one inference request and cancelling the request
for a model and GRPC client while the request is in queue. Expects 0 compute stage traces
| test_grpc_trace_model_cancel_in_queue | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_non_decoupled(self):
"""
Tests trace, collected from executing one inference request of non decoupled model.
"""
inputs = [
grpcclient.InferInput("IN", [1], "INT32").set_data_from_numpy(
self.input_data["IN"]
),
grpcclient.Infe... |
Tests trace, collected from executing one inference request of non decoupled model.
| test_non_decoupled | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_grpc_trace_simple_model_context_propagation(self):
"""
Tests trace, collected from executing one inference request
for a `simple` model, GRPC client and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
"""
triton_client_g... |
Tests trace, collected from executing one inference request
for a `simple` model, GRPC client and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
| test_grpc_trace_simple_model_context_propagation | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_streaming_grpc_trace_simple_model(self):
"""
Tests trace, collected from executing one inference request
for a `simple` model and GRPC streaming client.
"""
triton_client_grpc = grpcclient.InferenceServerClient(
"localhost:8001", verbose=True
)
... |
Tests trace, collected from executing one inference request
for a `simple` model and GRPC streaming client.
| test_streaming_grpc_trace_simple_model | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_streaming_grpc_trace_simple_model_context_propagation(self):
"""
Tests trace, collected from executing one inference request
for a `simple` model, GRPC streaming client and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
"""
... |
Tests trace, collected from executing one inference request
for a `simple` model, GRPC streaming client and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
| test_streaming_grpc_trace_simple_model_context_propagation | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_http_trace_bls_model_context_propagation(self):
"""
Tests trace, collected from executing one inference request
for a `bls_simple` model, HTTP client and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
"""
send_bls_reque... |
Tests trace, collected from executing one inference request
for a `bls_simple` model, HTTP client and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
| test_http_trace_bls_model_context_propagation | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_http_trace_ensemble_model(self):
"""
Tests trace, collected from executing one inference request
for a `ensemble_add_sub_int32_int32_int32` model and HTTP client.
"""
triton_client_http = httpclient.InferenceServerClient(
"localhost:8000", verbose=True
... |
Tests trace, collected from executing one inference request
for a `ensemble_add_sub_int32_int32_int32` model and HTTP client.
| test_http_trace_ensemble_model | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_http_trace_ensemble_model_context_propagation(self):
"""
Tests trace, collected from executing one inference request
for a `ensemble_add_sub_int32_int32_int32` model, HTTP client
and context propagation, i.e. client specifies OTel headers,
defined in `self.client_headers... |
Tests trace, collected from executing one inference request
for a `ensemble_add_sub_int32_int32_int32` model, HTTP client
and context propagation, i.e. client specifies OTel headers,
defined in `self.client_headers`.
| test_http_trace_ensemble_model_context_propagation | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_sagemaker_invocation_trace_simple_model_context_propagation(self):
"""
Tests trace, collected from executing one inference request
for a `simple` model, SageMaker (invocations) and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
... |
Tests trace, collected from executing one inference request
for a `simple` model, SageMaker (invocations) and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
| test_sagemaker_invocation_trace_simple_model_context_propagation | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_sagemaker_invoke_trace_simple_model_context_propagation(self):
"""
Tests trace, collected from executing one inference request
for a `simple` model, SageMaker (invoke) and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
"""
... |
Tests trace, collected from executing one inference request
for a `simple` model, SageMaker (invoke) and context propagation,
i.e. client specifies OTel headers, defined in `self.client_headers`.
| test_sagemaker_invoke_trace_simple_model_context_propagation | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_trace_context_exposed_to_pbe(self):
"""
Tests trace context, propagated to python backend.
"""
triton_client_http = httpclient.InferenceServerClient(
"localhost:8000", verbose=True
)
expect_none = np.array([False], dtype=bool)
inputs = httpcli... |
Tests trace context, propagated to python backend.
| test_trace_context_exposed_to_pbe | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def test_custom_backend_tracing(self):
"""
Tests custom activities reported from identity backend.
"""
input0_ = np.array([[4]], dtype=np.int32)
with httpclient.InferenceServerClient("localhost:8000", verbose=True) as client:
inputs = []
inputs.append(http... |
Tests custom activities reported from identity backend.
| test_custom_backend_tracing | python | triton-inference-server/server | qa/L0_trace/opentelemetry_unittest.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trace/opentelemetry_unittest.py | BSD-3-Clause |
def _preprocess(self, img, dtype):
"""
Pre-process an image to meet the size and type
requirements specified by the parameters.
"""
sample_img = img.convert("RGB")
resized_img = sample_img.resize((224, 224), Image.BILINEAR)
resized = np.array(resized_img)
... |
Pre-process an image to meet the size and type
requirements specified by the parameters.
| _preprocess | python | triton-inference-server/server | qa/L0_trt_dla/dla_test.py | https://github.com/triton-inference-server/server/blob/master/qa/L0_trt_dla/dla_test.py | BSD-3-Clause |
def auto_complete_config(auto_complete_model_config):
"""
The body of this model doesn't matter. The main purpose of this model is
to test correct handling of Python errors in the `auto_complete_config`
function.
"""
input0 = {"name": "INPUT0", "data_type": "TYPE_FP32", "... |
The body of this model doesn't matter. The main purpose of this model is
to test correct handling of Python errors in the `auto_complete_config`
function.
| auto_complete_config | python | triton-inference-server/server | qa/python_models/auto_complete_error/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/auto_complete_error/model.py | BSD-3-Clause |
def _get_gpu_bls_outputs(self, input0_pb, input1_pb, is_decoupled):
"""
This function is created to test that the DLPack container works
properly when the inference response and outputs go out of scope.
"""
infer_request = pb_utils.InferenceRequest(
model_name="dlpack... |
This function is created to test that the DLPack container works
properly when the inference response and outputs go out of scope.
| _get_gpu_bls_outputs | python | triton-inference-server/server | qa/python_models/bls/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/bls/model.py | BSD-3-Clause |
def execute(self, requests):
"""Identity model in Python backend that works with GPU and CPU
tensors."""
responses = []
for request in requests:
input_tensor = pb_utils.get_input_tensor_by_name(request, "INPUT0")
out_tensor = pb_utils.Tensor.from_dlpack(
... | Identity model in Python backend that works with GPU and CPU
tensors. | execute | python | triton-inference-server/server | qa/python_models/dlpack_identity/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/dlpack_identity/model.py | BSD-3-Clause |
def execute(self, requests):
"""
Tests returning invalid responses in execute request.
"""
self._i += 1
i = self._i
if i % 2 == 0:
return None
else:
return [None] * len(requests) |
Tests returning invalid responses in execute request.
| execute | python | triton-inference-server/server | qa/python_models/execute_return_error/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/execute_return_error/model.py | BSD-3-Clause |
def execute(self, requests):
"""
The body of this model doesn't matter. The main purpose of this model is
to test correct handling of Python errors in the `finalize` function.
"""
responses = []
for request in requests:
input_tensor = pb_utils.get_input_tensor... |
The body of this model doesn't matter. The main purpose of this model is
to test correct handling of Python errors in the `finalize` function.
| execute | python | triton-inference-server/server | qa/python_models/fini_error/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/fini_error/model.py | BSD-3-Clause |
def execute(self, requests):
"""
Identity model in Python backend with example BF16 and PyTorch usage.
"""
responses = []
for request in requests:
input_tensor = pb_utils.get_input_tensor_by_name(request, "INPUT0")
# Numpy does not support BF16, so use DL... |
Identity model in Python backend with example BF16 and PyTorch usage.
| execute | python | triton-inference-server/server | qa/python_models/identity_bf16/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/identity_bf16/model.py | BSD-3-Clause |
def execute(self, requests):
"""
This function counts the number of keys in the
"initialize" args argument to make sure that they are
correct.
"""
keys = [
"model_config",
"model_instance_kind",
"model_instance_name",
"model... |
This function counts the number of keys in the
"initialize" args argument to make sure that they are
correct.
| execute | python | triton-inference-server/server | qa/python_models/init_args/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/init_args/model.py | BSD-3-Clause |
def execute(self, requests):
"""
The main purpose of this function is to check whether undefined
variables are correctly handled in `initialize` function. The body of
this function is never called or used.
"""
responses = []
for request in requests:
in... |
The main purpose of this function is to check whether undefined
variables are correctly handled in `initialize` function. The body of
this function is never called or used.
| execute | python | triton-inference-server/server | qa/python_models/init_error/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/init_error/model.py | BSD-3-Clause |
def execute(self, requests):
"""Model supporting optional inputs. If the input is not provided, an
input tensor of size 1 containing scalar 5 will be used."""
responses = []
for request in requests:
input0_tensor = pb_utils.get_input_tensor_by_name(request, "INPUT0")
... | Model supporting optional inputs. If the input is not provided, an
input tensor of size 1 containing scalar 5 will be used. | execute | python | triton-inference-server/server | qa/python_models/optional/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/optional/model.py | BSD-3-Clause |
def auto_complete_config(auto_complete_model_config):
"""This function is called only once when loading the model assuming
the server was not started with `--disable-auto-complete-config`.
Parameters
----------
auto_complete_model_config : pb_utils.ModelConfig
An objec... | This function is called only once when loading the model assuming
the server was not started with `--disable-auto-complete-config`.
Parameters
----------
auto_complete_model_config : pb_utils.ModelConfig
An object containing the existing model configuration.
Returns
... | auto_complete_config | python | triton-inference-server/server | qa/python_models/python_based_backends/add_sub_backend/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/python_based_backends/add_sub_backend/model.py | BSD-3-Clause |
def initialize(self, args):
"""This function allows the model to initialize any state associated with this model.
Parameters
----------
args : dict
Both keys and values are strings. The dictionary keys and values are:
* model_config: A JSON string containing the mode... | This function allows the model to initialize any state associated with this model.
Parameters
----------
args : dict
Both keys and values are strings. The dictionary keys and values are:
* model_config: A JSON string containing the model configuration
* model_insta... | initialize | python | triton-inference-server/server | qa/python_models/python_based_backends/add_sub_backend/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/python_based_backends/add_sub_backend/model.py | BSD-3-Clause |
def execute(self, requests):
"""This function is called when an inference request is made
for this model.
Parameters
----------
requests : list
A list of pb_utils.InferenceRequest
Returns
-------
list
A list of pb_utils.InferenceRespo... | This function is called when an inference request is made
for this model.
Parameters
----------
requests : list
A list of pb_utils.InferenceRequest
Returns
-------
list
A list of pb_utils.InferenceResponse. The length of this list must
... | execute | python | triton-inference-server/server | qa/python_models/python_based_backends/add_sub_backend/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/python_based_backends/add_sub_backend/model.py | BSD-3-Clause |
def _get_instructions_from_request(self, request):
"""
Determine the execution instructions from the inputs. This test tries to examine
all the corner cases with using response sender.
Assumptions: The request batch size can be larger than one.
There are 5 inputs in the model t... |
Determine the execution instructions from the inputs. This test tries to examine
all the corner cases with using response sender.
Assumptions: The request batch size can be larger than one.
There are 5 inputs in the model that control the model behavior:
* NUMBER_OF_RESPONSE... | _get_instructions_from_request | python | triton-inference-server/server | qa/python_models/response_sender/model_common.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/response_sender/model_common.py | BSD-3-Clause |
def execute(self, requests):
"""
This function is called on inference request.
It is derived from "create_tf_modelfile" in
common/gen_qa_sequence_models.py and maintains
a true accumulator when the max batch size is 0
"""
output_dtype = self.output_dtype
... |
This function is called on inference request.
It is derived from "create_tf_modelfile" in
common/gen_qa_sequence_models.py and maintains
a true accumulator when the max batch size is 0
| execute | python | triton-inference-server/server | qa/python_models/sequence_int32/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/sequence_int32/model.py | BSD-3-Clause |
def execute(self, requests):
"""
This model ensures that errors in the execute function are properly
handles.
"""
responses = []
for request in requests:
input_tensor = pb_utils.get_input_tensor_by_name(request, "IN")
out_tensor = pb_utils.Tensor("... |
This model ensures that errors in the execute function are properly
handles.
| execute | python | triton-inference-server/server | qa/python_models/wrong_model/model.py | https://github.com/triton-inference-server/server/blob/master/qa/python_models/wrong_model/model.py | BSD-3-Clause |
def insert_after(regex: str) -> Callable[[str], str]:
"""
Builds a callback that will insert a provided header after
the specified regular expression. If the expression is not
found in the file contents, the header will be inserted at the
beginning of the file.
Args:
regex: The regular ... |
Builds a callback that will insert a provided header after
the specified regular expression. If the expression is not
found in the file contents, the header will be inserted at the
beginning of the file.
Args:
regex: The regular expression to match.
Returns:
A callable that ca... | insert_after | python | triton-inference-server/server | tools/add_copyright.py | https://github.com/triton-inference-server/server/blob/master/tools/add_copyright.py | BSD-3-Clause |
def copy_file(
src_file: str,
dst_dir: str,
) -> None:
"""Copy a file to the destination directory.
Args:
src_file: file to be copied
dst_dir: destination directory
"""
dest_dir_path = os.path.join(dst_dir, os.path.dirname(src_file))
os.makedirs(dest_dir_path, exist_ok=True)
shutil.copy(sr... | Copy a file to the destination directory.
Args:
src_file: file to be copied
dst_dir: destination directory
| copy_file | python | jax-ml/jax | build_wheel.py | https://github.com/jax-ml/jax/blob/master/build_wheel.py | Apache-2.0 |
def prepare_srcs(deps: list[str], srcs_dir: str) -> None:
"""Filter the sources and copy them to the destination directory.
Args:
deps: a list of paths to files.
srcs_dir: target directory where files are copied to.
"""
for file in deps:
if not (
file.startswith("bazel-out")
or fil... | Filter the sources and copy them to the destination directory.
Args:
deps: a list of paths to files.
srcs_dir: target directory where files are copied to.
| prepare_srcs | python | jax-ml/jax | build_wheel.py | https://github.com/jax-ml/jax/blob/master/build_wheel.py | Apache-2.0 |
def required_devices(num_devices_required):
"""Helper to skip benchmarks that require more devices."""
def helper1(f):
@functools.wraps(f)
def helper2(state):
if jax.device_count() < num_devices_required:
state.skip_with_error(f"requires {num_devices_required} devices")
return
re... | Helper to skip benchmarks that require more devices. | required_devices | python | jax-ml/jax | benchmarks/api_benchmark.py | https://github.com/jax-ml/jax/blob/master/benchmarks/api_benchmark.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.