# Copyright 2025, 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.

name: "tensorrt_llm"
backend: "python"

#######################################################
# The below config arguments are specific in model.yaml
# Please don't add it in config.pbtxt
#
# max_batch_size: 64
#
# model_transaction_policy {
#  decoupled: False
# }
#######################################################

instance_group [
  {
    count: 1
    kind : KIND_CPU
  }
]

input [
  {
    name: "text_input"
    data_type: TYPE_STRING
    dims: [ -1 ]
  },
  {
    name: "streaming"
    data_type: TYPE_BOOL
    dims: [ 1 ]
    optional: true
  },
  ## SamplingParams Arguments for Each Request ##
  {
    name: "sampling_param_best_of"
    data_type: TYPE_INT32
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_temperature"
    data_type: TYPE_FP32
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_top_k"
    data_type: TYPE_INT32
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_top_p"
    data_type: TYPE_FP32
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_frequency_penalty"
    data_type: TYPE_FP32
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_presence_penalty"
    data_type: TYPE_FP32
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_max_tokens"
    data_type: TYPE_INT32
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_stop"
    data_type: TYPE_STRING
    dims: [-1]
    optional: true
  },
  {
    name: "sampling_param_seed"
    data_type: TYPE_UINT64
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_exclude_input_from_output"
    data_type: TYPE_BOOL
    dims: [ 1 ]
    optional: true
  },
  {
    name: "sampling_param_return_perf_metrics"
    data_type: TYPE_BOOL
    dims: [ 1 ]
    optional: true
  },
  ## Arguments for Controlling Response Output Fields ##
  {
    name: "return_finish_reason"
    data_type: TYPE_BOOL
    dims: [1]
    optional: true
  },
  {
    name: "return_stop_reason"
    data_type: TYPE_BOOL
    dims: [1]
    optional: true
  },
  {
    name: "return_cumulative_logprob"
    data_type: TYPE_BOOL
    dims: [1]
    optional: true
  },
  {
    name: "stop"
    data_type: TYPE_BOOL
    dims: [ 1 ]
    optional: true
  }
]
###################################################################
# The below output parameters are arguments from LLM.RequestOutput
###################################################################
output [
  {
    name: "text_output"
    data_type: TYPE_STRING
    dims: [-1]
  },
  {
    name: "finish_reason"
    data_type: TYPE_STRING
    dims: [-1]
  },
  {
    name: "stop_reason"
    data_type: TYPE_STRING
    dims: [-1]
  },
  {
    name: "cumulative_logprob"
    data_type: TYPE_FP32
    dims: [-1]
  },
  {
    name: "kv_cache_reused_block"
    data_type: TYPE_INT32
    dims: [-1]
  },
  {
    name: "kv_cache_missed_block"
    data_type: TYPE_INT32
    dims: [-1]
  },
  {
    name: "kv_cache_alloc_new_blocks"
    data_type: TYPE_INT32
    dims: [-1]
  },
  {
    name: "kv_cache_alloc_total_blocks"
    data_type: TYPE_INT32
    dims: [-1]
  },
  {
    name: "kv_cache_hit_rate"
    data_type: TYPE_FP32
    dims: [-1]
  },
  {
    name: "arrival_time_ns"
    data_type: TYPE_INT64
    dims: [ 1 ]
  },
  {
    name: "first_scheduled_time_ns"
    data_type: TYPE_INT64
    dims: [ 1 ]
  },
  {
    name: "first_token_time_ns"
    data_type: TYPE_INT64
    dims: [ 1 ]
  },
  {
    name: "last_token_time_ns"
    data_type: TYPE_INT64
    dims: [ 1 ]
  },
  {
    name: "acceptance_rate"
    data_type: TYPE_FP32
    dims: [ 1 ]
  },
  {
    name: "total_accepted_draft_tokens"
    data_type: TYPE_INT32
    dims: [ 1 ]
  },
  {
    name: "total_draft_tokens"
    data_type: TYPE_INT32
    dims: [ 1 ]
  }
]
