Large Language Model Text Generation Inference
Go to file
2023-12-11 09:24:09 +01:00
.github Add RoCm support (#1243) 2023-11-27 14:08:12 +01:00
assets feat(benchmark): tui based benchmarking tool (#149) 2023-03-30 15:26:27 +02:00
benchmark Preping 1.1.0 (#1066) 2023-09-27 10:40:18 +02:00
clients/python feat: add mistral model (#1071) 2023-09-28 09:55:47 +02:00
docs v1.2.0 2023-11-30 15:18:15 +01:00
integration-tests v1.2.0 2023-11-30 15:18:15 +01:00
launcher Add changes from Optimum Habana's TGI folder 2023-12-05 11:12:16 +01:00
load_tests Adding small benchmark script. (#881) 2023-08-18 19:28:56 +02:00
proto feat: add mistral model (#1071) 2023-09-28 09:55:47 +02:00
router Exllama v2 (#1211) 2023-11-25 22:38:38 +01:00
server Fix for continuous batching (#1) 2023-12-11 09:24:09 +01:00
.dockerignore chore: add flash-attention to docker ignore (#287) 2023-05-05 17:52:09 +02:00
.gitignore feat(server): Rework model loading (#344) 2023-06-08 14:51:52 +02:00
Cargo.lock v1.2.0 2023-11-30 15:18:15 +01:00
Cargo.toml v1.2.0 2023-11-30 15:18:15 +01:00
Dockerfile Add changes from Optimum Habana's TGI folder 2023-12-05 11:12:16 +01:00
Dockerfile_amd Add RoCm support (#1243) 2023-11-27 14:08:12 +01:00
LICENSE chore: update license to HFOIL (#725) 2023-07-28 15:59:46 +02:00
Makefile Add changes from Optimum Habana's TGI folder 2023-12-05 11:12:16 +01:00
README.md Merge tag 'v1.2.0' into v1.2-release 2023-12-06 18:46:16 +01:00
rust-toolchain.toml v0.9.0 (#525) 2023-07-01 19:25:41 +02:00
sagemaker-entrypoint.sh feat(sagemaker): add trust remote code to entrypoint (#394) 2023-06-02 09:51:06 +02:00
update_doc.py Adding titles to CLI doc. (#1094) 2023-10-04 12:57:21 +02:00

Text Generation Inference on Habana Gaudi

To use 🤗 text-generation-inference on Habana Gaudi/Gaudi2, follow these steps:

  1. Build the Docker image located in this folder with:

    docker build -t tgi_gaudi .
    
  2. Launch a local server instance on 1 Gaudi 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 tgi_gaudi --model-id $model
    
  3. Launch a local server instance on 8 Gaudi 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 tgi_gaudi --model-id $model --sharded true --num-shard 8
    
  4. You can then send a request:

    curl 127.0.0.1:8080/generate \
      -X POST \
      -d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":17, "do_sample": true}}' \
      -H 'Content-Type: application/json'
    

    The first call will be slower as the model is compiled.

  5. To run benchmark test, please refer 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 3 or 4 using docker ps
    • text-generation-benchmark -t <model-id> , pass the model-id from docker run command
    • after the completion of tests, hit ctrl+c to see the performance data summary.

For gated models such as StarCoder, you will have to pass -e HUGGING_FACE_HUB_TOKEN=<token> to the docker run command above with a valid Hugging Face Hub read token.

For more information and documentation about Text Generation Inference, checkout the README of the original repo.

Not all features of TGI are currently supported as this is still a work in progress.

New changes are added for the current release:

  • Sharded feature with support for DeepSpeed-inference auto tensor parallelism. Also, use HPU graphs for performance improvement.
  • Torch profile.

Environment Variables Added:

Name Value(s) Default Description Usage
MAX_TOTAL_TOKENS integer 0 Control the padding of input add -e in docker run, such
ENABLE_HPU_GRAPH true/false true Enable hpu graph or not add -e in docker run command
PROF_WARMUPSTEP integer 0 Enable/disable profile, control profile warmup step, 0 means disable profile add -e in docker run command
PROF_STEP interger 5 Control profile step add -e in docker run command
PROF_PATH string /root/text-generation-inference Define profile folder add -e in docker run command
LIMIT_HPU_GRAPH True/False False Skip HPU graph usage for prefill to save memory 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.