Views
No views yet
1from transformers import AutoTokenizer
2from vllm import LLM, SamplingParams
3
4number_gpus = 1
5model_name = "neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-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-1.5B"
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-1.5B-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-1.5B-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-1.5B | neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-FP8-dynamic | Recovery |
|---|---|---|---|---|
| Reasoning | AIME 2024 (pass@1) | 30.05 | 29.83 | 99.27% |
| MATH-500 (pass@1) | 84.66 | 84.74 | 100.09% | |
| GPQA Diamond (pass@1) | 35.37 | 35.93 | 101.58% | |
| Average Score | 50.03 | 50.17 | 100.28% | |
| OpenLLM V1 | ARC-Challenge (Acc-Norm, 25-shot) | 37.20 | 37.71 | 101.4% |
| GSM8K (Strict-Match, 5-shot) | 69.98 | 68.99 | 98.6% | |
| HellaSwag (Acc-Norm, 10-shot) | 43.86 | 43.61 | 99.4% | |
| MMLU (Acc, 5-shot) | 37.38 | 37.22 | 99.6% | |
| TruthfulQA (MC2, 0-shot) | 45.21 | 44.77 | 99.0% | |
| Winogrande (Acc, 5-shot) | 54.30 | 54.62 | 100.6% | |
| Average Score | 47.99 | 47.82 | 99.7% | |
| OpenLLM V2 | IFEval (Inst Level Strict Acc, 0-shot) | 34.63 | 34.91 | 100.8% |
| BBH (Acc-Norm, 3-shot) | 3.06 | 2.40 | --- | |
| Math-Hard (Exact-Match, 4-shot) | 0.00 | 0.00 | --- | |
| GPQA (Acc-Norm, 0-shot) | 1.01 | 0.93 | --- | |
| MUSR (Acc-Norm, 0-shot) | 0.78 | 1.26 | --- | |
| MMLU-Pro (Acc, 5-shot) | 1.32 | 1.25 | --- | |
| Average Score | 6.80 | 6.79 | --- | |
| Coding | HumanEval (pass@1) | 37.90 | 36.40 | 96.0% |
| HumanEval (pass@10) | 61.30 | 61.30 | 100.0% | |
| HumanEval+ (pass@10) | 33.00 | 32.60 | 98.8% | |
| HumanEval+ (pass@10) | 55.90 | 56.30 | 100.7% |
guidellm --model neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-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-Qwen-1.5B | --- | 0.8 | 5667 | 1.6 | 2776 | 0.8 | 5515 | 0.8 | 5466 | 6.4 | 705 | 6.5 | 697 | 3.5 | 1295 | 18.3 | 246 |
| neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w8a8 | 1.14 | 0.7 | 6635 | 1.3 | 3340 | 0.7 | 6396 | 0.7 | 6343 | 5.3 | 845 | 5.4 | 832 | 2.9 | 1547 | 21.3 | 211 | |
| neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16 | 1.38 | 0.5 | 8293 | 1.1 | 4184 | 0.6 | 7976 | 0.6 | 7504 | 4.3 | 1051 | 4.4 | 1033 | 2.5 | 1819 | 21.1 | 213 | |
| A100x1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B | --- | 0.6 | 3359 | 1.2 | 1654 | 0.6 | 3286 | 0.6 | 3241 | 4.7 | 424 | 4.9 | 411 | 2.6 | 778 | 21.1 | 95 |
| neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w8a8 | 1.05 | 0.6 | 3531 | 1.1 | 1807 | 0.6 | 3427 | 0.6 | 3480 | 4.5 | 448 | 4.5 | 447 | 2.4 | 842 | 23.5 | 86 | |
| neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16 | 1.03 | 0.6 | 3469 | 1.1 | 1751 | 0.6 | 3403 | 0.6 | 3407 | 4.5 | 447 | 4.6 | 435 | 2.5 | 815 | 23.3 | 86 | |
| H100x1 | deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B | --- | 0.4 | 2604 | 0.8 | 1299 | 0.4 | 2543 | 0.4 | 2551 | 3.3 | 330 | 3.4 | 326 | 1.8 | 612 | 14.0 | 78 |
| neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-FP8-dynamic | 1.04 | 0.4 | 2694 | 0.8 | 1364 | 0.4 | 2670 | 0.4 | 2639 | 3.2 | 347 | 3.2 | 341 | 1.6 | 673 | 14.1 | 78 | |
| neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16 | 0.84 | 0.5 | 2111 | 1.0 | 1065 | 0.5 | 2068 | 0.5 | 2119 | 4.1 | 270 | 4.1 | 265 | 2.1 | 530 | 15.1 | 73 |