Views
No views yet
1git clone https://github.com/foundation-model-stack/fms-extras
2cd fms-extras
3pip install -e .1HF_HUB_CACHE=/hf_hub_cache
2chmod a+w $HF_HUB_CACHE
3HF_HUB_TOKEN="your huggingface hub token"
4TGIS_IMAGE=quay.io/wxpe/text-gen-server:main.ddc56ee
5
6docker pull $TGIS_IMAGE
7
8# optionally download granite-7b-lab if the weights do not already exist
9docker run --rm \
10 -v $HF_HUB_CACHE:/models \
11 -e HF_HUB_CACHE=/models \
12 -e TRANSFORMERS_CACHE=/models \
13 $TGIS_IMAGE \
14 text-generation-server download-weights \
15 instructlab/granite-7b-lab \
16 --token $HF_HUB_TOKEN
17
18# optionally download the speculator model if the weights do not already exist
19docker run --rm \
20 -v $HF_HUB_CACHE:/models \
21 -e HF_HUB_CACHE=/models \
22 -e TRANSFORMERS_CACHE=/models \
23 $TGIS_IMAGE \
24 text-generation-server download-weights \
25 ibm/granite-7b-lab-accelerator \
26 --token $HF_HUB_TOKEN
27
28# note: if the weights were downloaded separately (not with the above commands), please place them in the HF_HUB_CACHE directory and refer to them with /models/<model_name>
29docker run -d --rm --gpus all \
30 --name my-tgis-server \
31 -p 8033:8033 \
32 -v $HF_HUB_CACHE:/models \
33 -e HF_HUB_CACHE=/models \
34 -e TRANSFORMERS_CACHE=/models \
35 -e MODEL_NAME=instructlab/granite-7b-lab \
36 -e SPECULATOR_NAME=ibm/granite-7b-lab-accelerator \
37 -e FLASH_ATTENTION=true \
38 -e PAGED_ATTENTION=true \
39 -e DTYPE=float16 \
40 $TGIS_IMAGE
41
42# check logs and wait for "gRPC server started on port 8033" and "HTTP server started on port 3000"
43docker logs my-tgis-server -f
44
45# get the client sample (Note: The first prompt will take longer as there is a warmup time)
46conda create -n tgis-client-env python=3.11
47conda activate tgis-client-env
48git clone --branch main --single-branch https://github.com/IBM/text-generation-inference.git
49cd text-generation-inference/integration_tests
50make gen-client
51pip install . --no-cache-dirpython sample_client.py1model=ibm/granite-7b-lab-accelerator
2volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
3docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data ghcr.io/huggingface/text-generation-inference:latest --model-id $model1curl 127.0.0.1:8080/generate_stream \
2 -X POST \
3 -d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":20}}' \
4 -H 'Content-Type: application/json'1git clone --branch ibm_7b_instruct_lab_variant --single-branch https://github.com/JRosenkranz/fms-extras.git
2(cd fms-extras && pip install -e .)
3pip install transformers==4.35.0 sentencepiece numpy1MODEL_PATH=/path/to/instructlab/granite-7b-lab
2python fms-extras/scripts/paged_speculative_inference.py \
3 --variant=7b.ibm_instruct_lab \
4 --model_path=$MODEL_PATH \
5 --model_source=hf \
6 --tokenizer=$MODEL_PATH \
7 --speculator_path=ibm/granite-7b-lab-accelerator \
8 --speculator_source=hf \
9 --speculator_variant=1_4b \
10 --top_k_tokens_per_head=4,3,2,2,2 \
11 --compile \
12 --compile_mode=reduce-overhead1MODEL_PATH=/path/to/instructlab/granite-7b-lab
2python fms-extras/scripts/paged_speculative_inference.py \
3 --variant=7b.ibm_instruct_lab \
4 --model_path=$MODEL_PATH \
5 --model_source=hf \
6 --tokenizer=$MODEL_PATH \
7 --speculator_path=ibm/granite-7b-lab-accelerator \
8 --speculator_source=hf \
9 --speculator_variant=1_4b \
10 --top_k_tokens_per_head=4,3,2,2,2 \
11 --compile1MODEL_PATH=/path/to/instructlab/granite-7b-lab
2python fms-extras/scripts/paged_speculative_inference.py \
3 --variant=7b.ibm_instruct_lab \
4 --model_path=$MODEL_PATH \
5 --model_source=hf \
6 --tokenizer=$MODEL_PATH \
7 --speculator_path=ibm/granite-7b-lab-accelerator \
8 --speculator_source=hf \
9 --speculator_variant=1_4b \
10 --top_k_tokens_per_head=4,3,2,2,2 \
11 --batch_input \
12 --compile