From cb756eb60a26625746b8439260019ded523234d6 Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Tue, 29 Sep 2026 02:56:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E7=94=B1ModelHub=20XC=E7=A4=BE=E5=8C=BA=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Model: RedHatAI/DeepSeek-R1-Distill-Qwen-7B-quantized.w4a16 Source: Original Platform --- .gitattributes | 36 ++ README.md | 779 +++++++++++++++++++++++++++++++ config.json | 62 +++ configuration.json | 1 + generation_config.json | 9 + model-00001-of-00002.safetensors | 3 + model-00002-of-00002.safetensors | 3 + model.safetensors.index.json | 3 + recipe.yaml | 10 + special_tokens_map.json | 23 + tokenizer.json | 3 + tokenizer_config.json | 3 + 12 files changed, 935 insertions(+) create mode 100644 .gitattributes create mode 100644 README.md create mode 100644 config.json create mode 100644 configuration.json create mode 100644 generation_config.json create mode 100644 model-00001-of-00002.safetensors create mode 100644 model-00002-of-00002.safetensors create mode 100644 model.safetensors.index.json create mode 100644 recipe.yaml create mode 100644 special_tokens_map.json create mode 100644 tokenizer.json create mode 100644 tokenizer_config.json 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..9e2f52b --- /dev/null +++ b/README.md @@ -0,0 +1,779 @@ +--- +license: mit +tags: +- deepseek +- int4 +- vllm +- llmcompressor +base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-7B +library_name: transformers +--- + +# DeepSeek-R1-Distill-Qwen-7B-quantized.w4a16 + +## Model Overview +- **Model Architecture:** Qwen2ForCausalLM + - **Input:** Text + - **Output:** Text +- **Model Optimizations:** + - **Weight quantization:** INT4 +- **Release Date:** 2/4/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 of [DeepSeek-R1-Distill-Qwen-7B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B) to INT4 data type. +This optimization reduces the number of bits per parameter from 16 to 4, reducing the disk size and GPU memory requirements by approximately 75%. + + +Only the weights of the linear operators within transformers blocks are quantized. +Weights are quantized using a symmetric per-group scheme, with group size 128. +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.w4a16" + +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 = 2048 +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 = QuantizationModifier( + targets="Linear", + scheme="W4A16", + ignore=["lm_head"], + dampening_frac=0.01, +) + +# 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.w4a16 +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.w4a16",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.w4a16",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.w4a16Recovery
ReasoningAIME 2024 (pass@1)53.1750.8895.69%
MATH-500 (pass@1)93.6693.3399.65%
GPQA Diamond (pass@1)50.5349.8498.63%
Average Score65.7964.6898.31%
OpenLLM V1ARC-Challenge (Acc-Norm, 25-shot)50.51%
GSM8K (Strict-Match, 5-shot)78.62%
HellaSwag (Acc-Norm, 10-shot)61.90%
MMLU (Acc, 5-shot)54.19%
TruthfulQA (MC2, 0-shot)45.55%
Winogrande (Acc, 5-shot)61.56%
Average Score58.72%
OpenLLM V2IFEval (Inst Level Strict Acc, 0-shot)39.3839.38100.0%
BBH (Acc-Norm, 3-shot)6.977.48---
Math-Hard (Exact-Match, 4-shot)0.000.00---
GPQA (Acc-Norm, 0-shot)1.810.99---
MUSR (Acc-Norm, 0-shot)4.683.80---
MMLU-Pro (Acc, 5-shot)1.661.74---
Average Score9.088.90---
CodingHumanEval (pass@1)40.8048.50118.9%
HumanEval (pass@10)64.4067.10104.2%
HumanEval+ (pass@10)38.5045.00116.9%
HumanEval+ (pass@10)60.4064.10106.1%
+ + +## Inference Performance + + +This model achieves up to 2.6x speedup in single-stream deployment and up to 1.5x speedup in 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.w4a16 --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). \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..15e6d49 --- /dev/null +++ b/config.json @@ -0,0 +1,62 @@ +{ + "_name_or_path": "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B", + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "bos_token_id": 151643, + "eos_token_id": 151643, + "hidden_act": "silu", + "hidden_size": 3584, + "initializer_range": 0.02, + "intermediate_size": 18944, + "max_position_embeddings": 131072, + "max_window_layers": 28, + "model_type": "qwen2", + "num_attention_heads": 28, + "num_hidden_layers": 28, + "num_key_value_heads": 4, + "quantization_config": { + "config_groups": { + "group_0": { + "input_activations": null, + "output_activations": null, + "targets": [ + "Linear" + ], + "weights": { + "actorder": "weight", + "block_structure": null, + "dynamic": false, + "group_size": 128, + "num_bits": 4, + "observer": "mse", + "observer_kwargs": {}, + "strategy": "group", + "symmetric": true, + "type": "int" + } + } + }, + "format": "pack-quantized", + "global_compression_ratio": 2.070538700752354, + "ignore": [ + "lm_head" + ], + "kv_cache_scheme": null, + "quant_method": "compressed-tensors", + "quantization_status": "compressed", + "sparsity_config": {} + }, + "rms_norm_eps": 1e-06, + "rope_scaling": null, + "rope_theta": 10000, + "sliding_window": null, + "tie_word_embeddings": false, + "torch_dtype": "bfloat16", + "transformers_version": "4.48.0", + "use_cache": true, + "use_mrope": false, + "use_sliding_window": false, + "vocab_size": 152064 +} 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..7c976e3 --- /dev/null +++ b/model-00001-of-00002.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d841bf40ebee62d0d3489005e4206de901bb519ee9a16c1358ce85b2cee7868 +size 4455349216 diff --git a/model-00002-of-00002.safetensors b/model-00002-of-00002.safetensors new file mode 100644 index 0000000..ef3b83a --- /dev/null +++ b/model-00002-of-00002.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7946740ab848b4a02904f05bff81211bf9600fc20bfad39bbcc8d1703a40ce1c +size 1089994880 diff --git a/model.safetensors.index.json b/model.safetensors.index.json new file mode 100644 index 0000000..80087b0 --- /dev/null +++ b/model.safetensors.index.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c90a93b01f73615aa744eba7e5cda7e7f691262404495b029077d515ac600635 +size 63255 diff --git a/recipe.yaml b/recipe.yaml new file mode 100644 index 0000000..2250fc2 --- /dev/null +++ b/recipe.yaml @@ -0,0 +1,10 @@ +quant_stage: + quant_modifiers: + GPTQModifier: + dampening_frac: 0.01 + ignore: [lm_head] + config_groups: + group_0: + weights: {num_bits: 4, type: int, symmetric: true, strategy: group, group_size: 128, + actorder: weight, observer: mse} + targets: [Linear] 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