Rallio67 commited on
Commit
c018680
1 Parent(s): 9e3810c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -0
README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - fp8
4
+ - vllm
5
+ ---
6
+
7
+ See original model card for information about how it was made. This is to enable fast inference use with Hopper level hardware in FP8. I quantized it to FP8 using neuralmagic code below on 4x L40s.
8
+
9
+ https://huggingface.co/alpindale/magnum-72b-v1
10
+
11
+ # Magnum-72b-v1-FP8
12
+
13
+ ## Model Overview
14
+ * <h3 style="display: inline;">Model Architecture:</h3> Based on and identical to the Qwen2-72B-Instruct architecture
15
+ * <h3 style="display: inline;">Model Optimizations:</h3> Weights and activations quantized to FP8
16
+ * <h3 style="display: inline;">Release Date:</h3> June 25, 2024
17
+
18
+ Magnum-72B-v1 quantized to FP8 weights and activations using per-tensor quantization through the [AutoFP8 repository](https://github.com/neuralmagic/AutoFP8), ready for inference with vLLM >= 0.5.0.
19
+ Calibrated with 512 UltraChat samples to achieve 100% performance recovery on the Open LLM Benchmark evaluations.
20
+ Reduces space on disk by ~45%.
21
+ Part of the [FP8 LLMs for vLLM collection](https://huggingface.co/collections/neuralmagic/fp8-llms-for-vllm-666742ed2b78b7ac8df13127).
22
+
23
+ ## Usage and Creation
24
+ Produced using [AutoFP8 with calibration samples from ultrachat](https://github.com/neuralmagic/AutoFP8/blob/147fa4d9e1a90ef8a93f96fc7d9c33056ddc017a/example_dataset.py).
25
+
26
+ ```python
27
+ from datasets import load_dataset
28
+ from transformers import AutoTokenizer
29
+
30
+ from auto_fp8 import AutoFP8ForCausalLM, BaseQuantizeConfig
31
+
32
+ pretrained_model_dir = "alpindale/magnum-72b-v1"
33
+ quantized_model_dir = "Magnum-72B-FP8"
34
+
35
+ tokenizer = AutoTokenizer.from_pretrained(pretrained_model_dir, use_fast=True, model_max_length=4096)
36
+ tokenizer.pad_token = tokenizer.eos_token
37
+
38
+ ds = load_dataset("mgoin/ultrachat_2k", split="train_sft").select(range(512))
39
+ examples = [tokenizer.apply_chat_template(batch["messages"], tokenize=False) for batch in ds]
40
+ examples = tokenizer(examples, padding=True, truncation=True, return_tensors="pt").to("cuda")
41
+
42
+ quantize_config = BaseQuantizeConfig(quant_method="fp8", activation_scheme="static")
43
+
44
+ model = AutoFP8ForCausalLM.from_pretrained(
45
+ pretrained_model_dir, quantize_config=quantize_config
46
+ )
47
+ model.quantize(examples)
48
+ model.save_quantized(quantized_model_dir)
49
+ ```