初始化项目,由ModelHub XC社区提供模型
Model: RedHatAI/QwQ-32B-Preview-FP8-dynamic Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -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
|
||||||
168
README.md
Normal file
168
README.md
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
---
|
||||||
|
tags:
|
||||||
|
- fp8
|
||||||
|
- vllm
|
||||||
|
license: apache-2.0
|
||||||
|
license_link: https://huggingface.co/Qwen/QwQ-32B-Preview/blob/main/LICENSE
|
||||||
|
language:
|
||||||
|
- en
|
||||||
|
base_model: Qwen/Qwen2.5-32B-Instruct
|
||||||
|
library_name: transformers
|
||||||
|
---
|
||||||
|
|
||||||
|
# QwQ-32B-Preview-FP8-dynamic
|
||||||
|
|
||||||
|
## Model Overview
|
||||||
|
- **Model Architecture:** QwQ-32B-Preview
|
||||||
|
- **Input:** Text
|
||||||
|
- **Output:** Text
|
||||||
|
- **Model Optimizations:**
|
||||||
|
- **Weight quantization:** FP8
|
||||||
|
- **Activation quantization:** FP8
|
||||||
|
- **Release Date:** 3/1/2025
|
||||||
|
- **Version:** 1.0
|
||||||
|
- **Model Developers:** Neural Magic
|
||||||
|
|
||||||
|
Quantized version of [QwQ-32B-Preview](https://huggingface.co/Qwen/QwQ-32B-Preview).
|
||||||
|
It achieves an average score of 77.08 on the [OpenLLM](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) benchmark (version 1), whereas the unquantized model achieves 77.20.
|
||||||
|
|
||||||
|
### Model Optimizations
|
||||||
|
|
||||||
|
This model was obtained by quantizing the weights and activations of [QwQ-32B-Preview](https://huggingface.co/Qwen/QwQ-32B-Preview) to FP8 data type, ready for inference with vLLM >= 0.5.2.
|
||||||
|
This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%. Only the weights and activations of the linear operators within transformers blocks are quantized.
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
### 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
|
||||||
|
|
||||||
|
max_model_len, tp_size = 4096, 1
|
||||||
|
model_name = "neuralmagic-ent/QwQ-32B-Preview-FP8-dynamic"
|
||||||
|
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
||||||
|
llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True)
|
||||||
|
sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
|
||||||
|
|
||||||
|
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
|
||||||
|
import argparse
|
||||||
|
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||||
|
from llmcompressor.modifiers.quantization import QuantizationModifier
|
||||||
|
from llmcompressor.transformers import oneshot
|
||||||
|
import os
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description='Quantize a transformer model to FP8')
|
||||||
|
parser.add_argument('--model_id', type=str, required=True,
|
||||||
|
help='The model ID from HuggingFace (e.g., "meta-llama/Meta-Llama-3-8B-Instruct")')
|
||||||
|
parser.add_argument('--save_path', type=str, default='.',
|
||||||
|
help='Custom path to save the quantized model. If not provided, will use model_name-FP8-dynamic')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Load model
|
||||||
|
model = AutoModelForCausalLM.from_pretrained(
|
||||||
|
args.model_id, device_map="auto", torch_dtype="auto", trust_remote_code=True,
|
||||||
|
)
|
||||||
|
tokenizer = AutoTokenizer.from_pretrained(args.model_id)
|
||||||
|
|
||||||
|
# Configure the quantization algorithm and scheme
|
||||||
|
recipe = QuantizationModifier(
|
||||||
|
targets="Linear", scheme="FP8_DYNAMIC", ignore=["lm_head"]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Apply quantization
|
||||||
|
oneshot(model=model, recipe=recipe)
|
||||||
|
|
||||||
|
save_path = os.path.join(args.save_path, args.model_id.split("/")[1] + "-FP8-dynamic")
|
||||||
|
os.makedirs(save_path, exist_ok=True)
|
||||||
|
|
||||||
|
# Save to disk in compressed-tensors format
|
||||||
|
model.save_pretrained(save_path)
|
||||||
|
tokenizer.save_pretrained(save_path)
|
||||||
|
print(f"Model and tokenizer saved to: {save_path}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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-ent/QwQ-32B-Preview-FP8-dynamic",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=1,gpu_memory_utilization=0.8,enable_chunked_prefill=True,trust_remote_code=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-ent/QwQ-32B-Preview-FP8-dynamic",dtype=auto,add_bos_token=False,max_model_len=4096,tensor_parallel_size=1,gpu_memory_utilization=0.8,enable_chunked_prefill=True,trust_remote_code=True \
|
||||||
|
--apply_chat_template \
|
||||||
|
--fewshot_as_multiturn \
|
||||||
|
--tasks leaderboard \
|
||||||
|
--write_out \
|
||||||
|
--batch_size auto \
|
||||||
|
--output_path output_dir \
|
||||||
|
--show_config
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Accuracy
|
||||||
|
|
||||||
|
#### OpenLLM Leaderboard V1 evaluation scores
|
||||||
|
|
||||||
|
| Metric | Qwen/QwQ-32B-Preview | neuralmagic-ent/QwQ-32B-Preview-FP8-dynamic |
|
||||||
|
|-----------------------------------------|:---------------------------------:|:-------------------------------------------:|
|
||||||
|
| ARC-Challenge (Acc-Norm, 25-shot) | 70.73 | 71.08 |
|
||||||
|
| GSM8K (Strict-Match, 5-shot) | 83.09 | 82.18 |
|
||||||
|
| HellaSwag (Acc-Norm, 10-shot) | 85.77 | 85.88 |
|
||||||
|
| MMLU (Acc, 5-shot) | 82.67 | 82.67 |
|
||||||
|
| TruthfulQA (MC2, 0-shot) | 60.88 | 60.54 |
|
||||||
|
| Winogrande (Acc, 5-shot) | 80.03 | 80.11 |
|
||||||
|
| **Average Score** | **77.20** | **77.08** |
|
||||||
|
| **Recovery** | **100.00** | **99.84** |
|
||||||
|
|
||||||
|
#### OpenLLM Leaderboard V2 evaluation scores
|
||||||
|
|
||||||
|
| Metric | Qwen/QwQ-32B-Preview | neuralmagic-ent/QwQ-32B-Preview-FP8-dynamic |
|
||||||
|
|---------------------------------------------------------|:---------------------------------:|:-------------------------------------------:|
|
||||||
|
| IFEval (Inst-and-Prompt Level Strict Acc, 0-shot) | 42.34 | 40.48 |
|
||||||
|
| BBH (Acc-Norm, 3-shot) | 53.03 | 52.96 |
|
||||||
|
| Math-Hard (Exact-Match, 4-shot) | 21.15 | 20.82 |
|
||||||
|
| GPQA (Acc-Norm, 0-shot) | 2.97 | 1.99 |
|
||||||
|
| MUSR (Acc-Norm, 0-shot) | 9.57 | 10.93 |
|
||||||
|
| MMLU-Pro (Acc, 5-shot) | 52.00 | 51.62 |
|
||||||
|
| **Average Score** | **30.18** | **29.80** |
|
||||||
|
| **Recovery** | **100.00** | **98.74** |
|
||||||
|
|
||||||
24
added_tokens.json
Normal file
24
added_tokens.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"</tool_call>": 151658,
|
||||||
|
"<tool_call>": 151657,
|
||||||
|
"<|box_end|>": 151649,
|
||||||
|
"<|box_start|>": 151648,
|
||||||
|
"<|endoftext|>": 151643,
|
||||||
|
"<|file_sep|>": 151664,
|
||||||
|
"<|fim_middle|>": 151660,
|
||||||
|
"<|fim_pad|>": 151662,
|
||||||
|
"<|fim_prefix|>": 151659,
|
||||||
|
"<|fim_suffix|>": 151661,
|
||||||
|
"<|im_end|>": 151645,
|
||||||
|
"<|im_start|>": 151644,
|
||||||
|
"<|image_pad|>": 151655,
|
||||||
|
"<|object_ref_end|>": 151647,
|
||||||
|
"<|object_ref_start|>": 151646,
|
||||||
|
"<|quad_end|>": 151651,
|
||||||
|
"<|quad_start|>": 151650,
|
||||||
|
"<|repo_name|>": 151663,
|
||||||
|
"<|video_pad|>": 151656,
|
||||||
|
"<|vision_end|>": 151653,
|
||||||
|
"<|vision_pad|>": 151654,
|
||||||
|
"<|vision_start|>": 151652
|
||||||
|
}
|
||||||
3
config.json
Normal file
3
config.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:ad1981c4c8f40f444b5e6348222a0d5e3fad39de0680e1f74582e3e5001e59fe
|
||||||
|
size 1801
|
||||||
1
configuration.json
Normal file
1
configuration.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"framework": "pytorch", "task": "text-generation", "allow_remote": true}
|
||||||
13
generation_config.json
Normal file
13
generation_config.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"bos_token_id": 151643,
|
||||||
|
"do_sample": true,
|
||||||
|
"eos_token_id": [
|
||||||
|
151645,
|
||||||
|
151643
|
||||||
|
],
|
||||||
|
"pad_token_id": 151643,
|
||||||
|
"temperature": 0.7,
|
||||||
|
"top_k": 20,
|
||||||
|
"top_p": 0.8,
|
||||||
|
"transformers_version": "4.46.2"
|
||||||
|
}
|
||||||
BIN
merges.txt
(Stored with Git LFS)
Normal file
BIN
merges.txt
(Stored with Git LFS)
Normal file
Binary file not shown.
3
model-00001-of-00007.safetensors
Normal file
3
model-00001-of-00007.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:bbffc52dae3231d5a4557509bb51c96d668099c1cd62b88bb3e5c4d64f8056d8
|
||||||
|
size 4997762744
|
||||||
3
model-00002-of-00007.safetensors
Normal file
3
model-00002-of-00007.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:bcc7259beaf742d18c8c852ffdbb5f4bb44f7f2cfcf4d7ca5766ba7de2ed8900
|
||||||
|
size 4914421680
|
||||||
3
model-00003-of-00007.safetensors
Normal file
3
model-00003-of-00007.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:7cc60d2c02b6483ea3925766520b864c9cd3aacacc81780a14de643176acb36b
|
||||||
|
size 4877702248
|
||||||
3
model-00004-of-00007.safetensors
Normal file
3
model-00004-of-00007.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:42d74595a0cbfdc89777b73902f555414a84f7b8cd4d55d40e2624c6cc4731c2
|
||||||
|
size 4877702248
|
||||||
3
model-00005-of-00007.safetensors
Normal file
3
model-00005-of-00007.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:138cd6b5383f92247f7c07ccc80c7796e487c95d754157ab5e3257413acff970
|
||||||
|
size 4877702248
|
||||||
3
model-00006-of-00007.safetensors
Normal file
3
model-00006-of-00007.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:dc98d930166e3f322fb0c7d3d6fab93255e7b9d6eb9dea8d4bbc1787a59dcd4a
|
||||||
|
size 4877702248
|
||||||
3
model-00007-of-00007.safetensors
Normal file
3
model-00007-of-00007.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:329d13b64081bcbf80041d0a5faafda19ec0e0b8f3c9b344d8a8a66347859c70
|
||||||
|
size 4908583200
|
||||||
3
model.safetensors.index.json
Normal file
3
model.safetensors.index.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:ecb9438a33bfc025000cd8575afc73dec022f58d448a1ac920cdbe1adca60e82
|
||||||
|
size 102346
|
||||||
6
recipe.yaml
Normal file
6
recipe.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
DEFAULT_stage:
|
||||||
|
DEFAULT_modifiers:
|
||||||
|
QuantizationModifier:
|
||||||
|
ignore: [lm_head]
|
||||||
|
targets: [Linear]
|
||||||
|
scheme: FP8_DYNAMIC
|
||||||
31
special_tokens_map.json
Normal file
31
special_tokens_map.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"additional_special_tokens": [
|
||||||
|
"<|im_start|>",
|
||||||
|
"<|im_end|>",
|
||||||
|
"<|object_ref_start|>",
|
||||||
|
"<|object_ref_end|>",
|
||||||
|
"<|box_start|>",
|
||||||
|
"<|box_end|>",
|
||||||
|
"<|quad_start|>",
|
||||||
|
"<|quad_end|>",
|
||||||
|
"<|vision_start|>",
|
||||||
|
"<|vision_end|>",
|
||||||
|
"<|vision_pad|>",
|
||||||
|
"<|image_pad|>",
|
||||||
|
"<|video_pad|>"
|
||||||
|
],
|
||||||
|
"eos_token": {
|
||||||
|
"content": "<|im_end|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": false,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"pad_token": {
|
||||||
|
"content": "<|endoftext|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": false,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
}
|
||||||
|
}
|
||||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
|
||||||
|
size 11421896
|
||||||
3
tokenizer_config.json
Normal file
3
tokenizer_config.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:5e3278dffb14189645457aebd8f8426551a470264c7ac0dd0adfa6c9944f2088
|
||||||
|
size 7383
|
||||||
BIN
vocab.json
(Stored with Git LFS)
Normal file
BIN
vocab.json
(Stored with Git LFS)
Normal file
Binary file not shown.
Reference in New Issue
Block a user