Llama 3 with TensorRT-LLM
Build an optimized inference engine for Llama 3.1 8B
This configuration builds an inference engine to serve Llama 3.1 8B on an A100 GPU. It is very similar to the configuration for any other Llama model, including fine-tuned variants.
Setup
See the end-to-end engine builder tutorial prerequisites for full setup instructions.
Make sure you have accessed the gated model on Hugging Face and set your hf_access_token
in your Baseten workspace secrets.
Please upgrade to the latest version of Truss with pip install --upgrade truss
before following this example.
Configuration
This is a well-rounded configuration that balances latency and throughput. It supports long sequence lengths for multi-step chat and has a batch size of 32 as thatβs reasonable for an eight-billion-parameter model on an A100 GPU. The model is served unquantized in fp16
.
Deployment
Usage
The input text prompt to guide the language modelβs generation.
One of prompt
XOR messages
is required.
A list of dictionaries representing the message history, typically used in conversational contexts.
One of prompt
XOR messages
is required.
The maximum number of tokens to generate in the output. Controls the length of the generated text.
The number of beams used in beam search. Maximum of 1
.
A penalty applied to repeated tokens to discourage the model from repeating the same words or phrases.
A penalty applied to tokens already present in the prompt to encourage the generation of new topics.
Controls the randomness of the output. Lower values make the output more deterministic, while higher values increase randomness.
A penalty applied to the length of the generated sequence to control verbosity. Higher values make the model favor shorter outputs.
The token ID that indicates the end of the generated sequence.
The token ID used for padding sequences to a uniform length.
Limits the sampling pool to the top k
tokens, ensuring the model only considers the most likely tokens at each step.
Applies nucleus sampling to limit the sampling pool to a cumulative probability p
, ensuring only the most likely tokens are considered.