Skip to content

Commit 52af25f

Browse files
committed
init doc
Signed-off-by: Superjomn <[email protected]>
1 parent 4adde41 commit 52af25f

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

docs/source/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ Welcome to TensorRT-LLM's Documentation!
150150
blogs/tech_blog/blog1_Pushing_Latency_Boundaries_Optimizing_DeepSeek-R1_Performance_on_NVIDIA_B200_GPUs.md
151151
blogs/tech_blog/blog2_DeepSeek_R1_MTP_Implementation_and_Optimization.md
152152

153+
.. toctree::
154+
:maxdepth: 2
155+
:caption: LLM with TensorRT Engine
156+
:hidden:
157+
158+
legacy/tensorrt_quickstart.md
153159

154160
Indices and tables
155161
==================
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# LLM API with TensorRT Engine
2+
A simple inference example with TinyLlama using the LLM API:
3+
4+
```{literalinclude} ../../examples/llm-api/_tensorrt_engine/quickstart_example.py
5+
:language: python
6+
:linenos:
7+
```
8+
9+
For more advanced usage including distributed inference, multimodal, and speculative decoding, please refer to this [README](../../../examples/llm-api/README.md).
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from tensorrt_llm import LLM, SamplingParams
2+
3+
4+
def main():
5+
6+
# Model could accept HF model name, a path to local HF model,
7+
# or TensorRT Model Optimizer's quantized checkpoints like nvidia/Llama-3.1-8B-Instruct-FP8 on HF.
8+
llm = LLM(model="TinyLlama/TinyLlama-1.1B-Chat-v1.0")
9+
10+
# Sample prompts.
11+
prompts = [
12+
"Hello, my name is",
13+
"The capital of France is",
14+
"The future of AI is",
15+
]
16+
17+
# Create a sampling params.
18+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
19+
20+
for output in llm.generate(prompts, sampling_params):
21+
print(
22+
f"Prompt: {output.prompt!r}, Generated text: {output.outputs[0].text!r}"
23+
)
24+
25+
# Got output like
26+
# Prompt: 'Hello, my name is', Generated text: '\n\nJane Smith. I am a student pursuing my degree in Computer Science at [university]. I enjoy learning new things, especially technology and programming'
27+
# Prompt: 'The president of the United States is', Generated text: 'likely to nominate a new Supreme Court justice to fill the seat vacated by the death of Antonin Scalia. The Senate should vote to confirm the'
28+
# Prompt: 'The capital of France is', Generated text: 'Paris.'
29+
# Prompt: 'The future of AI is', Generated text: 'an exciting time for us. We are constantly researching, developing, and improving our platform to create the most advanced and efficient model available. We are'
30+
31+
32+
if __name__ == '__main__':
33+
main()

examples/llm-api/quickstart_example.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
from tensorrt_llm import LLM, SamplingParams
1+
from tensorrt_llm import BuildConfig, SamplingParams
2+
from tensorrt_llm._tensorrt_engine import LLM # NOTE the change
23

34

45
def main():
56

7+
build_config = BuildConfig()
8+
build_config.max_batch_size = 256
9+
build_config.max_num_tokens = 1024
10+
611
# Model could accept HF model name, a path to local HF model,
712
# or TensorRT Model Optimizer's quantized checkpoints like nvidia/Llama-3.1-8B-Instruct-FP8 on HF.
8-
llm = LLM(model="TinyLlama/TinyLlama-1.1B-Chat-v1.0")
13+
llm = LLM(model="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
14+
build_config=build_config)
915

1016
# Sample prompts.
1117
prompts = [

0 commit comments

Comments
 (0)