triton-inference-server / tensorrtllm_backend

The Triton TensorRT-LLM Backend
Apache License 2.0
700 stars 103 forks source link

Triton server no response when setting end_id in request #100

Open CaesarWWK opened 1 year ago

CaesarWWK commented 1 year ago

I used a fine-tuned llama2 model and built it with awq-int4, tp_size=4 max_input_length=8000, max_output_length=8000with tensorrt-llm. The model runs perfectly under tensorrt-llm.

When I use Triton, I set end_id=2, the model performs well when setting max_tokens arounds 200. But when I switch to a higher max_tokens such as 800, the model won't stop after receiving a request and further block all following requests.

I checked gpu usage, I found that only 1 gpu's utilization drop to 0%, all other gpus are still at 100% utilization, which is very wired.

One of my assumption is that, since tensorrt-llm has a bug in using end_id to stop llama model from generating new tokens, triton may also inherit the bug.

Another problem is that, since tensorrt-llm's output is filled with end_ids, it does not affect the output speed(like the inference time for generating 800 tokens does not differ much than the inference time for generating 2000 tokens if the case that the number of tokens except the end_id tokens are roughly the same ). However in the triton case, it actually affect the output speed.

I attach my request code in below.

import time
import requests

prompt = "Question:xxx\n\nAnswer:"
url = 'http://localhost:8000/v2/models/ensemble/generate'
data = dict(
    text_input=prompt,
    parameters=dict(
        max_tokens=2000,
        bad_words=[""],
        stop_words=["\\n"],
        # test="",
        # end_id=2
    )
)
for i in range(10):
    t0 = time.time()
    response = requests.post(url=url, json=data)
    t1 = time.time()
    print(response.json())
    print(t1 - t0)

the config of my model

{
  "builder_config": {
    "fp8": false,
    "hidden_act": "silu",
    "hidden_size": 5120,
    "int8": false,
    "max_batch_size": 8,
    "max_input_len": 8000,
    "max_num_tokens": null,
    "max_output_len": 8000,
    "max_position_embeddings": 16384,
    "name": "llama",
    "num_heads": 40,
    "num_kv_heads": 40,
    "num_layers": 40,
    "parallel_build": false,
    "pipeline_parallel": 1,
    "precision": "float16",
    "quant_mode": 33,
    "tensor_parallel": 4,
    "use_refit": false,
    "vocab_size": 55296
  },
  "plugin_config": {
    "attention_qk_half_accumulation": false,
    "bert_attention_plugin": false,
    "context_fmha_type": 1,
    "gemm_plugin": "float16",
    "gpt_attention_plugin": "float16",
    "identity_plugin": false,
    "layernorm_plugin": false,
    "layernorm_quantization_plugin": false,
    "lookup_plugin": false,
    "nccl_plugin": "float16",
    "paged_kv_cache": false,
    "quantize_per_token_plugin": false,
    "quantize_tensor_plugin": false,
    "remove_input_padding": true,
    "rmsnorm_plugin": false,
    "rmsnorm_quantization_plugin": false,
    "smooth_quant_gemm_plugin": false,
    "tokens_per_block": 0,
    "use_custom_all_reduce": false,
    "weight_only_groupwise_quant_matmul_plugin": "float16",
    "weight_only_quant_matmul_plugin": false
  }
}
schetlur-nv commented 12 months ago

Hey @CaesarWWK thanks for the issue. Would it be possible to share your config.pbtxt file for the Triton server too?

CaesarWWK commented 12 months ago

Hey @CaesarWWK thanks for the issue. Would it be possible to share your config.pbtxt file for the Triton server too? Hi, sorry not sure what you mean my config.pbtxt file for the server, I only modified ensemble, preprocess,postprocess,tensorrt_llm config.pbtxt files. I shared my tensorrt_llm's config above, and I attach others in below. If you need any other files, just ask me. ensemble/config.pbtxt

