**⚠️ Temporary fix to get Mixtral 8x22B with 64K context. If you are on SynapseAI 1.16, check out 1.16 of this repo
See this guide for setup: Mixtral 8x22B on Gaudi 2: A Comprehensive Setup Guide For optimizations Optimizing Mixtral 8x22b for Gaudi 2
To use 🤗 text-generation-inference on Habana Gaudi/Gaudi2, follow these steps:
docker pull ghcr.io/huggingface/tgi-gaudi:1.2.1
[!NOTE] Alternatively, you can build the Docker image using the
Dockerfilelocated in this folder with:docker build -t tgi_gaudi .
Launch a local server instance:
i. On 1 Gaudi/Gaudi2 card
model=meta-llama/Llama-2-7b-hf
volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
docker run -p 8080:80 -v $volume:/data --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --ipc=host ghcr.io/huggingface/tgi-gaudi:1.2.1 --model-id $model
For gated models such as LLama or StarCoder, you will have to pass
-e HUGGING_FACE_HUB_TOKEN=<token>to thedocker runcommand above with a valid Hugging Face Hub read token.
ii. On 8 Gaudi/Gaudi2 cards:
model=meta-llama/Llama-2-70b-hf
volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
docker run -p 8080:80 -v $volume:/data --runtime=habana -e PT_HPU_ENABLE_LAZY_COLLECTIVES=true -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --ipc=host ghcr.io/huggingface/tgi-gaudi:1.2.1 --model-id $model --sharded true --num-shard 8
You can then send a simple request:
curl 127.0.0.1:8080/generate \
-X POST \
-d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":32}}' \
-H 'Content-Type: application/json'
To run static benchmark test, please refer to TGI's benchmark tool.
To run it on the same machine, you can do the following:
docker exec -it <docker name> bash , pick the docker started from step 2 using docker pstext-generation-benchmark -t <model-id> , pass the model-id from docker run commandTo run continuous batching test, please refer to examples.
Maximum sequence length is controlled by two arguments:
--max-input-length is the maximum possible input prompt length. Default value is 1024.--max-total-tokens is the maximum possible total length of the sequence (input and output). Default value is 2048.Maximum batch size is controlled by two arguments:
--max-prefill-total-tokens as bs * max-input-length, where bs is your expected maximum prefill batch size.--max-batch-total-tokens as bs * max-total-tokens, where bs is your expected maximum decode batch size.BATCH_BUCKET_SIZE and PREFILL_BATCH_BUCKET_SIZE.To ensure greatest performance results, at the begginging of each server run, warmup is performed. It's designed to cover major recompilations while using HPU Graphs. It creates queries with all possible input shapes, based on provided parameters (described in this section) and runs basic TGI operations on them (prefill, decode, concatenate).
Except those already mentioned, there are other parameters that need to be properly adjusted to improve performance or memory usage:
PAD_SEQUENCE_TO_MULTIPLE_OF determines sizes of input legnth buckets. Since warmup creates several graphs for each bucket, it's important to adjust that value proportionally to input sequence length. Otherwise, some out of memory issues can be observed.ENABLE_HPU_GRAPH enables HPU graphs usage, which is crucial for performance results. Recommended value to keep is true .For more information and documentation about Text Generation Inference, checkout the README of the original repo.
TGI supports FP8 precision runs within the limits provided by Habana Quantization Toolkit. Models with FP8 can be ran by properly setting QUANT_CONFIG environment variable. Detailed instruction on how to use that variable can be found in Optimum Habana FP8 guide. Summarising that instruction in TGI cases:
QUANT_CONFIG=./quantization_config/maxabs_quant.json[!NOTE] Only models pointed in supported configurations are guaranteed to work with FP8
Additional hints to quantize model for TGI when using run_lm_eval.py:
--limit_hpu_graphs flag to save memory--batch_size , --max_new_tokens 512 and --max_input_tokens 512 In case of memory issues, lower those values--help for defining tasks/datasets)Not all features of TGI are currently supported as this is still a work in progress. Currently supported and validated configurations (other configurations are not guaranted to work or ensure reasonable performance):
| Model | Cards | Decode batch size | Dtype | Max input tokens | Max total tokens |
|---|---|---|---|---|---|
| LLaMA 70b | 8 | 128 | bfloat16/FP8 | 1024 | 2048 |
| LLaMA 7b | 1/8 | 16 | bfloat16/FP8 | 1024 | 2048 |
Other sequence lengths can be used with proportionally decreased/increased batch size (the higher sequence length, the lower batch size). Support for other models from Optimum Habana will be added successively.
| Name | Value(s) | Default | Description | Usage |
|---|---|---|---|---|
| ENABLE_HPU_GRAPH | True/False | True | Enable hpu graph or not | add -e in docker run command |
| LIMIT_HPU_GRAPH | True/False | False | Skip HPU graph usage for prefill to save memory, set to True for large sequence/decoding lengths(e.g. 300/212) | add -e in docker run command |
| BATCH_BUCKET_SIZE | integer | 8 | Batch size for decode operation will be rounded to the nearest multiple of this number. This limits the number of cached graphs | add -e in docker run command |
| PREFILL_BATCH_BUCKET_SIZE | integer | 4 | Batch size for prefill operation will be rounded to the nearest multiple of this number. This limits the number of cached graphs | add -e in docker run command |
| PAD_SEQUENCE_TO_MULTIPLE_OF | integer | 128 | For prefill operation, sequences will be padded to a multiple of provided value. | add -e in docker run command |
| SKIP_TOKENIZER_IN_TGI | True/False | False | Skip tokenizer for input/output processing | add -e in docker run command |
| WARMUP_ENABLED | True/False | True | Enable warmup during server initialization to recompile all graphs. This can increase TGI setup time. | add -e in docker run command |
| QUEUE_THRESHOLD_MS | integer | 120 | Controls the threshold beyond which the request are considered overdue and handled with priority. Shorter requests are prioritized otherwise. | add -e in docker run command |
To collect performance profiling, please set below environment variables:
| Name | Value(s) | Default | Description | Usage |
|---|---|---|---|---|
| PROF_WAITSTEP | integer | 0 | Control profile wait steps | add -e in docker run command |
| PROF_WARMUPSTEP | integer | 0 | Control profile warmup steps | add -e in docker run command |
| PROF_STEP | integer | 0 | Enable/disable profile, control profile active steps | add -e in docker run command |
| PROF_PATH | string | /tmp/hpu_profile | Define profile folder | add -e in docker run command |
| PROF_RANKS | string | 0 | Comma-separated list of ranks to profile | add -e in docker run command |
| PROF_RECORD_SHAPES | True/False | False | Control record_shapes option in the profiler | add -e in docker run command |
The license to use TGI on Habana Gaudi is the one of TGI: https://github.com/huggingface/text-generation-inference/blob/main/LICENSE
Please reach out to api-enterprise@huggingface.co if you have any question.
12 commits
1 commits
Python
76.7%
C++
11.8%
Cuda
6.7%
Rust
2.2%
**⚠️ Temporary fix to get Mixtral 8x22B with 64K context. If you are on SynapseAI 1.16, check out 1.16 of this repo
See this guide for setup: Mixtral 8x22B on Gaudi 2: A Comprehensive Setup Guide For optimizations Optimizing Mixtral 8x22b for Gaudi 2
To use 🤗 text-generation-inference on Habana Gaudi/Gaudi2, follow these steps:
docker pull ghcr.io/huggingface/tgi-gaudi:1.2.1
[!NOTE] Alternatively, you can build the Docker image using the
Dockerfilelocated in this folder with:docker build -t tgi_gaudi .
Launch a local server instance:
i. On 1 Gaudi/Gaudi2 card
model=meta-llama/Llama-2-7b-hf
volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
docker run -p 8080:80 -v $volume:/data --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --ipc=host ghcr.io/huggingface/tgi-gaudi:1.2.1 --model-id $model
For gated models such as LLama or StarCoder, you will have to pass
-e HUGGING_FACE_HUB_TOKEN=<token>to thedocker runcommand above with a valid Hugging Face Hub read token.
ii. On 8 Gaudi/Gaudi2 cards:
model=meta-llama/Llama-2-70b-hf
volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
docker run -p 8080:80 -v $volume:/data --runtime=habana -e PT_HPU_ENABLE_LAZY_COLLECTIVES=true -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --ipc=host ghcr.io/huggingface/tgi-gaudi:1.2.1 --model-id $model --sharded true --num-shard 8
You can then send a simple request:
curl 127.0.0.1:8080/generate \
-X POST \
-d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":32}}' \
-H 'Content-Type: application/json'
To run static benchmark test, please refer to TGI's benchmark tool.
To run it on the same machine, you can do the following:
docker exec -it <docker name> bash , pick the docker started from step 2 using docker pstext-generation-benchmark -t <model-id> , pass the model-id from docker run commandTo run continuous batching test, please refer to examples.
Maximum sequence length is controlled by two arguments:
--max-input-length is the maximum possible input prompt length. Default value is 1024.--max-total-tokens is the maximum possible total length of the sequence (input and output). Default value is 2048.Maximum batch size is controlled by two arguments:
--max-prefill-total-tokens as bs * max-input-length, where bs is your expected maximum prefill batch size.--max-batch-total-tokens as bs * max-total-tokens, where bs is your expected maximum decode batch size.BATCH_BUCKET_SIZE and PREFILL_BATCH_BUCKET_SIZE.To ensure greatest performance results, at the begginging of each server run, warmup is performed. It's designed to cover major recompilations while using HPU Graphs. It creates queries with all possible input shapes, based on provided parameters (described in this section) and runs basic TGI operations on them (prefill, decode, concatenate).
Except those already mentioned, there are other parameters that need to be properly adjusted to improve performance or memory usage:
PAD_SEQUENCE_TO_MULTIPLE_OF determines sizes of input legnth buckets. Since warmup creates several graphs for each bucket, it's important to adjust that value proportionally to input sequence length. Otherwise, some out of memory issues can be observed.ENABLE_HPU_GRAPH enables HPU graphs usage, which is crucial for performance results. Recommended value to keep is true .For more information and documentation about Text Generation Inference, checkout the README of the original repo.
TGI supports FP8 precision runs within the limits provided by Habana Quantization Toolkit. Models with FP8 can be ran by properly setting QUANT_CONFIG environment variable. Detailed instruction on how to use that variable can be found in Optimum Habana FP8 guide. Summarising that instruction in TGI cases:
QUANT_CONFIG=./quantization_config/maxabs_quant.json[!NOTE] Only models pointed in supported configurations are guaranteed to work with FP8
Additional hints to quantize model for TGI when using run_lm_eval.py:
--limit_hpu_graphs flag to save memory--batch_size , --max_new_tokens 512 and --max_input_tokens 512 In case of memory issues, lower those values--help for defining tasks/datasets)Not all features of TGI are currently supported as this is still a work in progress. Currently supported and validated configurations (other configurations are not guaranted to work or ensure reasonable performance):
| Model | Cards | Decode batch size | Dtype | Max input tokens | Max total tokens |
|---|---|---|---|---|---|
| LLaMA 70b | 8 | 128 | bfloat16/FP8 | 1024 | 2048 |
| LLaMA 7b | 1/8 | 16 | bfloat16/FP8 | 1024 | 2048 |
Other sequence lengths can be used with proportionally decreased/increased batch size (the higher sequence length, the lower batch size). Support for other models from Optimum Habana will be added successively.
| Name | Value(s) | Default | Description | Usage |
|---|---|---|---|---|
| ENABLE_HPU_GRAPH | True/False | True | Enable hpu graph or not | add -e in docker run command |
| LIMIT_HPU_GRAPH | True/False | False | Skip HPU graph usage for prefill to save memory, set to True for large sequence/decoding lengths(e.g. 300/212) | add -e in docker run command |
| BATCH_BUCKET_SIZE | integer | 8 | Batch size for decode operation will be rounded to the nearest multiple of this number. This limits the number of cached graphs | add -e in docker run command |
| PREFILL_BATCH_BUCKET_SIZE | integer | 4 | Batch size for prefill operation will be rounded to the nearest multiple of this number. This limits the number of cached graphs | add -e in docker run command |
| PAD_SEQUENCE_TO_MULTIPLE_OF | integer | 128 | For prefill operation, sequences will be padded to a multiple of provided value. | add -e in docker run command |
| SKIP_TOKENIZER_IN_TGI | True/False | False | Skip tokenizer for input/output processing | add -e in docker run command |
| WARMUP_ENABLED | True/False | True | Enable warmup during server initialization to recompile all graphs. This can increase TGI setup time. | add -e in docker run command |
| QUEUE_THRESHOLD_MS | integer | 120 | Controls the threshold beyond which the request are considered overdue and handled with priority. Shorter requests are prioritized otherwise. | add -e in docker run command |
To collect performance profiling, please set below environment variables:
| Name | Value(s) | Default | Description | Usage |
|---|---|---|---|---|
| PROF_WAITSTEP | integer | 0 | Control profile wait steps | add -e in docker run command |
| PROF_WARMUPSTEP | integer | 0 | Control profile warmup steps | add -e in docker run command |
| PROF_STEP | integer | 0 | Enable/disable profile, control profile active steps | add -e in docker run command |
| PROF_PATH | string | /tmp/hpu_profile | Define profile folder | add -e in docker run command |
| PROF_RANKS | string | 0 | Comma-separated list of ranks to profile | add -e in docker run command |
| PROF_RECORD_SHAPES | True/False | False | Control record_shapes option in the profiler | add -e in docker run command |
The license to use TGI on Habana Gaudi is the one of TGI: https://github.com/huggingface/text-generation-inference/blob/main/LICENSE
Please reach out to api-enterprise@huggingface.co if you have any question.
12 commits
1 commits
Python
76.7%
C++
11.8%
Cuda
6.7%
Rust
2.2%