---
title: rombos-llm-v2.5-qwen-32b-gptq-int4
canonical_url: "https://www.modelscope.cn/models/tclf90/rombos-llm-v2.5-qwen-32b-gptq-int4"
md_url: "https://www.modelscope.cn/models/tclf90/rombos-llm-v2.5-qwen-32b-gptq-int4.md"
repository: tclf90/rombos-llm-v2.5-qwen-32b-gptq-int4
chinese_name: "Rombos-LLM-V2.5-Qwen-32B-GPTQ-Int4-量化修复"
last_updated: 2024-10-31
license: qwen
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - qwen2
architectures:
  - Qwen2ForCausalLM
parameters: 5.7B
tensor_type:
  - I32
  - F16
library_name:
  - safetensors
  - pytorch
frameworks:
  - Pytorch
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 182
stars: 2
tags:
  - qwen2.5
  - gptq
  - int4
  - "量化修复"
  - vLLM
  - sglang
---

# rombos-llm-v2.5-qwen-32b-gptq-int4

> rombos-llm-v2.5-qwen-32b-gptq-int4 - tclf90 在 ModelScope 开源的模型。Rombos-LLM-V2.5-Qwen-32B-GPTQ-Int4-量化修复 HF原始模型 rombodawg/Rombos-LLM-V2.5-Qwen-32b

tclf90/rombos-llm-v2.5-qwen-32b-gptq-int4 是 ModelScope 魔搭社区上的 5.7B 参数text-generation模型，采用 qwen 许可，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: tclf90/rombos-llm-v2.5-qwen-32b-gptq-int4
- **License**: qwen
- **Tasks**: text-generation
- **Parameters**: 5.7B
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Tags**: qwen2.5, gptq, int4, 量化修复, vLLM, sglang
- **Downloads**: 182
- **Stars**: 2
- **Last updated**: 2024-10-31

Source: https://www.modelscope.cn/models/tclf90/rombos-llm-v2.5-qwen-32b-gptq-int4

---

# Rombos-LLM-V2.5-Qwen-32B-GPTQ-Int4-量化修复
HF原始模型 [rombodawg/Rombos-LLM-V2.5-Qwen-32b](https://huggingface.co/rombodawg/Rombos-LLM-V2.5-Qwen-32b)


### 【留给Qwen32B刚需使用者的一个Note】

该模型自Qwen1.5以来，非常容易出现 !!!!!!! 的核心原因在于个别`layers`，例如`layers.4`、`layers.5`和`layers.6`，中的MLP模块的表征，学成了一个值域范围非常大的张量。其在推理过程中，需要用超过fp16精度来表示。

核心解决办法有三

(1) 将有问题layers回炉，用某种方式重新炼一下（我不太清楚有什么温和的处理手段，欢迎留言投稿献计）。

(2) 用可以支持TF16部署格式的格式进行部署。

(3) 对相关节点做峰值裁减处理

经过测试，也可以无脑对所有MLP节点进行裁减，具体操作如下：

找到vllm中的qwen2模型定义文件 `vllm/model_executor/models/qwen2.py`
定位到`Qwen2DecoderLayer`的`forward`的尾部，或`line:220~221`, 插入一行峰值裁减，如下
```
220        hidden_states = self.mlp(hidden_states)
221        hidden_states = torch.clamp(hidden_states, -3000., 3000.)   # 插入该行
222        return hidden_states, residual
```
这样就完成了一个对mlp节点进行正负3000的浮点峰值裁减的操作。
之后，就可以愉快的体验了，祝好。


### 【模型更新日期】

注：通过`snapshot_download`函数传入`revision=...`来下载指定的`tag`版本

``` 
2024-10-31
1. 优化测量算法，提升长文作答能力 (tag g128v2)

2024-10-25
1. add group 32 (tag g32)
2. add group 128 (tag g128)
```

### 【模型列表】

| tag      | 文件大小   | 最近更新时间       |
|----------|--------|--------------|
| `g128v2` | `19GB` | `2024-10-31` |
| `g128`   | `19GB` | `2024-10-25` |
| `g32`    | `20GB` | `2024-10-25` |

```python
from modelscope import snapshot_download
snapshot_download('tclf90/rombos-llm-v2.5-qwen-32b-gptq-int4', cache_dir="本地路径", revision='g128v2')
snapshot_download('tclf90/rombos-llm-v2.5-qwen-32b-gptq-int4', cache_dir="本地路径", revision='g32')
```

### 【修复内容】

1. 对GPTQ量化的校准做了额外优化；减少模型的 `1.乱吐字`、`2.无限循环`、`3.长文能力丢失`等情况。
2. 有些推理框架的默认`top_k`与`top_p`较大，可以考虑减小对应数值，来获得更合理的模型输出。
3. 根据模型实际情况，可以支持1卡、2卡及4卡的`tensor-parallel-size`启动。


### 【介绍】
Rombos-LLM-V2.5-Qwen-32b is a continues finetuned version of Qwen2.5-32B. I noticed recently that the Qwen team did not learn from my methods of continuous finetuning, the great benefits, and no downsides of it. So I took it upon myself to merge the instruct model with the base model myself using the *Ties* merge method

This version of the model shows higher performance than the original instruct and base models. 

### 【模型下载】
```python
from modelscope import snapshot_download
snapshot_download('tclf90/模型名', cache_dir="本地路径", revision='...tag...')
```

### 【高并发RESTFul API推理】
方式1：[vllm](https://github.com/vllm-project/vllm)

方式2：[sglang](https://github.com/sgl-project/sglang)
