--- license: mit tags: - deepseek - fp8 - vllm base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B library_name: transformers --- # DeepSeek-R1-Distill-Qwen-7B-FP8-dynamic ## Model Overview - **Model Architecture:** Qwen2ForCausalLM - **Input:** Text - **Output:** Text - **Model Optimizations:** - **Weight quantization:** FP8 - **Activation quantization:** FP8 - **Release Date:** 2/5/2025 - **Version:** 1.0 - **Model Developers:** Neural Magic Quantized version of [DeepSeek-R1-Distill-Qwen-7B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B). ### Model Optimizations This model was obtained by quantizing the weights and activations of [DeepSeek-R1-Distill-Qwen-7B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B) to FP8 data type. This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%. Only the weights and activations of the linear operators within transformers blocks are quantized. Weights are quantized using a symmetric per-channel scheme, whereas quantizations are quantized using a symmetric per-token scheme. [LLM Compressor](https://github.com/vllm-project/llm-compressor) is used for quantization. ## Use with vLLM This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below. ```python from transformers import AutoTokenizer from vllm import LLM, SamplingParams number_gpus = 1 model_name = "neuralmagic/DeepSeek-R1-Distill-Qwen-7B-dynamic" tokenizer = AutoTokenizer.from_pretrained(model_name) sampling_params = SamplingParams(temperature=0.6, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id]) llm = LLM(model=model_name, tensor_parallel_size=number_gpus, trust_remote_code=True) messages_list = [ [{"role": "user", "content": "Who are you? Please respond in pirate speak!"}], ] prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list] outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params) generated_text = [output.outputs[0].text for output in outputs] print(generated_text) ``` vLLM also supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details. ## Creation This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below. ```python from transformers import AutoModelForCausalLM, AutoTokenizer from llmcompressor.modifiers.quantization import QuantizationModifier from llmcompressor.transformers import oneshot import os # Load model model_stub = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B" model_name = model_stub.split("/")[-1] model = AutoModelForCausalLM.from_pretrained( model_stub, torch_dtype="auto", ) tokenizer = AutoTokenizer.from_pretrained(model_stub) # Configure the quantization algorithm and scheme recipe = QuantizationModifier( targets="Linear", scheme="FP8_DYNAMIC", ignore=["lm_head"], ) # Apply quantization oneshot( model=model, recipe=recipe, ) # Save to disk in compressed-tensors format save_path = model_name + "-FP8-dynamic model.save_pretrained(save_path) tokenizer.save_pretrained(save_path) print(f"Model and tokenizer saved to: {save_path}") ``` ## Evaluation The model was evaluated on OpenLLM Leaderboard [V1](https://huggingface.co/spaces/open-llm-leaderboard-old/open_llm_leaderboard) and [V2](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard#/), using the following commands: OpenLLM Leaderboard V1: ``` lm_eval \ --model vllm \ --model_args pretrained="neuralmagic/DeepSeek-R1-Distill-Qwen-7B-FP8-dynamic",dtype=auto,max_model_len=4096,tensor_parallel_size=1,enable_chunked_prefill=True \ --tasks openllm \ --write_out \ --batch_size auto \ --output_path output_dir \ --show_config ``` OpenLLM Leaderboard V2: ``` lm_eval \ --model vllm \ --model_args pretrained="neuralmagic/DeepSeek-R1-Distill-Qwen-7B-FP8-dynamic",dtype=auto,max_model_len=4096,tensor_parallel_size=1,enable_chunked_prefill=True \ --apply_chat_template \ --fewshot_as_multiturn \ --tasks leaderboard \ --write_out \ --batch_size auto \ --output_path output_dir \ --show_config ``` ### Accuracy
Category | Metric | deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | neuralmagic/DeepSeek-R1-Distill-Qwen-7B-FP8-dynamic | Recovery |
---|---|---|---|---|
OpenLLM V1 | ARC-Challenge (Acc-Norm, 25-shot) | 50.51 | 50.51 | 100.0% |
GSM8K (Strict-Match, 5-shot) | 78.62 | 79.83 | 101.5% | |
HellaSwag (Acc-Norm, 10-shot) | 61.90 | 61.62 | 99.6% | |
MMLU (Acc, 5-shot) | 54.19 | 53.76 | 99.2% | |
TruthfulQA (MC2, 0-shot) | 45.55 | 46.14 | 101.3% | |
Winogrande (Acc, 5-shot) | 61.56 | 60.54 | 98.3% | |
Average Score | 58.72 | 58.73 | 100.0% | |
OpenLLM V2 | IFEval (Inst Level Strict Acc, 0-shot) | 39.67 | 39.77 | 100.2% |
BBH (Acc-Norm, 3-shot) | 39.60 | 39.33 | 99.3% | |
Math-Hard (Exact-Match, 4-shot) | 0.00 | 0.00 | --- | |
GPQA (Acc-Norm, 0-shot) | 25.24 | 24.97 | 98.6% | |
MUSR (Acc-Norm, 0-shot) | 38.09 | 37.82 | 99.3% | |
MMLU-Pro (Acc, 5-shot) | 19.53 | 18.53 | 94.5% | |
Average Score | 27.02 | 26.74 | 99.0% | |
Coding | HumanEval (pass@1) | 40.80 | 39.50 | 96.8% |
HumanEval (pass@10) | 64.40 | 62.10 | 96.4% | |
HumanEval+ (pass@10) | 38.50 | 37.20 | 96.6% | |
HumanEval+ (pass@10) | 60.40 | 59.30 | 98.2% |
Instruction Following 256 / 128 |
Multi-turn Chat 512 / 256 |
Docstring Generation 768 / 128 |
RAG 1024 / 128 |
Code Completion 256 / 1024 |
Code Fixing 1024 / 1024 |
Large Summarization 4096 / 512 |
Large RAG 10240 / 1536 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hardware | Model | Average cost reduction | Latency (s) | QPD | Latency (s) | QPD | Latency (s) | QPD | Latency (s) | QPD | Latency (s) | QPD | Latency (s) | QPD | Latency (s) | QPD | Latency (s) | QPD |
A6000x1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | --- | 2.9 | 1576 | 5.7 | 788 | 2.9 | 1535 | 3.0 | 1496 | 22.6 | 199 | 23.2 | 194 | 12.1 | 370 | 38.5 | 117 |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 | 1.56 | 1.8 | 2495 | 3.7 | 1223 | 1.9 | 2384 | 1.9 | 2393 | 14.3 | 315 | 14.8 | 304 | 7.9 | 572 | 25.3 | 178 | |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a16 | 2.41 | 1.1 | 4086 | 2.3 | 1998 | 1.2 | 3783 | 1.3 | 3527 | 8.6 | 526 | 8.8 | 512 | 5.2 | 860 | 22.7 | 198 | |
A100x1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | --- | 1.4 | 1389 | 2.9 | 691 | 1.5 | 1358 | 1.5 | 1329 | 11.5 | 175 | 11.6 | 174 | 6.2 | 326 | 21.5 | 93 |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 | 1.28 | 1.1 | 1850 | 2.2 | 905 | 1.1 | 1807 | 1.1 | 1750 | 8.6 | 233 | 8.7 | 230 | 4.7 | 431 | 23.1 | 87 | |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a16 | 1.72 | 0.8 | 2575 | 1.5 | 1298 | 0.8 | 2461 | 0.8 | 2382 | 6.1 | 331 | 6.2 | 323 | 3.6 | 566 | 22.7 | 89 | |
H100x1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | --- | 0.9 | 1161 | 1.9 | 579 | 1.0 | 1138 | 1.0 | 1121 | 7.5 | 146 | 7.6 | 145 | 3.9 | 279 | 15.4 | 71 |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-FP8-dynamic | 1.34 | 0.7 | 1585 | 1.4 | 786 | 0.7 | 1577 | 0.7 | 1524 | 5.3 | 207 | 5.5 | 197 | 2.9 | 382 | 14.3 | 77 | |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a16 | 1.33 | 0.7 | 1590 | 1.4 | 793 | 0.7 | 1549 | 0.7 | 1509 | 5.4 | 201 | 5.5 | 198 | 2.9 | 381 | 14.0 | 78 |
Instruction Following 256 / 128 |
Multi-turn Chat 512 / 256 |
Docstring Generation 768 / 128 |
RAG 1024 / 128 |
Code Completion 256 / 1024 |
Code Fixing 1024 / 1024 |
Large Summarization 4096 / 512 |
Large RAG 10240 / 1536 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hardware | Model | Average cost reduction | Maximum throughput (QPS) | QPD | Maximum throughput (QPS) | QPD | Maximum throughput (QPS) | QPD | Maximum throughput (QPS) | QPD | Maximum throughput (QPS) | QPD | Maximum throughput (QPS) | QPD | Maximum throughput (QPS) | QPD | Maximum throughput (QPS) | QPD |
A6000x1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | --- | 14.9 | 67138 | 7.1 | 32094 | 7.4 | 33096 | 5.9 | 26480 | 2.0 | 9004 | 1.5 | 6639 | 1.1 | 4938 | 0.3 | 1151 |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 | 1.36 | 20.2 | 90956 | 8.8 | 39786 | 10.2 | 45963 | 8.1 | 36596 | 3.1 | 13968 | 2.1 | 9629 | 1.4 | 6374 | 0.3 | 1429 | |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a16 | 1.00 | 13.3 | 59681 | 6.1 | 27633 | 5.9 | 26689 | 4.7 | 20944 | 2.9 | 13108 | 1.9 | 8355 | 1.0 | 4362 | 0.3 | 1170 | |
A100x1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | --- | 26.4 | 53073 | 13.0 | 26213 | 14.5 | 29110 | 11.4 | 22936 | 4.4 | 8749 | 3.3 | 6680 | 2.3 | 4634 | 0.5 | 1105 |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 | 1.27 | 34.3 | 69009 | 14.8 | 29791 | 19.0 | 38214 | 15.7 | 31598 | 5.6 | 11186 | 4.2 | 8350 | 3.0 | 6020 | 0.7 | 1328 | |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a16 | 0.93 | 23.9 | 47993 | 12.0 | 24194 | 12.5 | 25239 | 10.0 | 20029 | 4.5 | 9055 | 3.3 | 6681 | 2.1 | 4156 | 0.5 | 1043 | |
H100x1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | --- | 54.3 | 59410 | 26.0 | 28440 | 32.1 | 35154 | 26.7 | 29190 | 8.0 | 8700 | 6.6 | 7275 | 5.2 | 5669 | 1.2 | 1266 |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-FP8-dynamic | 1.16 | 62.9 | 68818 | 30.3 | 33196 | 39.4 | 43132 | 31.1 | 34073 | 9.2 | 10058 | 7.1 | 7748 | 6.1 | 6714 | 1.3 | 1415 | |
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a16 | 1.02 | 56.2 | 61483 | 26.7 | 29243 | 32.5 | 35592 | 26.9 | 29461 | 8.3 | 9072 | 6.4 | 7027 | 5.2 | 5731 | 1.2 | 1291 |