mgoin commited on
Commit
4b1f72a
·
verified ·
1 Parent(s): 00937dc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +43 -4
README.md CHANGED
@@ -4,14 +4,53 @@ tags:
4
  - vllm
5
  ---
6
 
 
7
 
8
- Meta-Llama-3-8B-Instruct quantized to FP8 weights and activations using per-tensor quantization, ready for inference with vLLM >= 0.5.0.
9
- This model checkpoint also includes experimental per-tensor scales for FP8 quantized KV Cache, accessed through the `--kv-cache-dtype fp8` argument in vLLM.
 
10
 
11
  ```python
12
  from vllm import LLM
13
-
14
- model = LLM(model="nm-testing/Meta-Llama-3-8B-Instruct-FP8-KV", kv_cache_dtype="fp8")
15
  result = model.generate("Hello, my name is")
16
  ```
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  - vllm
5
  ---
6
 
7
+ # Meta-Llama-3-8B-Instruct-FP8-KV
8
 
9
+ ## Model Overview
10
+ Meta-Llama-3-8B-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-8B-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/blob/147fa4d9e1a90ef8a93f96fc7d9c33056ddc017a/example_dataset.py).
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-8B-Instruct"
29
+ quantized_model_dir = "Meta-Llama-3-8B-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-8B-Instruct | Meta-Llama-3-8B-Instruct-FP8 | Meta-Llama-3-8B-Instruct-FP8-KV<br>(this model) |
54
+ | :------------------: | :----------------------: | :--------------------------: | :---------------------------------------------: |
55
+ | gsm8k<br>5-shot | 75.44 | 74.37 | 74.98 |
56
+