|
--- |
|
license: apache-2.0 |
|
license_link: https://huggingface.co/Qwen/Qwen3-235B-A22B/blob/main/LICENSE |
|
pipeline_tag: text-generation |
|
tags: |
|
- Qwen3 |
|
- gptq |
|
- int8 |
|
- 量化修复 |
|
- vLLM |
|
base_model: |
|
- Qwen/Qwen3-235B-A22B |
|
base_model_relation: quantized |
|
--- |
|
# Qwen3-235B-A22B-GPTQ-Int8 |
|
Base Model [Qwen/Qwen3-235B-A22B](https://www.modelscope.cn/models/Qwen/Qwen3-235B-A22B) |
|
|
|
### 【Model Update Date】 |
|
``` |
|
2025-05-09 |
|
1. fast commit |
|
2. Confirmed support for launching with 8 GPUs using `tensor-parallel-size` + `expert-parallel` |
|
3. Must be launched with `gptq_marlin`; does not support Compute 7 GPUs: vLLM has not implemented native GPTQ MoE module |
|
``` |
|
|
|
### 【Dependencies】 |
|
|
|
``` |
|
vllm==0.8.5 |
|
transformers==4.51.3 |
|
``` |
|
|
|
<div style=" |
|
background: rgba(255, 193, 61, 0.15); |
|
padding: 16px; |
|
border-radius: 6px; |
|
border: 1px solid rgba(255, 165, 0, 0.3); |
|
margin: 16px 0; |
|
"> |
|
### 【💡Notes on New VLLM MoE Versions💡】 |
|
|
|
#### 1. V0 Inference Mode is Required |
|
Before launching vLLM, set the following environment variable |
|
``` |
|
export VLLM_USE_V1=0 |
|
``` |
|
|
|
#### 2. A Small Bug Exists in gptq_marlin.py and Requires Patching |
|
Replace the file in your installation with the attached version at: |
|
|
|
```.../vllm/model_executor/layers/quantization/gptq_marlin.py``` |
|
|
|
Otherwise, you may encounter the following error: |
|
``` |
|
raise NotImplementedError( |
|
NotImplementedError: Apply router weight on input is not supported forfused Marlin MoE method. |
|
``` |
|
</div> |
|
|
|
<div style=" |
|
background: rgba(255, 0, 200, 0.15); |
|
padding: 16px; |
|
border-radius: 6px; |
|
border: 1px solid rgba(255, 0, 200, 0.3); |
|
margin: 16px 0; |
|
"> |
|
### 【💡Notes on Qwen3-235B-A22B💡】 |
|
|
|
#### 1. When launching vLLM, remember to enable expert parallelism (--enable-expert-parallel), otherwise multi-GPU launch on a single node (e.g., 8 GPUs) will fail. |
|
Example Launch Command: |
|
```commandline |
|
vllm serve \ |
|
QuantTrio/Qwen3-235B-A22B-GPTQ-Int8 \ |
|
--served-model-name Qwen3-235B-A22B-GPTQ-Int8 \ |
|
--max-num-seqs 8 \ |
|
--max-model-len 32768 \ |
|
--max-seq-len-to-capture 32768 \ |
|
--gpu-memory-utilization 0.98 \ |
|
--tensor-parallel-size 8 \ |
|
--enable-expert-parallel \ |
|
--disable-log-requests \ |
|
--trust-remote-code |
|
``` |
|
</div> |
|
|
|
|
|
### 【Model List】 |
|
|
|
| FILE SIZE | LATEST UPDATE TIME | |
|
|---------|--------------| |
|
| `226GB` | `2025-05-09` | |
|
|
|
|
|
|
|
### 【Model Download】 |
|
|
|
```python |
|
from huggingface_hub import snapshot_download |
|
snapshot_download('QuantTrio/Qwen3-235B-A22B-GPTQ-Int8', cache_dir="local_path") |
|
``` |
|
|
|
|
|
|
|
### 【Introduce 】 |
|
# Qwen3-235B-A22B |
|
<a href="https://chat.qwen.ai/" target="_blank" style="margin: 2px;"> |
|
<img alt="Chat" src="https://img.shields.io/badge/%F0%9F%92%9C%EF%B8%8F%20Qwen%20Chat%20-536af5" style="display: inline-block; vertical-align: middle;"/> |
|
</a> |
|
|
|
## Qwen3 Highlights |
|
|
|
Qwen3 is the latest generation of large language models in Qwen series, offering a comprehensive suite of dense and mixture-of-experts (MoE) models. Built upon extensive training, Qwen3 delivers groundbreaking advancements in reasoning, instruction-following, agent capabilities, and multilingual support, with the following key features: |
|
|
|
- **Uniquely support of seamless switching between thinking mode** (for complex logical reasoning, math, and coding) and **non-thinking mode** (for efficient, general-purpose dialogue) **within single model**, ensuring optimal performance across various scenarios. |
|
- **Significantly enhancement in its reasoning capabilities**, surpassing previous QwQ (in thinking mode) and Qwen2.5 instruct models (in non-thinking mode) on mathematics, code generation, and commonsense logical reasoning. |
|
- **Superior human preference alignment**, excelling in creative writing, role-playing, multi-turn dialogues, and instruction following, to deliver a more natural, engaging, and immersive conversational experience. |
|
- **Expertise in agent capabilities**, enabling precise integration with external tools in both thinking and unthinking modes and achieving leading performance among open-source models in complex agent-based tasks. |
|
- **Support of 100+ languages and dialects** with strong capabilities for **multilingual instruction following** and **translation**. |
|
|
|
## Model Overview |
|
|
|
**Qwen3-235B-A22B** has the following features: |
|
- Type: Causal Language Models |
|
- Training Stage: Pretraining & Post-training |
|
- Number of Parameters: 235B in total and 22B activated |
|
- Number of Paramaters (Non-Embedding): 234B |
|
- Number of Layers: 94 |
|
- Number of Attention Heads (GQA): 64 for Q and 4 for KV |
|
- Number of Experts: 128 |
|
- Number of Activated Experts: 8 |
|
- Context Length: 32,768 natively and [131,072 tokens with YaRN](#processing-long-texts). |
|
|
|
For more details, including benchmark evaluation, hardware requirements, and inference performance, please refer to our [blog](https://qwenlm.github.io/blog/qwen3/), [GitHub](https://github.com/QwenLM/Qwen3), and [Documentation](https://qwen.readthedocs.io/en/latest/). |
|
|
|
## Best Practices |
|
|
|
To achieve optimal performance, we recommend the following settings: |
|
|
|
1. **Sampling Parameters**: |
|
- For thinking mode (`enable_thinking=True`), use `Temperature=0.6`, `TopP=0.95`, `TopK=20`, and `MinP=0`. **DO NOT use greedy decoding**, as it can lead to performance degradation and endless repetitions. |
|
- For non-thinking mode (`enable_thinking=False`), we suggest using `Temperature=0.7`, `TopP=0.8`, `TopK=20`, and `MinP=0`. |
|
- For supported frameworks, you can adjust the `presence_penalty` parameter between 0 and 2 to reduce endless repetitions. However, using a higher value may occasionally result in language mixing and a slight decrease in model performance. |
|
|
|
2. **Adequate Output Length**: We recommend using an output length of 32,768 tokens for most queries. For benchmarking on highly complex problems, such as those found in math and programming competitions, we suggest setting the max output length to 38,912 tokens. This provides the model with sufficient space to generate detailed and comprehensive responses, thereby enhancing its overall performance. |
|
|
|
3. **Standardize Output Format**: We recommend using prompts to standardize model outputs when benchmarking. |
|
- **Math Problems**: Include "Please reason step by step, and put your final answer within \boxed{}." in the prompt. |
|
- **Multiple-Choice Questions**: Add the following JSON structure to the prompt to standardize responses: "Please show your choice in the `answer` field with only the choice letter, e.g., `"answer": "C"`." |
|
|
|
4. **No Thinking Content in History**: In multi-turn conversations, the historical model output should only include the final output part and does not need to include the thinking content. It is implemented in the provided chat template in Jinja2. However, for frameworks that do not directly use the Jinja2 chat template, it is up to the developers to ensure that the best practice is followed. |
|
|
|
## Processing Long Texts |
|
|
|
Qwen3 natively supports context lengths of up to 32,768 tokens. For conversations where the total length (including both input and output) significantly exceeds this limit, we recommend using RoPE scaling techniques to handle long texts effectively. We have validated the model's performance on context lengths of up to 131,072 tokens using the [YaRN](https://arxiv.org/abs/2309.00071) method. |
|
|
|
YaRN is currently supported by several inference frameworks, e.g., `transformers` and `llama.cpp` for local use, `vllm` and `sglang` for deployment. In general, there are two approaches to enabling YaRN for supported frameworks: |
|
|
|
- Modifying the model files: |
|
In the `config.json` file, add the `rope_scaling` fields: |
|
```json |
|
{ |
|
..., |
|
"rope_scaling": { |
|
"rope_type": "yarn", |
|
"factor": 4.0, |
|
"original_max_position_embeddings": 32768 |
|
} |
|
} |
|
``` |
|
For `llama.cpp`, you need to regenerate the GGUF file after the modification. |
|
|
|
- Passing command line arguments: |
|
|
|
For `vllm`, you can use |
|
```shell |
|
vllm serve ... --rope-scaling '{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":32768}' --max-model-len 131072 |
|
``` |
|
|
|
For `sglang`, you can use |
|
```shell |
|
python -m sglang.launch_server ... --json-model-override-args '{"rope_scaling":{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":32768}}' |
|
``` |
|
|
|
For `llama-server` from `llama.cpp`, you can use |
|
```shell |
|
llama-server ... --rope-scaling yarn --rope-scale 4 --yarn-orig-ctx 32768 |
|
``` |
|
|
|
## To completely disable thinking, you could use a custom chat template when starting the model: |
|
[Vllm Guide](https://qwen.readthedocs.io/en/latest/deployment/vllm.html#thinking-non-thinking-modes) |
|
|
|
``` |
|
vllm serve ...model_path... --chat-template ./qwen3_nonthinking.jinja |
|
``` |
|
|
|
|
|
## Citation |
|
|
|
If you find our work helpful, feel free to give us a cite. |
|
|
|
``` |
|
@misc{qwen3, |
|
title = {Qwen3}, |
|
url = {https://qwenlm.github.io/blog/qwen3/}, |
|
author = {Qwen Team}, |
|
month = {April}, |
|
year = {2025} |
|
} |
|
|