name: "ensemble"
platform: "ensemble"
max_batch_size: 128
input [
{
name: "text_input"
data_type: TYPE_STRING
dims: [ -1 ]
},
{
name: "max_tokens"
data_type: TYPE_UINT32
dims: [ -1 ]
},
{
name: "bad_words"
data_type: TYPE_STRING
dims: [ -1 ]
},
{
name: "stop_words"
data_type: TYPE_STRING
dims: [ -1 ]
},
{
name: "end_id"
data_type: TYPE_UINT32
dims: [ 1 ]
optional: true
},
{
name: "pad_id"
data_type: TYPE_UINT32
dims: [ 1 ]
optional: true
},
{
name: "top_k"
data_type: TYPE_UINT32
dims: [ 1 ]
optional: true
},
{
name: "top_p"
data_type: TYPE_FP32
dims: [ 1 ]
optional: true
},
{
name: "temperature"
data_type: TYPE_FP32
dims: [ 1 ]
optional: true
},
{
name: "length_penalty"
data_type: TYPE_FP32
dims: [ 1 ]
optional: true
},
{
name: "repetition_penalty"
data_type: TYPE_FP32
dims: [ 1 ]
optional: true
},
{
name: "min_length"
data_type: TYPE_UINT32
dims: [ 1 ]
optional: true
},
{
name: "presence_penalty"
data_type: TYPE_FP32
dims: [ 1 ]
optional: true
},
{
name: "random_seed"
data_type: TYPE_UINT64
dims: [ 1 ]
optional: true
},
{
name: "beam_width"
data_type: TYPE_UINT32
dims: [ 1 ]
optional: true
},
{
name: "stream"
data_type: TYPE_BOOL
dims: [ 1 ]
optional: true
}
]
output [
{
name: "text_output"
data_type: TYPE_STRING
dims: [ -1, -1 ]
}
]
ensemble_scheduling {
step [
{
model_name: "preprocessing"
model_version: -1
input_map {
key: "QUERY"
value: "text_input"
}
input_map {
key: "REQUEST_OUTPUT_LEN"
value: "max_tokens"
}
input_map {
key: "BAD_WORDS_DICT"
value: "bad_words"
}
input_map {
key: "STOP_WORDS_DICT"
value: "stop_words"
}
output_map {
key: "REQUEST_INPUT_LEN"
value: "_REQUEST_INPUT_LEN"
}
output_map {
key: "INPUT_ID"
value: "_INPUT_ID"
}
output_map {
key: "REQUEST_OUTPUT_LEN"
value: "_REQUEST_OUTPUT_LEN"
}
},
{
model_name: "tensorrt_llm"
model_version: -1
input_map {
key: "input_ids"
value: "_INPUT_ID"
}
input_map {
key: "input_lengths"
value: "_REQUEST_INPUT_LEN"
}
input_map {
key: "request_output_len"
value: "_REQUEST_OUTPUT_LEN"
}
input_map {
key: "end_id"
value: "end_id"
}
input_map {
key: "pad_id"
value: "pad_id"
}
input_map {
key: "runtime_top_k"
value: "top_k"
}
input_map {
key: "runtime_top_p"
value: "top_p"
}
input_map {
key: "temperature"
value: "temperature"
}
input_map {
key: "len_penalty"
value: "length_penalty"
}
input_map {
key: "repetition_penalty"
value: "repetition_penalty"
}
input_map {
key: "min_length"
value: "min_length"
}
input_map {
key: "presence_penalty"
value: "presence_penalty"
}
input_map {
key: "random_seed"
value: "random_seed"
}
input_map {
key: "beam_width"
value: "beam_width"
}
input_map {
key: "streaming"
value: "stream"
}
output_map {
key: "output_ids"
value: "_TOKENS_BATCH"
}
},
{
model_name: "postprocessing"
model_version: -1
input_map {
key: "TOKENS_BATCH"
value: "_TOKENS_BATCH"
}
output_map {
key: "OUTPUT"
value: "text_output"
}
}
]
}

preprocess


# Copyright 2023, 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: "preprocessing" backend: "python" max_batch_size: 128 input [ { name: "QUERY" data_type: TYPE_STRING dims: [ -1 ] }, { name: "BAD_WORDS_DICT" data_type: TYPE_STRING dims: [ -1 ] }, { name: "STOP_WORDS_DICT" data_type: TYPE_STRING dims: [ -1 ] }, { name: "REQUEST_OUTPUT_LEN" data_type: TYPE_UINT32 dims: [ -1 ] } ] output [ { name: "INPUT_ID" data_type: TYPE_INT32 dims: [ -1 ] }, { name: "REQUEST_INPUT_LEN" data_type: TYPE_INT32 dims: [ 1 ] }, { name: "BAD_WORDS_IDS" data_type: TYPE_INT32 dims: [ 2, -1 ] }, { name: "STOP_WORDS_IDS" data_type: TYPE_INT32 dims: [ 2, -1 ] }, { name: "REQUEST_OUTPUT_LEN" data_type: TYPE_UINT32 dims: [ -1 ] } ]

parameters { key: "tokenizer_dir" value: { string_value: "/data/aigc/public/chinese-llama2-peft" } }

parameters { key: "tokenizer_type" value: { string_value: "llama" } }

instance_group [ { count: 1 kind: KIND_CPU } ]

postprocess

name: "postprocessing" backend: "python" max_batch_size: 128 input [ { name: "TOKENS_BATCH" data_type: TYPE_INT32 dims: [ -1, -1 ] } ] output [ { name: "OUTPUT" data_type: TYPE_STRING dims: [ -1, -1 ] } ]

parameters { key: "tokenizer_dir" value: { string_value: "/data/aigc/public/chinese-llama2-peft" } }

parameters { key: "tokenizer_type" value: { string_value: "llama" } }

instance_group [ { count: 1 kind: KIND_CPU } ]

schetlur-nv commented 10 months ago

@CaesarWWK can you try again with the latest code, we fixed some issues that may be related to this bug.