JRosenkranz commited on
Commit
fbb7aba
1 Parent(s): 0079668

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -0
README.md CHANGED
@@ -1,3 +1,94 @@
1
  ---
2
  license: llama3
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: llama3
3
  ---
4
+
5
+ ## Installation from source
6
+
7
+ ```bash
8
+ git clone https://github.com/foundation-model-stack/fms-extras
9
+ cd fms-extras
10
+ pip install -e .
11
+ ```
12
+
13
+
14
+ ## Description
15
+
16
+ This model is intended to be used as an accelerator for [llama3 8b (instruct)](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) and takes inspiration
17
+ from the Medusa speculative decoding architecture. This accelerator modifies the MLP into a multi-stage MLP, where each stage predicts
18
+ a single token in the draft based on both a state vector and sampled token
19
+ from the prior stage (the base model can be considered stage 0).
20
+ The state vector from the base model provides contextual information to the accelerator,
21
+ while conditioning on prior sampled tokens allows it to produce higher-quality draft n-grams.
22
+
23
+ Note: The underlying MLP speculator is a generic architecture that can be trained with any generative model to accelerate inference.
24
+ Training is light-weight and can be completed in only a few days depending on base model size and speed.
25
+
26
+ ## Repository Links
27
+
28
+ 1. [Paged Attention KV-Cache / Speculator](https://github.com/foundation-model-stack/fms-extras)
29
+ 2. [Production Server with speculative decoding](https://github.com/IBM/text-generation-inference.git)
30
+ 3. [Speculator training](https://github.com/foundation-model-stack/fms-fsdp/pull/35)
31
+
32
+ ## Samples
33
+
34
+ _Note: For all samples, your environment must have access to cuda_
35
+
36
+ ### Production Server Sample
37
+
38
+ *To try this out running in a production-like environment, please use the pre-built docker image:*
39
+
40
+ #### Setup
41
+
42
+ ```bash
43
+ HF_HUB_CACHE=/hf_hub_cache
44
+ chmod a+w $HF_HUB_CACHE
45
+ HF_HUB_TOKEN="your huggingface hub token"
46
+ TGIS_IMAGE=quay.io/wxpe/text-gen-server:main.ee927a4
47
+
48
+ docker pull $TGIS_IMAGE
49
+
50
+ # optionally download llama3-8b-instruct if the weights do not already exist
51
+ docker run --rm \
52
+ -v $HF_HUB_CACHE:/models \
53
+ -e HF_HUB_CACHE=/models \
54
+ -e TRANSFORMERS_CACHE=/models \
55
+ $TGIS_IMAGE \
56
+ text-generation-server download-weights \
57
+ meta-llama/Meta-Llama-3-8B-Instruct \
58
+ --token $HF_HUB_TOKEN
59
+
60
+ # optionally download the speculator model if the weights do not already exist
61
+ docker run --rm \
62
+ -v $HF_HUB_CACHE:/models \
63
+ -e HF_HUB_CACHE=/models \
64
+ -e TRANSFORMERS_CACHE=/models \
65
+ $TGIS_IMAGE \
66
+ text-generation-server download-weights \
67
+ ibm-fms/llama3-8b-accelerator \
68
+ --token $HF_HUB_TOKEN
69
+
70
+ # note: if the weights were downloaded separately (not with the above commands), please place them in the HF_HUB_CACHE directoy and refer to them with /models/<model_name>
71
+ docker run -d --rm --gpus all \
72
+ --name my-tgis-server \
73
+ -p 8033:8033 \
74
+ -v $HF_HUB_CACHE:/models \
75
+ -e HF_HUB_CACHE=/models \
76
+ -e TRANSFORMERS_CACHE=/models \
77
+ -e MODEL_NAME=meta-llama/Meta-Llama-3-8B-Instruct \
78
+ -e SPECULATOR_NAME=ibm-fms/llama3-8b-accelerator \
79
+ -e FLASH_ATTENTION=true \
80
+ -e PAGED_ATTENTION=true \
81
+ -e DTYPE=float16 \
82
+ $TGIS_IMAGE
83
+
84
+ # check logs and wait for "gRPC server started on port 8033" and "HTTP server started on port 3000"
85
+ docker logs my-tgis-server -f
86
+
87
+ # get the client sample (Note: The first prompt will take longer as there is a warmup time)
88
+ conda create -n tgis-client-env python=3.11
89
+ conda activate tgis-client-env
90
+ git clone --branch main --single-branch https://github.com/IBM/text-generation-inference.git
91
+ cd text-generation-inference/integration_tests
92
+ make gen-client
93
+ pip install . --no-cache-dir
94
+ ```