Quantized version of DeepSeek-R1-Distill-Qwen-7B.
This model was obtained by quantizing the weights and activations of DeepSeek-R1-Distill-Qwen-7B to INT8 data type. This optimization reduces the number of bits used to represent weights and activations from 16 to 8, reducing GPU memory requirements (by approximately 50%) and increasing matrix-multiply compute throughput (by approximately 2x). Weight quantization also reduces disk size 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. The GPTQ algorithm is applied for quantization, as implemented in the llm-compressor library.
This model can be deployed efficiently using the vLLM backend, as shown in the example below.
from transformers import AutoTokenizer
from vllm import LLM, SamplingParams
number_gpus = 1
model_name = "neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8"
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 for more details.
This model was created with llm-compressor by running the code snippet below.
from transformers import AutoModelForCausalLM, AutoTokenizer
from llmcompressor.modifiers.quantization import QuantizationModifier
from llmcompressor.modifiers.smoothquant import SmoothQuantModifier
from llmcompressor.transformers import oneshot
# Load model
model_stub = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
model_name = model_stub.split("/")[-1]
num_samples = 1024
max_seq_len = 8192
tokenizer = AutoTokenizer.from_pretrained(model_stub)
model = AutoModelForCausalLM.from_pretrained(
model_stub,
device_map="auto",
torch_dtype="auto",
)
def preprocess_fn(example):
return {"text": tokenizer.apply_chat_template(example["messages"], add_generation_prompt=False, tokenize=False)}
ds = load_dataset("neuralmagic/LLM_compression_calibration", split="train")
ds = ds.map(preprocess_fn)
# Configure the quantization algorithm and scheme
recipe = [
SmoothQuantModifier(smoothing_strength=0.7),
QuantizationModifier(
targets="Linear",
scheme="W8A8",
ignore=["lm_head"],
dampening_frac=0.1,
),
]
# Apply quantization
oneshot(
model=model,
dataset=ds,
recipe=recipe,
max_seq_length=max_seq_len,
num_calibration_samples=num_samples,
)
# Save to disk in compressed-tensors format
save_path = model_name + "-quantized.w8a8
model.save_pretrained(save_path)
tokenizer.save_pretrained(save_path)
print(f"Model and tokenizer saved to: {save_path}")
The model was evaluated on OpenLLM Leaderboard V1 and V2, using the following commands:
OpenLLM Leaderboard V1:
lm_eval \
--model vllm \
--model_args pretrained="neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8",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-quantized.w8a8",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-7B | neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 | Recovery |
|---|---|---|---|---|
| Reasoning | AIME 2024 (pass@1) | 53.17 | 55.19 | 103.8% |
| MATH-500 (pass@1) | 93.66 | 93 | 99.3% | |
| GPQA Diamond (pass@1) | 50.53 | 50.65 | 100.24% | |
| Average Score | 65.79 | 66.28 | 100.74% | |
| 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.33% | |
| Average Score | 58.72 | 58.73 | 100.0% | |
| OpenLLM V2 | IFEval (Inst Level Strict Acc, 0-shot) | 39.38 | 40.20 | 102.1% |
| BBH (Acc-Norm, 3-shot) | 6.97 | 6.10 | --- | |
| Math-Hard (Exact-Match, 4-shot) | 0.00 | 0.00 | --- | |
| GPQA (Acc-Norm, 0-shot) | 1.81 | 0.90 | --- | |
| MUSR (Acc-Norm, 0-shot) | 4.68 | 4.04 | --- | |
| MMLU-Pro (Acc, 5-shot) | 1.66 | 1.73 | --- | |
| Average Score | 9.08 | 8.83 | --- | |
| 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% |
This model achieves up to 1.6x speedup in both single-stream and multi-stream asynchronous deployment, depending on hardware and use-case scenario. The following performance benchmarks were conducted with vLLM version 0.7.2, and GuideLLM.
Benchmarking Commandguidellm --model neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 --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-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 | |
**Use case profiles: prompt tokens / generation tokens
**QPD: Queries per dollar, based on on-demand cost at Lambda Labs (observed on 2/18/2025).
| 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 | |
**Use case profiles: prompt tokens / generation tokens
**QPS: Queries per second.
**QPD: Queries per dollar, based on on-demand cost at Lambda Labs (observed on 2/18/2025).
model-00001-of-00002.safetensors 4.6 GiBmodel-00002-of-00002.safetensors 3.5 GiB