Views
No views yet
1from transformers import AutoTokenizer
2from vllm import LLM, SamplingParams
3
4number_gpus = 1
5model_name = "neuralmagic/DeepSeek-R1-Distill-Llama-8B-FP8-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-Llama-8B"
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-Llama-8B-FP8-dynamic",dtype=auto,max_model_len=4096,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-Llama-8B-FP8-dynamic",dtype=auto,max_model_len=4096,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-Llama-8B | neuralmagic/DeepSeek-R1-Distill-Llama-8B-FP8-dynamic | Recovery |
|---|---|---|---|---|
| Reasoning | AIME 2024 (pass@1) | 49.25 | 50.83 | 103.21% |
| MATH-500 (pass@1) | 90.18 | 90.24 | 100.07% | |
| GPQA Diamond (pass@1) | 49.27 | 48.71 | 98.86% | |
| Average Score | 62.9 | 63.26 | 100.57% | |
| OpenLLM V1 | ARC-Challenge (Acc-Norm, 25-shot) | 45.05 | 44.88 | 99.6% |
| GSM8K (Strict-Match, 5-shot) | 62.77 | 61.49 | 98.0% | |
| HellaSwag (Acc-Norm, 10-shot) | 76.78 | 76.68 | 99.9% | |
| MMLU (Acc, 5-shot) | 55.65 | 55.82 | 100.3% | |
| TruthfulQA (MC2, 0-shot) | 50.55 | 49.92 | 98.8% | |
| Winogrande (Acc, 5-shot) | 68.51 | 67.72 | 98.8% | |
| Average Score | 58.88 | 59.42 | 99.2 | |
| OpenLLM V2 | IFEval (Inst Level Strict Acc, 0-shot) | 38.37 | 38.67 | 100.8% |
| BBH (Acc-Norm, 3-shot) | 7.43 | 7.48 | --- | |
| Math-Hard (Exact-Match, 4-shot) | 0.00 | 0.00 | --- | |
| GPQA (Acc-Norm, 0-shot) | 1.51 | 0.94 | --- | |
| MUSR (Acc-Norm, 0-shot) | 1.86 | 1.27 | --- | |
| MMLU-Pro (Acc, 5-shot) | 1.61 | 1.60 | --- | |
| Average Score | 8.47 | 8.33 | --- | |
| Coding | HumanEval (pass@1) | 49.90 | 51.20 | 102.6% |
| HumanEval (pass@10) | 68.90 | 68.20 | 99.0% | |
| HumanEval+ (pass@10) | 44.10 | 46.60 | 105.7% | |
| HumanEval+ (pass@10) | 62.90 | 62.70 | 99.7% |
guidellm --model neuralmagic/DeepSeek-R1-Distill-Llama-8B-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 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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-Llama-8B | --- | 3.0 | 1511 | 6.0 | 755 | 3.0 | 1483 | 3.1 | 1462 | 23.6 | 191 | 24.0 | 188 | 12.7 | 353 | 41.1 | 110 |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a8 | 1.53 | 1.9 | 2356 | 3.8 | 1175 | 2.0 | 2291 | 2.0 | 2207 | 15.2 | 297 | 15.5 | 290 | 8.5 | 531 | 28.6 | 157 | |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a16 | 2.35 | 1.2 | 3870 | 2.3 | 1918 | 1.3 | 3492 | 1.3 | 3335 | 9.1 | 492 | 9.5 | 472 | 5.8 | 771 | 22.7 | 198 | |
| A100x1 | deepseek-ai/DeepSeek-R1-Distill-Llama-8B | --- | 1.5 | 1308 | 3.1 | 657 | 1.6 | 1274 | 1.6 | 1263 | 12.1 | 166 | 12.4 | 162 | 6.5 | 308 | 25.6 | 78 |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a8 | 1.30 | 1.1 | 1763 | 2.3 | 882 | 1.2 | 1716 | 1.2 | 1698 | 9.0 | 223 | 9.2 | 218 | 4.9 | 409 | 25.7 | 78 | |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a16 | 1.76 | 0.8 | 2501 | 1.6 | 1236 | 0.9 | 2350 | 0.9 | 2287 | 6.4 | 316 | 6.6 | 306 | 3.7 | 544 | 24.7 | 82 | |
| H100x1 | deepseek-ai/DeepSeek-R1-Distill-Llama-8B | --- | 1.0 | 1146 | 1.9 | 574 | 1.0 | 1128 | 1.0 | 1111 | 7.6 | 144 | 7.7 | 142 | 4.1 | 266 | 16.3 | 67 |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-FP8-dynamic | 1.25 | 0.7 | 1567 | 1.4 | 758 | 0.7 | 1484 | 0.7 | 1462 | 5.7 | 191 | 5.8 | 189 | 3.2 | 347 | 22.5 | 49 | |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a16 | 1.30 | 0.7 | 1527 | 1.4 | 768 | 0.7 | 1495 | 0.7 | 1463 | 5.6 | 194 | 5.7 | 190 | 3.1 | 350 | 14.7 | 74 |
| 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-Llama-8B | --- | 12.6 | 56742 | 5.7 | 25687 | 6.5 | 29349 | 5.2 | 23259 | 1.6 | 7250 | 1.2 | 5181 | 0.8 | 3445 | 0.1 | 616 |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a8 | 1.34 | 17.4 | 78101 | 7.6 | 34351 | 8.8 | 39790 | 7.0 | 31532 | 2.3 | 10405 | 1.5 | 6960 | 1.0 | 4355 | 0.2 | 785 | |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a16 | 0.91 | 10.9 | 48964 | 5.1 | 22989 | 4.8 | 21791 | 3.8 | 17039 | 2.2 | 9726 | 1.2 | 5434 | 0.6 | 2544 | 0.1 | 578 | |
| A100x1 | deepseek-ai/DeepSeek-R1-Distill-Llama-8B | --- | 24.5 | 49296 | 11.3 | 22657 | 13.0 | 26047 | 10.5 | 21020 | 3.5 | 7029 | 2.5 | 4995 | 1.7 | 3503 | 0.3 | 659 |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a8 | 1.27 | 30.8 | 62042 | 14.1 | 28419 | 17.2 | 34554 | 13.8 | 27719 | 4.6 | 9299 | 3.1 | 6215 | 2.2 | 4331 | 0.4 | 807 | |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a16 | 0.97 | 22.7 | 45708 | 10.5 | 21216 | 11.1 | 22353 | 8.9 | 17939 | 3.9 | 7758 | 2.6 | 5241 | 1.6 | 3196 | 0.4 | 718 | |
| H100x1 | deepseek-ai/DeepSeek-R1-Distill-Llama-8B | --- | 49.0 | 53593 | 22.6 | 24750 | 28.3 | 30971 | 22.9 | 25035 | 7.2 | 7912 | 5.1 | 5561 | 3.6 | 3939 | 0.6 | 703 |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-FP8-dynamic | 1.14 | 57.1 | 62517 | 26.0 | 28440 | 34.5 | 37781 | 28.7 | 31360 | 7.2 | 7877 | 5.4 | 5923 | 4.3 | 4697 | 0.7 | 782 | |
| neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a16 | 1.01 | 49.8 | 54452 | 22.9 | 25035 | 28.5 | 31162 | 23.0 | 25200 | 6.8 | 7493 | 5.0 | 5431 | 3.7 | 4079 | 0.7 | 787 |