From 18b68be22e17b6ccb082f82ac46165ebeb05bc02 Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Thu, 2 Jul 2026 06:20:12 +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-Llama-8B-quantized.w8a8 Source: Original Platform --- .gitattributes | 36 ++ README.md | 782 +++++++++++++++++++++++++++++++ config.json | 3 + 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 | 21 + special_tokens_map.json | 23 + tokenizer.json | 3 + tokenizer_config.json | 3 + 12 files changed, 890 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..7e08363 --- /dev/null +++ b/README.md @@ -0,0 +1,782 @@ +--- +license: mit +tags: +- deepseek +- int8 +- vllm +- llmcompressor +base_model: deepseek-ai/DeepSeek-R1-Distill-Llama-8B +library_name: transformers +--- + +# DeepSeek-R1-Distill-Llama-8B-quantized.w8a8 + +## Model Overview +- **Model Architecture:** LlamaForCausalLM + - **Input:** Text + - **Output:** Text +- **Model Optimizations:** + - **Weight quantization:** INT8 + - **Activation quantization:** INT8 +- **Release Date:** 2/1/2025 +- **Version:** 1.0 +- **Model Developers:** Neural Magic + +Quantized version of [DeepSeek-R1-Distill-Llama-8B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-8B). + + +### Model Optimizations + +This model was obtained by quantizing the weights and activations of [DeepSeek-R1-Distill-Llama-8B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-8B) 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-Llama-8B-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-Llama-8B" +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=device_map, + 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.8), + 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-Llama-8B-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-Llama-8B-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-Llama-8Bneuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a8Recovery
ReasoningAIME 2024 (pass@1)49.2549.0799.63%
MATH-500 (pass@1)90.1890.0499.84%
GPQA Diamond (pass@1)49.2748.998.25%
Average Score62.962.6799.63%
OpenLLM V1ARC-Challenge (Acc-Norm, 25-shot)45.0545.22100.4%
GSM8K (Strict-Match, 5-shot)62.7762.0998.9%
HellaSwag (Acc-Norm, 10-shot)76.7876.80100.0%
MMLU (Acc, 5-shot)55.6555.5399.8%
TruthfulQA (MC2, 0-shot)50.5549.8998.7%
Winogrande (Acc, 5-shot)68.5167.4098.4%
Average Score59.8859.4999.3%
OpenLLM V2IFEval (Inst Level Strict Acc, 0-shot)38.3738.40100.1%
BBH (Acc-Norm, 3-shot)7.437.66---
Math-Hard (Exact-Match, 4-shot)0.000.00---
GPQA (Acc-Norm, 0-shot)1.511.47---
MUSR (Acc-Norm, 0-shot)1.861.27---
MMLU-Pro (Acc, 5-shot)1.611.48---
Average Score8.478.38---
CodingHumanEval (pass@1)49.9050.90102.0%
HumanEval (pass@10)68.9068.7099.7%
HumanEval+ (pass@10)44.1046.70105.9%
HumanEval+ (pass@10)62.9064.30102.2%
+ +## Inference Performance + + +This model achieves up to 1.6x speedup in single-stream deployment and up to 1.4x 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-Llama-8B-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-Llama-8B---3.015116.07553.014833.1146223.619124.018812.735341.1110
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a81.531.923563.811752.022912.0220715.229715.52908.553128.6157
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a162.351.238702.319181.334921.333359.14929.54725.877122.7198
A100x1deepseek-ai/DeepSeek-R1-Distill-Llama-8B---1.513083.16571.612741.6126312.116612.41626.530825.678
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a81.301.117632.38821.217161.216989.02239.22184.940925.778
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a161.760.825011.612360.923500.922876.43166.63063.754424.782
H100x1deepseek-ai/DeepSeek-R1-Distill-Llama-8B---1.011461.95741.011281.011117.61447.71424.126616.367
neuralmagic/DeepSeek-R1-Distill-Llama-8B-FP8-dynamic1.250.715671.47580.714840.714625.71915.81893.234722.549
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a161.300.715271.47680.714950.714635.61945.71903.135014.774
+ +**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-Llama-8B---12.6567425.7256876.5293495.2232591.672501.251810.834450.1616
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a81.3417.4781017.6343518.8397907.0315322.3104051.569601.043550.2785
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a160.9110.9489645.1229894.8217913.8170392.297261.254340.625440.1578
A100x1deepseek-ai/DeepSeek-R1-Distill-Llama-8B---24.54929611.32265713.02604710.5210203.570292.549951.735030.3659
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w8a81.2730.86204214.12841917.23455413.8277194.692993.162152.243310.4807
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a160.9722.74570810.52121611.1223538.9179393.977582.652411.631960.4718
H100x1deepseek-ai/DeepSeek-R1-Distill-Llama-8B---49.05359322.62475028.33097122.9250357.279125.155613.639390.6703
neuralmagic/DeepSeek-R1-Distill-Llama-8B-FP8-dynamic1.1457.16251726.02844034.53778128.7313607.278775.459234.346970.7782
neuralmagic/DeepSeek-R1-Distill-Llama-8B-quantized.w4a161.0149.85445222.92503528.53116223.0252006.874935.054313.740790.7787
+ +**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..c98daea --- /dev/null +++ b/config.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0238982feadcf40f008dcab19e3d76f91a7912e9d7f62b0504be656ef426bd4 +size 1967 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..f54b488 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,9 @@ +{ + "_from_model_config": true, + "bos_token_id": 128000, + "do_sample": true, + "eos_token_id": 128001, + "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..5e2fa29 --- /dev/null +++ b/model-00001-of-00002.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb98897044be304d944f0f1bbe4079c2b393f3b55a457606274bd7467b58ba4c +size 4999400864 diff --git a/model-00002-of-00002.safetensors b/model-00002-of-00002.safetensors new file mode 100644 index 0000000..5b79f57 --- /dev/null +++ b/model-00002-of-00002.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2e89e0c595786118d35ea92af2246345d041b886d90168aa8a235d96b549f7b +size 4084612496 diff --git a/model.safetensors.index.json b/model.safetensors.index.json new file mode 100644 index 0000000..889bb55 --- /dev/null +++ b/model.safetensors.index.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ed839beb27a9a1c3bef4e5f5b5011ba4c7dd8595770d17b85ea56df6a69d83e +size 43463 diff --git a/recipe.yaml b/recipe.yaml new file mode 100644 index 0000000..6d75bc2 --- /dev/null +++ b/recipe.yaml @@ -0,0 +1,21 @@ +quant_stage: + quant_modifiers: + SmoothQuantModifier: + smoothing_strength: 0.8 + 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..b8f14d8 --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9c9eb63a8e03059914880f918cd28a880dec8b6e15e4461e1ff677e3743dbb8 +size 9084480 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