mgoin commited on
Commit
71a4b63
1 Parent(s): eef3cb9

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
README.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - fp8
4
+ - vllm
5
+ ---
6
+
7
+ # Meta-Llama-3-70B-Instruct-FP8-KV
8
+
9
+ ## Model Overview
10
+ Meta-Llama-3-70B-Instruct quantized to FP8 weights and activations using per-tensor quantization, ready for inference with vLLM >= 0.5.0.
11
+ This model checkpoint also includes per-tensor scales for FP8 quantized KV Cache, accessed through the `--kv-cache-dtype fp8` argument in vLLM.
12
+
13
+ ```python
14
+ from vllm import LLM
15
+ model = LLM(model="neuralmagic/Meta-Llama-3-70B-Instruct-FP8-KV", kv_cache_dtype="fp8")
16
+ result = model.generate("Hello, my name is")
17
+ ```
18
+
19
+ ## Usage and Creation
20
+ Produced using [AutoFP8 with calibration samples from ultrachat](https://github.com/neuralmagic/AutoFP8).
21
+
22
+ ```python
23
+ from datasets import load_dataset
24
+ from transformers import AutoTokenizer
25
+
26
+ from auto_fp8 import AutoFP8ForCausalLM, BaseQuantizeConfig
27
+
28
+ pretrained_model_dir = "meta-llama/Meta-Llama-3-70B-Instruct"
29
+ quantized_model_dir = "Meta-Llama-3-70B-Instruct-FP8-KV"
30
+
31
+ tokenizer = AutoTokenizer.from_pretrained(pretrained_model_dir, use_fast=True)
32
+ tokenizer.pad_token = tokenizer.eos_token
33
+
34
+ ds = load_dataset("mgoin/ultrachat_2k", split="train_sft")
35
+ examples = [tokenizer.apply_chat_template(batch["messages"], tokenize=False) for batch in ds]
36
+ examples = tokenizer(examples, padding=True, truncation=True, return_tensors="pt").to("cuda")
37
+
38
+ quantize_config = BaseQuantizeConfig(
39
+ quant_method="fp8",
40
+ activation_scheme="static",
41
+ ignore_patterns=["re:.*lm_head"],
42
+ kv_cache_quant_targets=("k_proj", "v_proj"),
43
+ )
44
+
45
+ model = AutoFP8ForCausalLM.from_pretrained(pretrained_model_dir, quantize_config)
46
+ model.quantize(examples)
47
+ model.save_quantized(quantized_model_dir)
48
+ ```
49
+
50
+ ## Evaluation
51
+
52
+ ### Open LLM Leaderboard evaluation scores
53
+ | | Meta-Llama-3-70B-Instruct | Meta-Llama-3-70B-Instruct-FP8 | Meta-Llama-3-70B-Instruct-FP8-KV<br>(this model) |
54
+ | :----------------------: | :-----------------------: | :---------------------------: | :----------------------------------------------: |
55
+ | arc-c<br>25-shot | 72.69 | 72.61 | 72.57 |
56
+ | hellaswag<br>10-shot | 85.50 | 85.41 | 85.32 |
57
+ | mmlu<br>5-shot | 80.18 | 80.06 | 79.69 |
58
+ | truthfulqa<br>0-shot | 62.90 | 62.73 | 61.92 |
59
+ | winogrande<br>5-shot | 83.34 | 83.03 | 83.66 |
60
+ | gsm8k<br>5-shot | 92.49 | 91.12 | 90.83 |
61
+ | **Average<br>Accuracy** | **79.51** | **79.16** | **79.00** |
62
+ | **Recovery** | **100%** | **99.55%** | **99.36%** |