sahilsuneja commited on
Commit
11efffa
·
verified ·
1 Parent(s): 2affeda

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +126 -3
README.md CHANGED
@@ -1,3 +1,126 @@
1
- ---
2
- license: llama3
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3
3
+ ---
4
+
5
+
6
+ ## Installation from source
7
+
8
+ ```bash
9
+ git clone https://github.com/foundation-model-stack/fms-extras
10
+ cd fms-extras
11
+ pip install -e .
12
+ ```
13
+
14
+
15
+ ## Description
16
+
17
+ This model is intended to be used as an accelerator for [llama3 70b (instruct)](https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct) and takes inspiration
18
+ from the Medusa speculative decoding architecture. It is also applicable for [llama3.1 70b (instruct)](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct).
19
+ This accelerator modifies the MLP into a multi-stage MLP, where each stage predicts
20
+ a single token in the draft based on both a state vector and sampled token
21
+ from the prior stage (the base model can be considered stage 0).
22
+ The state vector from the base model provides contextual information to the accelerator,
23
+ while conditioning on prior sampled tokens allows it to produce higher-quality draft n-grams.
24
+
25
+ Note: The underlying MLP speculator is a generic architecture that can be trained with any generative model to accelerate inference.
26
+ Training is light-weight and can be completed in only a few days depending on base model size and speed.
27
+
28
+ ## Repository Links
29
+
30
+ 1. [Paged Attention KV-Cache / Speculator](https://github.com/foundation-model-stack/fms-extras)
31
+ 2. [Production Server with speculative decoding](https://github.com/IBM/text-generation-inference.git)
32
+ 3. [Speculator training](https://github.com/foundation-model-stack/fms-fsdp/pull/35)
33
+
34
+ ## Samples
35
+
36
+ _Note: For all samples, your environment must have access to cuda_
37
+
38
+ ### Use in IBM Production TGIS
39
+
40
+ *To try this out running in a production-like environment, please use the pre-built docker image:*
41
+
42
+ #### Setup
43
+
44
+ ```bash
45
+ HF_HUB_CACHE=/hf_hub_cache
46
+ chmod a+w $HF_HUB_CACHE
47
+ HF_HUB_TOKEN="your huggingface hub token"
48
+ TGIS_IMAGE=quay.io/wxpe/text-gen-server:main.ddc56ee
49
+
50
+ docker pull $TGIS_IMAGE
51
+
52
+ # optionally download llama3-70b-instruct if the weights do not already exist
53
+ docker run --rm \
54
+ -v $HF_HUB_CACHE:/models \
55
+ -e HF_HUB_CACHE=/models \
56
+ -e TRANSFORMERS_CACHE=/models \
57
+ $TGIS_IMAGE \
58
+ text-generation-server download-weights \
59
+ meta-llama/Meta-Llama-3-70B-Instruct \
60
+ --token $HF_HUB_TOKEN
61
+
62
+ # optionally download the speculator model if the weights do not already exist
63
+ docker run --rm \
64
+ -v $HF_HUB_CACHE:/models \
65
+ -e HF_HUB_CACHE=/models \
66
+ -e TRANSFORMERS_CACHE=/models \
67
+ $TGIS_IMAGE \
68
+ text-generation-server download-weights \
69
+ ibm-fms/llama3-70b-accelerator \
70
+ --token $HF_HUB_TOKEN
71
+
72
+ # 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>
73
+ docker run -d --rm --gpus all \
74
+ --name my-tgis-server \
75
+ -p 8033:8033 \
76
+ -v $HF_HUB_CACHE:/models \
77
+ -e HF_HUB_CACHE=/models \
78
+ -e TRANSFORMERS_CACHE=/models \
79
+ -e MODEL_NAME=meta-llama/Meta-Llama-3-70B-Instruct \
80
+ -e SPECULATOR_NAME=ibm-fms/llama3-70b-accelerator \
81
+ -e FLASH_ATTENTION=true \
82
+ -e PAGED_ATTENTION=true \
83
+ -e DTYPE=float16 \
84
+ $TGIS_IMAGE
85
+
86
+ # check logs and wait for "gRPC server started on port 8033" and "HTTP server started on port 3000"
87
+ docker logs my-tgis-server -f
88
+
89
+ # get the client sample (Note: The first prompt will take longer as there is a warmup time)
90
+ conda create -n tgis-client-env python=3.11
91
+ conda activate tgis-client-env
92
+ git clone --branch main --single-branch https://github.com/IBM/text-generation-inference.git
93
+ cd text-generation-inference/integration_tests
94
+ make gen-client
95
+ pip install . --no-cache-dir
96
+ ```
97
+
98
+ #### Run Sample
99
+
100
+ ```bash
101
+ python sample_client.py
102
+ ```
103
+
104
+ _Note: first prompt may be slower as there is a slight warmup time_
105
+
106
+ ### Use in Huggingface TGI
107
+
108
+ #### start the server
109
+
110
+ ```bash
111
+ model=ibm-fms/llama3-70b-accelerator
112
+ volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
113
+
114
+ docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data ghcr.io/huggingface/text-generation-inference:latest --model-id $model
115
+ ```
116
+
117
+ _note: for tensor parallel, add --num-shard_
118
+
119
+ #### make a request
120
+
121
+ ```bash
122
+ curl 127.0.0.1:8080/generate_stream \
123
+ -X POST \
124
+ -d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":20}}' \
125
+ -H 'Content-Type: application/json'
126
+ ```