robertgshaw2 commited on
Commit
2023f80
·
verified ·
1 Parent(s): cb5a068

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +56 -0
README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama2
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ ---
7
+
8
+ ## llama-2-7b-chat-marlin
9
+
10
+ Example of converting a GPTQ model to Marlin format for fast batched decoding with [Marlin Kernels](https://github.com/IST-DASLab/marlin)
11
+
12
+ ### Install Marlin
13
+ ```bash
14
+ pip install torch
15
+ git clone https://github.com/IST-DASLab/marlin.git
16
+ cd marlin
17
+ pip install -e .
18
+ ```
19
+
20
+ ### Convert Model
21
+
22
+ The following converts the model from GPTQ to Marlin format. Note that this requires:
23
+ - `sym=true`
24
+ - `group_size=128`
25
+ - `desc_activations=false`
26
+
27
+ ```bash
28
+ pip install -U transformers accelerate auto-gptq optimum
29
+ ```
30
+
31
+ Convert with the `convert.py` script in this repo:
32
+
33
+ ```bash
34
+ python3 convert.py --model-id "TheBloke/Llama-2-7B-Chat-GPTQ" --save-path "./marlin-model" --do-generation
35
+ ```bash
36
+
37
+ ### Run Model
38
+
39
+ Load with the `load.load_model` utility from this repo and run inference as usual.
40
+
41
+ ```python
42
+ from load import load_model
43
+ from transformers import AutoTokenizer
44
+
45
+ # Load model from disk.
46
+ model_path = "./marlin-model"
47
+ model = load_model(model_path).to("cuda")
48
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
49
+
50
+
51
+ # Run inference to confirm it is working.
52
+ inputs = tokenizer("My favorite song is", return_tensors="pt")
53
+ inputs = {k: v.to("cuda") for k, v in inputs.items()}
54
+ outputs = model.generate(**inputs, max_new_tokens=50, do_sample=False)
55
+ print(tokenizer.batch_decode(outputs)[0])
56
+ ```