commit c755d7f6f8bb5f78441e391ffb4996df3ad50bd0 Author: ModelHub XC Date: Thu Jul 2 06:44:12 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: RedHatAI/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..52373fe --- /dev/null +++ b/.gitattributes @@ -0,0 +1,36 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +tokenizer.json filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5d82a2 --- /dev/null +++ b/README.md @@ -0,0 +1,783 @@ +--- +license: mit +tags: +- deepseek +- int8 +- vllm +- llmcompressor +base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B +library_name: transformers +--- + +# DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 + +## Model Overview +- **Model Architecture:** Qwen2ForCausalLM + - **Input:** Text + - **Output:** Text +- **Model Optimizations:** + - **Weight quantization:** INT8 + - **Activation quantization:** INT8 +- **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 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](https://arxiv.org/abs/2210.17323) algorithm is applied for quantization, as implemented in the [llm-compressor](https://github.com/vllm-project/llm-compressor) library. + + +## 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-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](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.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}") +``` + +## 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-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 +``` + +### Accuracy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CategoryMetricdeepseek-ai/DeepSeek-R1-Distill-Qwen-7Bneuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8Recovery
ReasoningAIME 2024 (pass@1)53.1755.19103.8%
MATH-500 (pass@1)93.669399.3%
GPQA Diamond (pass@1)50.5350.65100.24%
Average Score65.7966.28100.74%
OpenLLM V1ARC-Challenge (Acc-Norm, 25-shot)50.5150.51100.0%
GSM8K (Strict-Match, 5-shot)78.6279.83101.5%
HellaSwag (Acc-Norm, 10-shot)61.9061.6299.6%
MMLU (Acc, 5-shot)54.1953.7699.2%
TruthfulQA (MC2, 0-shot)45.5546.14101.3%
Winogrande (Acc, 5-shot)61.5660.5498.33%
Average Score58.7258.73100.0%
OpenLLM V2IFEval (Inst Level Strict Acc, 0-shot)39.3840.20102.1%
BBH (Acc-Norm, 3-shot)6.976.10---
Math-Hard (Exact-Match, 4-shot)0.000.00---
GPQA (Acc-Norm, 0-shot)1.810.90---
MUSR (Acc-Norm, 0-shot)4.684.04---
MMLU-Pro (Acc, 5-shot)1.661.73---
Average Score9.088.83---
CodingHumanEval (pass@1)40.8039.5096.8%
HumanEval (pass@10)64.4062.1096.4%
HumanEval+ (pass@10)38.5037.2096.6%
HumanEval+ (pass@10)60.4059.3098.2%
+ + +## Inference Performance + + +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](https://docs.vllm.ai/en/latest/) version 0.7.2, and [GuideLLM](https://github.com/neuralmagic/guidellm). + +
+Benchmarking Command + +``` +guidellm --model neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a8 --target "http://localhost:8000/v1" --data-type emulated --data "prompt_tokens=,generated_tokens=" --max seconds 360 --backend aiohttp_server +``` +
+ +### Single-stream performance (measured with vLLM version 0.7.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
HardwareModelAverage cost reductionLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPD
A6000x1deepseek-ai/DeepSeek-R1-Distill-Qwen-7B---2.915765.77882.915353.0149622.619923.219412.137038.5117
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a81.561.824953.712231.923841.9239314.331514.83047.957225.3178
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a162.411.140862.319981.237831.335278.65268.85125.286022.7198
A100x1deepseek-ai/DeepSeek-R1-Distill-Qwen-7B---1.413892.96911.513581.5132911.517511.61746.232621.593
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a81.281.118502.29051.118071.117508.62338.72304.743123.187
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a161.720.825751.512980.824610.823826.13316.23233.656622.789
H100x1deepseek-ai/DeepSeek-R1-Distill-Qwen-7B---0.911611.95791.011381.011217.51467.61453.927915.471
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-FP8-dynamic1.340.715851.47860.715770.715245.32075.51972.938214.377
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a161.330.715901.47930.715490.715095.42015.51982.938114.078
+ +**Use case profiles: prompt tokens / generation tokens + +**QPD: Queries per dollar, based on on-demand cost at [Lambda Labs](https://lambdalabs.com/service/gpu-cloud) (observed on 2/18/2025). + + +### Multi-stream asynchronous performance (measured with vLLM version 0.7.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
HardwareModelAverage cost reductionMaximum throughput (QPS)QPDMaximum throughput (QPS)QPDMaximum throughput (QPS)QPDMaximum throughput (QPS)QPDMaximum throughput (QPS)QPDMaximum throughput (QPS)QPDMaximum throughput (QPS)QPDMaximum throughput (QPS)QPD
A6000x1deepseek-ai/DeepSeek-R1-Distill-Qwen-7B---14.9671387.1320947.4330965.9264802.090041.566391.149380.31151
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a81.3620.2909568.83978610.2459638.1365963.1139682.196291.463740.31429
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a161.0013.3596816.1276335.9266894.7209442.9131081.983551.043620.31170
A100x1deepseek-ai/DeepSeek-R1-Distill-Qwen-7B---26.45307313.02621314.52911011.4229364.487493.366802.346340.51105
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w8a81.2734.36900914.82979119.03821415.7315985.6111864.283503.060200.71328
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a160.9323.94799312.02419412.52523910.0200294.590553.366812.141560.51043
H100x1deepseek-ai/DeepSeek-R1-Distill-Qwen-7B---54.35941026.02844032.13515426.7291908.087006.672755.256691.21266
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-FP8-dynamic1.1662.96881830.33319639.44313231.1340739.2100587.177486.167141.31415
neuralmagic/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a161.0256.26148326.72924332.53559226.9294618.390726.470275.257311.21291
+ +**Use case profiles: prompt tokens / generation tokens + +**QPS: Queries per second. + +**QPD: Queries per dollar, based on on-demand cost at [Lambda Labs](https://lambdalabs.com/service/gpu-cloud) (observed on 2/18/2025). diff --git a/config.json b/config.json new file mode 100644 index 0000000..4daa46d --- /dev/null +++ b/config.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8bed7317068d2d914e477a6c8a37324f9f9231d6b05e88b44f2c436c05867177 +size 1831 diff --git a/configuration.json b/configuration.json new file mode 100644 index 0000000..bbeeda1 --- /dev/null +++ b/configuration.json @@ -0,0 +1 @@ +{"framework": "pytorch", "task": "text-generation", "allow_remote": true} \ No newline at end of file diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..f40ad03 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,9 @@ +{ + "_from_model_config": true, + "bos_token_id": 151646, + "do_sample": true, + "eos_token_id": 151643, + "temperature": 0.6, + "top_p": 0.95, + "transformers_version": "4.48.0" +} diff --git a/model-00001-of-00002.safetensors b/model-00001-of-00002.safetensors new file mode 100644 index 0000000..c300b0d --- /dev/null +++ b/model-00001-of-00002.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2fff4b44f0f6480741177898ad875d8cc2d3e61f1f324ed5bc4ff93a6e31e571 +size 4985986104 diff --git a/model-00002-of-00002.safetensors b/model-00002-of-00002.safetensors new file mode 100644 index 0000000..3b4bdd0 --- /dev/null +++ b/model-00002-of-00002.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e615cb42da0232d0dc4782addcb9eae60d4cf1c0f06238a94e7d9a40b0c2ceab +size 3722801480 diff --git a/model.safetensors.index.json b/model.safetensors.index.json new file mode 100644 index 0000000..2f59f70 --- /dev/null +++ b/model.safetensors.index.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9032d296d5fdc3b749bdd1d5e5353e4d6545b908376d2e40c6f0c7081d786329 +size 44817 diff --git a/recipe.yaml b/recipe.yaml new file mode 100644 index 0000000..c27dd6d --- /dev/null +++ b/recipe.yaml @@ -0,0 +1,21 @@ +quant_stage: + quant_modifiers: + SmoothQuantModifier: + smoothing_strength: 0.7 + mappings: + - - ['re:.*q_proj', 're:.*k_proj', 're:.*v_proj'] + - re:.*input_layernorm + - - ['re:.*gate_proj', 're:.*up_proj'] + - re:.*post_attention_layernorm + - - ['re:.*down_proj'] + - re:.*up_proj + GPTQModifier: + sequential_update: true + dampening_frac: 0.1 + ignore: [lm_head] + config_groups: + group_0: + targets: [Linear] + weights: {num_bits: 8, type: int, symmetric: true, strategy: channel, observer: mse} + input_activations: {num_bits: 8, type: int, symmetric: true, strategy: token, dynamic: true, + observer: memoryless} diff --git a/special_tokens_map.json b/special_tokens_map.json new file mode 100644 index 0000000..1d385d6 --- /dev/null +++ b/special_tokens_map.json @@ -0,0 +1,23 @@ +{ + "bos_token": { + "content": "<|begin▁of▁sentence|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "eos_token": { + "content": "<|end▁of▁sentence|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "pad_token": { + "content": "<|end▁of▁sentence|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + } +} diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..8e71bf3 --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88145e3c3249adc2546ede277e9819d6e405e19072456e4b521cbc724bd60773 +size 7031660 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..1046e6c --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ac8c85fb242563c2260baec0909debd69d718af6a0b3d90e6cab62b4d341cd5 +size 3071