TensorRT-LLMs/inference_request.html
2024-02-29 20:56:26 +08:00

301 lines
21 KiB
HTML

<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Inference Request &mdash; tensorrt_llm documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Multi-head, Multi-query and Group-query Attention" href="gpt_attention.html" />
<link rel="prev" title="The Batch Manager in TensorRT-LLM" href="batch_manager.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home">
tensorrt_llm
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="architecture.html">TensorRT-LLM Architecture</a></li>
<li class="toctree-l1"><a class="reference internal" href="gpt_runtime.html">C++ GPT Runtime</a></li>
<li class="toctree-l1"><a class="reference internal" href="batch_manager.html">The Batch Manager in TensorRT-LLM</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Inference Request</a></li>
<li class="toctree-l1"><a class="reference internal" href="gpt_attention.html">Multi-head, Multi-query and Group-query Attention</a></li>
<li class="toctree-l1"><a class="reference internal" href="precision.html">Numerical Precision</a></li>
<li class="toctree-l1"><a class="reference internal" href="build_from_source.html">Build from Source</a></li>
<li class="toctree-l1"><a class="reference internal" href="performance.html">Performance of TensorRT-LLM</a></li>
<li class="toctree-l1"><a class="reference internal" href="2023-05-19-how-to-debug.html">How to debug</a></li>
<li class="toctree-l1"><a class="reference internal" href="2023-05-17-how-to-add-a-new-model.html">How to add a new model</a></li>
<li class="toctree-l1"><a class="reference internal" href="graph-rewriting.html">Graph Rewriting Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="memory.html">Memory Usage of TensorRT-LLM</a></li>
<li class="toctree-l1"><a class="reference internal" href="new_workflow.html">New Workflow</a></li>
<li class="toctree-l1"><a class="reference internal" href="lora.html">Run gpt-2b + LoRA using GptManager / cpp runtime</a></li>
<li class="toctree-l1"><a class="reference internal" href="perf_best_practices.html">Best Practices for Tuning the Performance of TensorRT-LLM</a></li>
<li class="toctree-l1"><a class="reference internal" href="performance_analysis.html">Performance Analysis of TensorRT-LLM</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Python API</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="python-api/tensorrt_llm.layers.html">Layers</a></li>
<li class="toctree-l1"><a class="reference internal" href="python-api/tensorrt_llm.functional.html">Functionals</a></li>
<li class="toctree-l1"><a class="reference internal" href="python-api/tensorrt_llm.models.html">Models</a></li>
<li class="toctree-l1"><a class="reference internal" href="python-api/tensorrt_llm.plugin.html">Plugin</a></li>
<li class="toctree-l1"><a class="reference internal" href="python-api/tensorrt_llm.quantization.html">Quantization</a></li>
<li class="toctree-l1"><a class="reference internal" href="python-api/tensorrt_llm.runtime.html">Runtime</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="_cpp_gen/runtime.html">Runtime</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Blogs</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="blogs/H100vsA100.html">H100 has 4.6x A100 Performance in TensorRT-LLM, achieving 10,000 tok/s at 100ms to first token</a></li>
<li class="toctree-l1"><a class="reference internal" href="blogs/H200launch.html">H200 achieves nearly 12,000 tokens/sec on Llama2-13B with TensorRT-LLM</a></li>
<li class="toctree-l1"><a class="reference internal" href="blogs/Falcon180B-H200.html">Falcon-180B on a single H200 GPU with INT4 AWQ, and 6.7x faster Llama-70B over A100</a></li>
<li class="toctree-l1"><a class="reference internal" href="blogs/quantization-in-TRT-LLM.html">Speed up inference with SOTA quantization techniques in TRT-LLM</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">tensorrt_llm</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Inference Request</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/inference_request.md.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="inference-request">
<h1>Inference Request<a class="headerlink" href="#inference-request" title="Link to this heading"></a></h1>
<p>The main class to describe requests to <code class="docutils literal notranslate"><span class="pre">GptManager</span></code> is <code class="docutils literal notranslate"><span class="pre">InferenceRequest</span></code>. This is structured as a map of tensors and a <code class="docutils literal notranslate"><span class="pre">uint64_t</span> <span class="pre">requestId</span></code>.
The mandatory tensors to create a valid <code class="docutils literal notranslate"><span class="pre">InferenceRequest</span></code> object are described below. Sampling Config params are documented in more detail <a class="reference internal" href="gpt_runtime.html#sampling-parameters"><span class="std std-ref">here</span></a>, and descriptions are omitted in the table:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head text-center"><p>Name</p></th>
<th class="head text-center"><p>Shape</p></th>
<th class="head text-center"><p>Type</p></th>
<th class="head text-center"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">request_output_len</span></code></p></td>
<td class="text-center"><p>[1,1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>Max number of output tokens</p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">input_ids</span></code></p></td>
<td class="text-center"><p>[1, num_input_tokens]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>Tensor of input tokens</p></td>
</tr>
</tbody>
</table>
<p>Optional tensors that can be supplied to <code class="docutils literal notranslate"><span class="pre">InferenceRequest</span></code> are shown below. Default values, where applicable are specified.:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head text-center"><p>Name</p></th>
<th class="head text-center"><p>Shape</p></th>
<th class="head text-center"><p>Type</p></th>
<th class="head text-center"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">streaming</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">bool</span></code></p></td>
<td class="text-center"><p>(Default=<code class="docutils literal notranslate"><span class="pre">false</span></code>). When <code class="docutils literal notranslate"><span class="pre">true</span></code>, stream out tokens as they are generated. When <code class="docutils literal notranslate"><span class="pre">false</span></code> return only when the full generation has completed.</p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">beam_width</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>(Default=1) Beam width for this request; set to 1 for greedy sampling</p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">temperature</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">temperature</span></code></p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">runtime_top_k</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">topK</span></code></p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">runtime_top_p</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">topP</span></code></p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">len_penalty</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">lengthPenalty</span></code></p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">repetition_penalty</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">repetitionPenalty</span></code></p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">min_length</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">minLength</span></code></p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">presence_penalty</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">presencePenalty</span></code></p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">frequency_penalty</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">frequencyPenalty</span></code></p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">random_seed</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">uint64_t</span></code></p></td>
<td class="text-center"><p>Sampling Config param: <code class="docutils literal notranslate"><span class="pre">randomSeed</span></code></p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">end_id</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>End token Id</p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">pad_id</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>Pad token Id</p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">embedding_bias</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td class="text-center"><p>Embedding bias</p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">bad_words_list</span></code></p></td>
<td class="text-center"><p>[2, num_bad_words]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>Bad words list</p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">stop_words_list</span></code></p></td>
<td class="text-center"><p>[2, num_stop_words]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>Stop words list</p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">prompt_embedding_table</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float16</span></code></p></td>
<td class="text-center"><p>P-tuning prompt embedding table</p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">prompt_vocab_size</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>P-tuning prompt vocab size</p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">lora_weights</span></code></p></td>
<td class="text-center"><p>[ num_lora_modules_layers, D x Hi + Ho x D ]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">float</span></code> (model data type)</p></td>
<td class="text-center"><p>weights for a lora adapter. see <a class="reference internal" href="lora.html#lora-tensor-format-details"><span class="std std-ref">lora docs</span></a> for more details.</p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">lora_config</span></code></p></td>
<td class="text-center"><p>[3]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>lora configuration tensor. <code class="docutils literal notranslate"><span class="pre">[</span> <span class="pre">module_id,</span> <span class="pre">layer_idx,</span> <span class="pre">adapter_size</span> <span class="pre">(D</span> <span class="pre">aka</span> <span class="pre">R</span> <span class="pre">value)</span> <span class="pre">]</span></code> see <a class="reference internal" href="lora.html#lora-tensor-format-details"><span class="std std-ref">lora docs</span></a> for more details.</p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">return_log_probs</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">bool</span></code></p></td>
<td class="text-center"><p>When <code class="docutils literal notranslate"><span class="pre">true</span></code>, include log probs in the output</p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">return_context_logits</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">bool</span></code></p></td>
<td class="text-center"><p>When <code class="docutils literal notranslate"><span class="pre">true</span></code>, include context logits in the output</p></td>
</tr>
<tr class="row-even"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">return_generation_logits</span></code></p></td>
<td class="text-center"><p>[1]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">bool</span></code></p></td>
<td class="text-center"><p>When <code class="docutils literal notranslate"><span class="pre">true</span></code>, include generation logits in the output</p></td>
</tr>
<tr class="row-odd"><td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">draft_input_ids</span></code></p></td>
<td class="text-center"><p>[num_draft_tokens]</p></td>
<td class="text-center"><p><code class="docutils literal notranslate"><span class="pre">int32_t</span></code></p></td>
<td class="text-center"><p>Draft tokens to be leveraged in generation phase to potentially generate multiple output tokens in one inflight batching iteration</p></td>
</tr>
</tbody>
</table>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="batch_manager.html" class="btn btn-neutral float-left" title="The Batch Manager in TensorRT-LLM" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="gpt_attention.html" class="btn btn-neutral float-right" title="Multi-head, Multi-query and Group-query Attention" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2023, NVidia.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>