-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Add doc and CI for TRTLLM #2799
Merged
+114
−2
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# TensorRT-LLM backend | ||
|
||
The NVIDIA TensorRT-LLM (TRTLLM) backend is a high-performance backend for LLMs | ||
that uses NVIDIA's TensorRT library for inference acceleration. | ||
It makes use of specific optimizations for NVIDIA GPUs, such as custom kernels. | ||
|
||
To use the TRTLLM backend you need to compile `engines` for the models you want to use. | ||
Each `engine` must be compiled on the same GPU architecture that you will use for inference. | ||
|
||
## Supported models | ||
|
||
Check the [support matrix](https://nvidia.github.io/TensorRT-LLM/reference/support-matrix.html) to see which models are | ||
supported. | ||
|
||
## Compiling engines | ||
|
||
You can use [Optimum-NVIDIA](https://github.com/huggingface/optimum-nvidia) to compile engines for the models you | ||
want to use. | ||
|
||
```bash | ||
MODEL_NAME="meta-llama/Llama-3.1-8B-Instruct" | ||
|
||
# Install huggingface_cli | ||
python -m pip install huggingface-cli[hf_transfer] | ||
|
||
# Login to the Hugging Face Hub | ||
huggingface-cli login | ||
|
||
# Create a directory to store the model | ||
mkdir -p /tmp/models/$MODEL_NAME | ||
|
||
# Create a directory to store the compiled engine | ||
mkdir -p /tmp/engines/$MODEL_NAME | ||
|
||
# Download the model | ||
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download --local-dir /tmp/models/$MODEL_NAME $MODEL_NAME | ||
|
||
# Compile the engine using Optimum-NVIDIA | ||
docker run \ | ||
--rm \ | ||
-it \ | ||
--gpus=1 \ | ||
-v /tmp/models/$MODEL_NAME:/model \ | ||
-v /tmp/engines/$MODEL_NAME:/engine \ | ||
huggingface/optimum-nvidia \ | ||
optimum-cli export trtllm \ | ||
--tp=1 \ | ||
--pp=1 \ | ||
--max-batch-size=128 \ | ||
--max-input-length 4096 \ | ||
--max-output-length 8192 \ | ||
--max-beams-width=1 \ | ||
--destination /engine \ | ||
$MODEL_NAME | ||
``` | ||
|
||
Your compiled engine will be saved in the `/tmp/engines/$MODEL_NAME` directory. | ||
|
||
## Using the TRTLLM backend | ||
|
||
Run TGI-TRTLLM Docker image with the compiled engine: | ||
|
||
```bash | ||
docker run \ | ||
--gpus 1 \ | ||
-it \ | ||
--rm \ | ||
-p 3000:3000 \ | ||
-e MODEL=$MODEL_NAME \ | ||
-e PORT=3000 \ | ||
-e HF_TOKEN='hf_XXX' \ | ||
-v /tmp/engines/$MODEL_NAME:/data \ | ||
ghcr.io/huggingface/text-generation-inference:latest-trtllm \ | ||
--executor-worker executorWorker \ | ||
--model-id /data/$MODEL_NAME | ||
``` | ||
|
||
## Development | ||
|
||
To develop TRTLLM backend, you can use [dev containers](https://containers.dev/) located in | ||
`.devcontainer` directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Multi-backend support | ||
|
||
TGI (Text Generation Inference) offers flexibility by supporting multiple backends for serving large language models (LLMs). | ||
With multi-backend support, you can choose the backend that best suits your needs, | ||
whether you prioritize performance, ease of use, or compatibility with specific hardware. API interaction with | ||
TGI remains consistent across backends, allowing you to switch between them seamlessly. | ||
|
||
**Supported backends:** | ||
* **TGI CUDA backend**: This high-performance backend is optimized for NVIDIA GPUs and serves as the default option | ||
within TGI. Developed in-house, it boasts numerous optimizations and is used in production by various projects, including those by Hugging Face. | ||
* **[TGI TRTLLM backend](./backends/trtllm)**: This backend leverages NVIDIA's TensorRT library to accelerate LLM inference. | ||
It utilizes specialized optimizations and custom kernels for enhanced performance. | ||
However, it requires a model-specific compilation step for each GPU architecture. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't enable the integration tests, only the build step.