--- tags: - fp8 - vllm --- # Qwen2-1.5B-Instruct-FP8 ## Model Overview Qwen2-1.5B-Instruct quantized to FP8 weights and activations using per-tensor quantization, ready for inference with vLLM >= 0.5.0. ## Usage and Creation Produced using [AutoFP8 with calibration samples from ultrachat](https://github.com/neuralmagic/AutoFP8/blob/147fa4d9e1a90ef8a93f96fc7d9c33056ddc017a/example_dataset.py). ```python from datasets import load_dataset from transformers import AutoTokenizer from auto_fp8 import AutoFP8ForCausalLM, BaseQuantizeConfig pretrained_model_dir = "Qwen/Qwen2-1.5B-Instruct" quantized_model_dir = "Qwen2-1.5B-Instruct-FP8" tokenizer = AutoTokenizer.from_pretrained(pretrained_model_dir, use_fast=True, model_max_length=4096) tokenizer.pad_token = tokenizer.eos_token ds = load_dataset("mgoin/ultrachat_2k", split="train_sft").select(range(512)) examples = [tokenizer.apply_chat_template(batch["messages"], tokenize=False) for batch in ds] examples = tokenizer(examples, padding=True, truncation=True, return_tensors="pt").to("cuda") quantize_config = BaseQuantizeConfig(quant_method="fp8", activation_scheme="static") model = AutoFP8ForCausalLM.from_pretrained( pretrained_model_dir, quantize_config=quantize_config ) model.quantize(examples) model.save_quantized(quantized_model_dir) ``` ## Evaluation ### Open LLM Leaderboard evaluation scores | | Qwen2-1.5B-Instruct | Qwen2-1.5B-Instruct-FP8
(this model) | | :------------------: | :----------------------: | :------------------------------------------------: | | arc-c
25-shot | 43.09 | 41.81 | | hellaswag
10-shot | 67.48 | 67.18 | | mmlu
5-shot | 55.87 | 55.60 | | truthfulqa
0-shot | 43.34 | 43.09 | | winogrande
5-shot | 63.61 | 63.38 | | gsm8k
5-shot | 57.70 | 56.48 | | **Average
Accuracy** | **55.18** | **54.59** | | **Recovery** | **100%** | **98.93%** |