Views
No views yet
1from transformers import AutoTokenizer
2from vllm import LLM, SamplingParams
3
4number_gpus = 1
5model_name = "neuralmagic/DeepSeek-R1-Distill-Qwen-32B-dynamic"
6
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8sampling_params = SamplingParams(temperature=0.6, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
9llm = LLM(model=model_name, tensor_parallel_size=number_gpus, trust_remote_code=True)
10
11messages_list = [
12 [{"role": "user", "content": "Who are you? Please respond in pirate speak!"}],
13]
14
15prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]
16
17outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)
18
19generated_text = [output.outputs[0].text for output in outputs]
20print(generated_text)1from transformers import AutoModelForCausalLM, AutoTokenizer
2from llmcompressor.modifiers.quantization import QuantizationModifier
3from llmcompressor.transformers import oneshot
4import os
5
6# Load model
7model_stub = "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"
8model_name = model_stub.split("/")[-1]
9
10model = AutoModelForCausalLM.from_pretrained(
11 model_stub,
12 torch_dtype="auto",
13)
14
15tokenizer = AutoTokenizer.from_pretrained(model_stub)
16
17# Configure the quantization algorithm and scheme
18recipe = QuantizationModifier(
19 targets="Linear",
20 scheme="FP8_DYNAMIC",
21 ignore=["lm_head"],
22)
23
24# Apply quantization
25oneshot(
26 model=model,
27 recipe=recipe,
28)
29
30# Save to disk in compressed-tensors format
31save_path = model_name + "-FP8-dynamic
32model.save_pretrained(save_path)
33tokenizer.save_pretrained(save_path)
34print(f"Model and tokenizer saved to: {save_path}")lm_eval \
--model vllm \
--model_args pretrained="neuralmagic/DeepSeek-R1-Distill-Qwen-32B-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_configlm_eval \
--model vllm \
--model_args pretrained="neuralmagic/DeepSeek-R1-Distill-Qwen-32B-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| Category | Metric | deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | neuralmagic/DeepSeek-R1-Distill-Qwen-32B-FP8-dynamic | Recovery |
|---|---|---|---|---|
| Reasoning | AIME 2024 (pass@1) | 69.75 | 68.5 | 98.21% |
| MATH-500 (pass@1) | 95.09 | 95.26 | 100.18% | |
| GPQA Diamond (pass@1) | 64.05 | 62.88 | 98.17% | |
| Average Score | 76.3 | 75.55 | 99.02% | |
| OpenLLM V1 | ARC-Challenge (Acc-Norm, 25-shot) | 64.59 | 64.42 | 99.7% |
| GSM8K (Strict-Match, 5-shot) | 82.71 | 82.64 | 99.9% | |
| HellaSwag (Acc-Norm, 10-shot) | 83.80 | 83.77 | 100.0% | |
| MMLU (Acc, 5-shot) | 81.12 | 80.98 | 99.8% | |
| TruthfulQA (MC2, 0-shot) | 58.41 | 58.30 | 99.8% | |
| Winogrande (Acc, 5-shot) | 76.40 | 76.09 | 99.6% | |
| Average Score | 74.51 | 74.36 | 99.8% | |
| OpenLLM V2 | IFEval (Inst Level Strict Acc, 0-shot) | 42.87 | 49.43 | 99.2% |
| BBH (Acc-Norm, 3-shot) | 57.96 | 58.38 | 100.7% | |
| Math-Hard (Exact-Match, 4-shot) | 0.00 | 0.00 | --- | |
| GPQA (Acc-Norm, 0-shot) | 26.95 | 26.86 | 99.7% | |
| MUSR (Acc-Norm, 0-shot) | 43.95 | 44.22 | 100.6% | |
| MMLU-Pro (Acc, 5-shot) | 49.82 | 49.43 | 99.2% | |
| Average Score | 36.92 | 36.86 | 99.8% | |
| Coding | HumanEval (pass@1) | 86.00 | 85.20 | 99.1% |
| HumanEval (pass@10) | 92.50 | 92.20 | 99.7% | |
| HumanEval+ (pass@10) | 82.00 | 80.90 | 98.7% | |
| HumanEval+ (pass@10) | 88.70 | 88.70 | 100.0% |
guidellm --model neuralmagic/DeepSeek-R1-Distill-Qwen-32B-FP8-dynamic --target "http://localhost:8000/v1" --data-type emulated --data "prompt_tokens=<prompt_tokens>,generated_tokens=<generated_tokens>" --max seconds 360 --backend aiohttp_server| 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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| GPU class | Number of GPUs | 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 |
| A6000 | 2 | deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | --- | 6.3 | 359 | 12.8 | 176 | 6.5 | 347 | 6.6 | 342 | 49.9 | 45 | 50.8 | 44 | 26.6 | 85 | 83.4 | 27 |
| 1 | neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w8a8 | 1.81 | 6.9 | 648 | 13.8 | 325 | 7.2 | 629 | 7.2 | 622 | 54.8 | 82 | 55.6 | 81 | 30.0 | 150 | 94.8 | 47 | |
| 1 | neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a16 | 3.07 | 3.9 | 1168 | 7.8 | 580 | 4.3 | 1041 | 4.6 | 975 | 29.7 | 151 | 30.9 | 146 | 19.3 | 233 | 61.4 | 73 | |
| A100 | 1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | --- | 5.6 | 361 | 11.1 | 180 | 5.7 | 350 | 5.8 | 347 | 44.0 | 46 | 44.7 | 45 | 23.6 | 85 | 73.7 | 27 |
| 1 | neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w8a8 | 1.50 | 3.7 | 547 | 7.3 | 275 | 3.8 | 536 | 3.8 | 528 | 29.0 | 69 | 29.5 | 68 | 15.7 | 128 | 53.1 | 38 | |
| 1 | neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a16 | 2.30 | 2.2 | 894 | 4.5 | 449 | 2.4 | 831 | 2.5 | 798 | 17.4 | 116 | 18.0 | 112 | 10.5 | 191 | 49.5 | 41 | |
| H100 | 1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | --- | 3.3 | 327 | 6.7 | 163 | 3.4 | 320 | 3.4 | 317 | 26.6 | 41 | 26.9 | 41 | 14.3 | 77 | 47.8 | 23 |
| 1 | neuralmagic/DeepSeek-R1-Distill-Qwen-32B-FP8-dynamic | 1.52 | 2.2 | 503 | 4.3 | 252 | 2.2 | 490 | 2.3 | 485 | 17.3 | 63 | 17.5 | 63 | 9.5 | 116 | 33.4 | 33 | |
| 1 | neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a16 | 1.61 | 2.1 | 532 | 4.1 | 268 | 2.1 | 516 | 2.1 | 513 | 16.1 | 68 | 16.5 | 66 | 9.1 | 120 | 31.9 | 34 |
| 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 |
| A6000x2 | deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | --- | 6.2 | 13940 | 1.9 | 4348 | 2.7 | 6153 | 2.1 | 4778 | 0.6 | 1382 | 0.4 | 930 | 0.3 | 685 | 0.1 | 124 |
| neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w8a8 | 1.80 | 8.7 | 19492 | 4.2 | 9474 | 4.1 | 9290 | 3.0 | 6802 | 1.2 | 2734 | 0.9 | 1962 | 0.5 | 1177 | 0.1 | 254 | |
| neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a16 | 1.30 | 5.9 | 13366 | 2.5 | 5733 | 2.4 | 5409 | 1.6 | 3525 | 1.2 | 2757 | 0.7 | 1663 | 0.3 | 676 | 0.1 | 214 | |
| A100x2 | deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | --- | 12.9 | 13016 | 5.8 | 5848 | 6.3 | 6348 | 5.1 | 5146 | 2.0 | 1988 | 1.5 | 1463 | 0.9 | 869 | 0.2 | 192 |
| neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w8a8 | 1.52 | 21.4 | 21479 | 8.9 | 8948 | 10.6 | 10611 | 8.2 | 8197 | 3.0 | 3018 | 2.0 | 2054 | 1.2 | 1241 | 0.3 | 264 | |
| neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a16 | 1.09 | 13.5 | 13568 | 6.5 | 6509 | 6.0 | 6075 | 4.7 | 4754 | 2.8 | 2790 | 1.6 | 1651 | 0.9 | 862 | 0.2 | 225 | |
| H100x2 | deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | --- | 25.5 | 14392 | 12.5 | 7035 | 14.0 | 7877 | 11.3 | 6364 | 3.6 | 2041 | 2.7 | 1549 | 1.9 | 1057 | 0.4 | 200 |
| neuralmagic/DeepSeek-R1-Distill-Qwen-32B-FP8-dynamic | 1.46 | 46.7 | 25538 | 20.3 | 11082 | 23.3 | 12728 | 18.4 | 10049 | 5.3 | 2881 | 3.7 | 2097 | 2.6 | 1445 | 0.5 | 256 | |
| neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a16 | 1.23 | 36.9 | 20172 | 17.4 | 9500 | 18.0 | 9822 | 14.2 | 7755 | 5.3 | 2900 | 3.3 | 1867 | 2.3 | 1265 | 0.4 | 241 |