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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
base_model:
|
| 6 |
+
- Qwen/Qwen3-235B-A22B
|
| 7 |
+
tags:
|
| 8 |
+
- neuralmagic
|
| 9 |
+
- redhat
|
| 10 |
+
- llmcompressor
|
| 11 |
+
- quantized
|
| 12 |
+
- FP8
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Qwen3-235B-A22B-FP8-dynamic
|
| 16 |
+
|
| 17 |
+
## Model Overview
|
| 18 |
+
- **Model Architecture:** Qwen3MoeForCausalLM
|
| 19 |
+
- **Input:** Text
|
| 20 |
+
- **Output:** Text
|
| 21 |
+
- **Model Optimizations:**
|
| 22 |
+
- **Activation quantization:** FP8
|
| 23 |
+
- **Weight quantization:** FP8
|
| 24 |
+
- **Intended Use Cases:**
|
| 25 |
+
- Reasoning.
|
| 26 |
+
- Function calling.
|
| 27 |
+
- Subject matter experts via fine-tuning.
|
| 28 |
+
- Multilingual instruction following.
|
| 29 |
+
- Translation.
|
| 30 |
+
- **Out-of-scope:** Use in any manner that violates applicable laws or regulations (including trade compliance laws).
|
| 31 |
+
- **Release Date:** 05/05/2025
|
| 32 |
+
- **Version:** 1.0
|
| 33 |
+
- **Model Developers:** RedHat (Neural Magic)
|
| 34 |
+
|
| 35 |
+
### Model Optimizations
|
| 36 |
+
|
| 37 |
+
This model was obtained by quantizing activations and weights of [Qwen3-235B-A22B](https://huggingface.co/Qwen/Qwen3-235B-A22B) to FP8 data type.
|
| 38 |
+
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).
|
| 39 |
+
Weight quantization also reduces disk size requirements by approximately 50%.
|
| 40 |
+
|
| 41 |
+
Only weights and activations of the linear operators within transformers blocks are quantized.
|
| 42 |
+
Weights are quantized with a symmetric static per-channel scheme, whereas activations are quantized with a symmetric dynamic per-token scheme.
|
| 43 |
+
The [llm-compressor](https://github.com/vllm-project/llm-compressor) library is used for quantization.
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
## Deployment
|
| 47 |
+
|
| 48 |
+
This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
from vllm import LLM, SamplingParams
|
| 52 |
+
from transformers import AutoTokenizer
|
| 53 |
+
|
| 54 |
+
model_id = "RedHatAI/Qwen3-235B-A22B-FP8-dynamic"
|
| 55 |
+
number_gpus = 4
|
| 56 |
+
sampling_params = SamplingParams(temperature=0.6, top_p=0.95, top_k=20, min_p=0, max_tokens=256)
|
| 57 |
+
|
| 58 |
+
messages = [
|
| 59 |
+
{"role": "user", "content": prompt}
|
| 60 |
+
]
|
| 61 |
+
|
| 62 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 63 |
+
|
| 64 |
+
messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
|
| 65 |
+
|
| 66 |
+
prompts = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
| 67 |
+
|
| 68 |
+
llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
|
| 69 |
+
|
| 70 |
+
outputs = llm.generate(prompts, sampling_params)
|
| 71 |
+
|
| 72 |
+
generated_text = outputs[0].outputs[0].text
|
| 73 |
+
print(generated_text)
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
|
| 77 |
+
|
| 78 |
+
## Creation
|
| 79 |
+
|
| 80 |
+
<details>
|
| 81 |
+
<summary>Creation details</summary>
|
| 82 |
+
This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below.
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
```python
|
| 86 |
+
from llmcompressor.modifiers.quantization import QuantizationModifier
|
| 87 |
+
from llmcompressor.transformers import oneshot
|
| 88 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 89 |
+
|
| 90 |
+
# Load model
|
| 91 |
+
model_stub = "Qwen/Qwen3-235B-A22B"
|
| 92 |
+
model_name = model_stub.split("/")[-1]
|
| 93 |
+
|
| 94 |
+
model = AutoModelForCausalLM.from_pretrained(model_stub)
|
| 95 |
+
|
| 96 |
+
tokenizer = AutoTokenizer.from_pretrained(model_stub)
|
| 97 |
+
|
| 98 |
+
# Configure the quantization algorithm and scheme
|
| 99 |
+
recipe = QuantizationModifier(
|
| 100 |
+
ignore=["lm_head"],
|
| 101 |
+
targets="Linear",
|
| 102 |
+
scheme="FP8_dynamic",
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
# Apply quantization
|
| 106 |
+
oneshot(
|
| 107 |
+
model=model,
|
| 108 |
+
recipe=recipe,
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
# Save to disk in compressed-tensors format
|
| 112 |
+
save_path = model_name + "-FP8-dynamic"
|
| 113 |
+
model.save_pretrained(save_path)
|
| 114 |
+
tokenizer.save_pretrained(save_path)
|
| 115 |
+
print(f"Model and tokenizer saved to: {save_path}")
|
| 116 |
+
```
|
| 117 |
+
</details>
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
## Evaluation
|
| 122 |
+
|
| 123 |
+
The model was evaluated on the OpenLLM leaderboard tasks (version 1), using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) and [vLLM](https://docs.vllm.ai/en/stable/).
|
| 124 |
+
|
| 125 |
+
<details>
|
| 126 |
+
<summary>Evaluation details</summary>
|
| 127 |
+
|
| 128 |
+
```
|
| 129 |
+
lm_eval \
|
| 130 |
+
--model vllm \
|
| 131 |
+
--model_args pretrained="RedHatAI/Qwen3-235B-A22B-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=4 \
|
| 132 |
+
--tasks openllm \
|
| 133 |
+
--apply_chat_template\
|
| 134 |
+
--fewshot_as_multiturn \
|
| 135 |
+
--batch_size auto
|
| 136 |
+
```
|
| 137 |
+
</details>
|
| 138 |
+
|
| 139 |
+
### Accuracy
|
| 140 |
+
|
| 141 |
+
<table>
|
| 142 |
+
<tr>
|
| 143 |
+
<th>Category
|
| 144 |
+
</th>
|
| 145 |
+
<th>Benchmark
|
| 146 |
+
</th>
|
| 147 |
+
<th>Qwen3-235B-A22B
|
| 148 |
+
</th>
|
| 149 |
+
<th>Qwen3-235B-A22B-FP8-dynamic<br>(this model)
|
| 150 |
+
</th>
|
| 151 |
+
<th>Recovery
|
| 152 |
+
</th>
|
| 153 |
+
</tr>
|
| 154 |
+
<tr>
|
| 155 |
+
<td rowspan="7" ><strong>OpenLLM v1</strong>
|
| 156 |
+
</td>
|
| 157 |
+
<td>MMLU (5-shot)
|
| 158 |
+
</td>
|
| 159 |
+
<td>84.77
|
| 160 |
+
</td>
|
| 161 |
+
<td>84.61
|
| 162 |
+
</td>
|
| 163 |
+
<td>99.8%
|
| 164 |
+
</td>
|
| 165 |
+
</tr>
|
| 166 |
+
<tr>
|
| 167 |
+
<td>ARC Challenge (25-shot)
|
| 168 |
+
</td>
|
| 169 |
+
<td>71.84
|
| 170 |
+
</td>
|
| 171 |
+
<td>70.90
|
| 172 |
+
</td>
|
| 173 |
+
<td>98.7%
|
| 174 |
+
</td>
|
| 175 |
+
</tr>
|
| 176 |
+
<tr>
|
| 177 |
+
<td>GSM-8K (5-shot, strict-match)
|
| 178 |
+
</td>
|
| 179 |
+
<td>74.22
|
| 180 |
+
</td>
|
| 181 |
+
<td>74.98
|
| 182 |
+
</td>
|
| 183 |
+
<td>101.0%
|
| 184 |
+
</td>
|
| 185 |
+
</tr>
|
| 186 |
+
<tr>
|
| 187 |
+
<td>Hellaswag (10-shot)
|
| 188 |
+
</td>
|
| 189 |
+
<td>76.56
|
| 190 |
+
</td>
|
| 191 |
+
<td>76.10
|
| 192 |
+
</td>
|
| 193 |
+
<td>99.4%
|
| 194 |
+
</td>
|
| 195 |
+
</tr>
|
| 196 |
+
<tr>
|
| 197 |
+
<td>Winogrande (5-shot)
|
| 198 |
+
</td>
|
| 199 |
+
<td>73.95
|
| 200 |
+
</td>
|
| 201 |
+
<td>75.06
|
| 202 |
+
</td>
|
| 203 |
+
<td>101.5%
|
| 204 |
+
</td>
|
| 205 |
+
</tr>
|
| 206 |
+
<tr>
|
| 207 |
+
<td>TruthfulQA (0-shot, mc2)
|
| 208 |
+
</td>
|
| 209 |
+
<td>61.18
|
| 210 |
+
</td>
|
| 211 |
+
<td>60.93
|
| 212 |
+
</td>
|
| 213 |
+
<td>99.6%
|
| 214 |
+
</td>
|
| 215 |
+
</tr>
|
| 216 |
+
<tr>
|
| 217 |
+
<td><strong>Average</strong>
|
| 218 |
+
</td>
|
| 219 |
+
<td><strong>73.75</strong>
|
| 220 |
+
</td>
|
| 221 |
+
<td><strong>73.76</strong>
|
| 222 |
+
</td>
|
| 223 |
+
<td><strong>100.0%</strong>
|
| 224 |
+
</td>
|
| 225 |
+
</tr>
|
| 226 |
+
</table>
|