commit 0c09548574c75efa7a086db57a67df464328093f Author: ModelHub XC Date: Thu Oct 22 08:22:17 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: RedHatAI/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a16 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..13d18d2 --- /dev/null +++ b/README.md @@ -0,0 +1,789 @@ +--- +license: mit +tags: +- deepseek +- int4 +- vllm +- llmcompressor +base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-32B +library_name: transformers +--- + +# DeepSeek-R1-Distill-Qwen-32B-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-32B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B). + + +### Model Optimizations + +This model was obtained by quantizing the weights of [DeepSeek-R1-Distill-Qwen-32B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B) 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-32B-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-32B" +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.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.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-32B-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-32B-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-32Bneuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a16Recovery
ReasoningAIME 2024 (pass@1)69.7568.8398.68%
MATH-500 (pass@1)95.0995.0199.92%
GPQA Diamond (pass@1)64.0563.7999.59%
Average Score76.375.8899.45%
OpenLLM V1ARC-Challenge (Acc-Norm, 25-shot)64.5963.6598.6%
GSM8K (Strict-Match, 5-shot)82.7184.38102.0%
HellaSwag (Acc-Norm, 10-shot)83.8083.3299.4%
MMLU (Acc, 5-shot)81.1280.9199.7%
TruthfulQA (MC2, 0-shot)58.4158.54100.2%
Winogrande (Acc, 5-shot)76.4075.1498.4%
Average Score74.5174.3299.8%
OpenLLM V2IFEval (Inst Level Strict Acc, 0-shot)42.8772.4899.1%
BBH (Acc-Norm, 3-shot)57.9657.5499.3%
Math-Hard (Exact-Match, 4-shot)0.000.00---
GPQA (Acc-Norm, 0-shot)26.9526.4198.0%
MUSR (Acc-Norm, 0-shot)43.9544.34100.9%
MMLU-Pro (Acc, 5-shot)49.8248.4397.2%
Average Score36.92%
CodingHumanEval (pass@1)86.0086.00100.0%
HumanEval (pass@10)92.5092.60100.1%
HumanEval+ (pass@10)82.0080.6098.3%
HumanEval+ (pass@10)88.7089.70101.1%
+ +## Inference Performance + + +This model achieves up to 3.4x speedup in single-stream deployment and up to 2.0x 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-32B-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
GPU classNumber of GPUsModelAverage cost reductionLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPD
A60002deepseek-ai/DeepSeek-R1-Distill-Qwen-32B---6.335912.81766.53476.634249.94550.84426.68583.427
1neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w8a81.816.964813.83257.26297.262254.88255.68130.015094.847
1neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a163.073.911687.85804.310414.697529.715130.914619.323361.473
A1001deepseek-ai/DeepSeek-R1-Distill-Qwen-32B---5.636111.11805.73505.834744.04644.74523.68573.727
1neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w8a81.503.75477.32753.85363.852829.06929.56815.712853.138
1neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a162.302.28944.54492.48312.579817.411618.011210.519149.541
H1001deepseek-ai/DeepSeek-R1-Distill-Qwen-32B---3.33276.71633.43203.431726.64126.94114.37747.823
1neuralmagic/DeepSeek-R1-Distill-Qwen-32B-FP8-dynamic1.522.25034.32522.24902.348517.36317.5639.511633.433
1neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a161.612.15324.12682.15162.151316.16816.5669.112031.934
+ +**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
A6000x2deepseek-ai/DeepSeek-R1-Distill-Qwen-32B---6.2139401.943482.761532.147780.613820.49300.36850.1124
neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w8a81.808.7194924.294744.192903.068021.227340.919620.511770.1254
neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a161.305.9133662.557332.454091.635251.227570.716630.36760.1214
A100x2deepseek-ai/DeepSeek-R1-Distill-Qwen-32B---12.9130165.858486.363485.151462.019881.514630.98690.2192
neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w8a81.5221.4214798.9894810.6106118.281973.030182.020541.212410.3264
neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a161.0913.5135686.565096.060754.747542.827901.616510.98620.2225
H100x2deepseek-ai/DeepSeek-R1-Distill-Qwen-32B---25.51439212.5703514.0787711.363643.620412.715491.910570.4200
neuralmagic/DeepSeek-R1-Distill-Qwen-32B-FP8-dynamic1.4646.72553820.31108223.31272818.4100495.328813.720972.614450.5256
neuralmagic/DeepSeek-R1-Distill-Qwen-32B-quantized.w4a161.2336.92017217.4950018.0982214.277555.329003.318672.312650.4241
+ +**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..e11969a --- /dev/null +++ b/config.json @@ -0,0 +1,61 @@ +{ + "_name_or_path": "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B", + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "bos_token_id": 151643, + "eos_token_id": 151643, + "hidden_act": "silu", + "hidden_size": 5120, + "initializer_range": 0.02, + "intermediate_size": 27648, + "max_position_embeddings": 131072, + "max_window_layers": 64, + "model_type": "qwen2", + "num_attention_heads": 40, + "num_hidden_layers": 64, + "num_key_value_heads": 8, + "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.088115267917011, + "ignore": [ + "lm_head" + ], + "kv_cache_scheme": null, + "quant_method": "compressed-tensors", + "quantization_status": "compressed", + "sparsity_config": {} + }, + "rms_norm_eps": 1e-05, + "rope_scaling": null, + "rope_theta": 1000000.0, + "sliding_window": null, + "tie_word_embeddings": false, + "torch_dtype": "bfloat16", + "transformers_version": "4.48.0", + "use_cache": true, + "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-00004.safetensors b/model-00001-of-00004.safetensors new file mode 100644 index 0000000..0576e2b --- /dev/null +++ b/model-00001-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d542328103dcdaef7846153d89aeca0a2f658d1cac4fa8a1710f5393f770436f +size 4931437664 diff --git a/model-00002-of-00004.safetensors b/model-00002-of-00004.safetensors new file mode 100644 index 0000000..664fea2 --- /dev/null +++ b/model-00002-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2cead7b5a33e99aff6a74bb30bcffd4f8601c70f92c1d50299fb967f2718e6c +size 4956016432 diff --git a/model-00003-of-00004.safetensors b/model-00003-of-00004.safetensors new file mode 100644 index 0000000..414965c --- /dev/null +++ b/model-00003-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a85f2c10e191e275862b378ca215aec96e9b5988365ac56e1ae8d9f3a37a23a1 +size 4996551064 diff --git a/model-00004-of-00004.safetensors b/model-00004-of-00004.safetensors new file mode 100644 index 0000000..494c066 --- /dev/null +++ b/model-00004-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b2aa1a2a45ecd355c74cd2276e5ab14a9a661dc90c94ecbe56a34b0b16d9ad7 +size 4323099720 diff --git a/model.safetensors.index.json b/model.safetensors.index.json new file mode 100644 index 0000000..66ab27c --- /dev/null +++ b/model.safetensors.index.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4254fbf3c846533a611a7ac5074eb88eb355fca6c5b8f39cfbf06eea59bc8a5d +size 144580 diff --git a/recipe.yaml b/recipe.yaml new file mode 100644 index 0000000..f466631 --- /dev/null +++ b/recipe.yaml @@ -0,0 +1,10 @@ +quant_stage: + quant_modifiers: + GPTQModifier: + dampening_frac: 0.1 + 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