Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ python3 tools/spec_benchmark.py \
测试`transformers`加载量化模型离线推理:

```shell
python deploy/offline.py $MODEL_PATH
python scripts/deploy/offline.py $MODEL_PATH "Hello, my name is"
```

其中 `MODEL_PATH` 为量化产出模型路径。
Expand All @@ -168,32 +168,35 @@ python deploy/offline.py $MODEL_PATH
[vLLM](https://github.com/vllm-project/vllm) 服务启动脚本,建议版本`vllm>=0.8.5.post1`,部署MOE INT8量化模型需要`vllm>=0.9.2`。

```shell
bash deploy/run_vllm.sh $MODEL_PATH
bash scripts/deploy/run_vllm.sh --model-path $MODEL_PATH --port 8080 -d 0,1,2,3 -t 4 -p 1 -g 0.8 --max-model-len 4096
```
其中`-d`为可见设备,`-t`为张量并行度,`-p`为流水线并行度,`-g`为显存使用率。

**SGLang**

[SGLang](https://github.com/sgl-project/sglang) 服务启动脚本,建议版本 `sglang>=0.4.6.post1`:

```shell
bash deploy/run_sglang.sh $MODEL_PATH
bash scripts/deploy/run_sglang.sh --model-path $MODEL_PATH --port 8080 -d 0,1,2,3 -t 4 -g 0.8
```

#### 3. 服务调用

通过 [OpenAI 格式](https://platform.openai.com/docs/api-reference/introduction) 接口发起请求:

```shell
bash deploy/openai.sh $MODEL_PATH
bash scripts/deploy/openai.sh -m $MODEL_PATH -p "Hello, my name is" --port 8080 --max-tokens 4096 --temperature 0.7 --top-p 0.8 --top-k 20 --repetition-penalty 1.05 --system-prompt "You are a helpful assistant."
```
其中`-p`为输入prompt

#### 4. 效果验证

使用 [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) 评估量化模型精度,建议版本`lm-eval>=0.4.8`:

```shell
bash deploy/lm_eval.sh $MODEL_PATH
bash scripts/deploy/lm_eval.sh -d 0,1 -t 2 -g 0.8 -r $RESULT_PATH -b "auto" --tasks ceval-valid,mmlu,gsm8k,humaneval -n 0 $MODEL_PATH
```
其中`RESULT_PATH`为测试结果保存目录,`-b`为batch size大小,`--tasks`为评测任务,`-n`为few-shot数量

详细操作指南请参阅[部署文档](https://angelslim.readthedocs.io/zh-cn/latest/deployment/deploy.html)。

Expand Down
13 changes: 8 additions & 5 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ If you need to load a quantized model via `transformers`, please set the `deploy
To test offline inference with a quantized model loaded via `transformers`, run the following command:

```shell
python deploy/offline.py $MODEL_PATH
python scripts/deploy/offline.py $MODEL_PATH "Hello, my name is"
```

Where `MODEL_PATH` is the path to the quantized model output.
Expand All @@ -169,33 +169,36 @@ Use the following script to launch a [vLLM](https://github.com/vllm-project/vllm


```shell
bash deploy/run_vllm.sh $MODEL_PATH
bash scripts/deploy/run_vllm.sh --model-path $MODEL_PATH --port 8080 -d 0,1,2,3 -t 4 -p 1 -g 0.8 --max-model-len 4096
```
Where `-d` is the visible devices, `-t` is tensor parallel size, `-p` is pipeline parallel size, and `-g` is the GPU memory utilization.

**SGLang**


Use the following script to launch a [SGLang](https://github.com/sgl-project/sglang) server, recommended version `sglang>=0.4.6.post1`.

```shell
bash deploy/run_sglang.sh $MODEL_PATH
bash scripts/deploy/run_sglang.sh --model-path $MODEL_PATH --port 8080 -d 0,1,2,3 -t 4 -g 0.8
```

#### 3. Service Invocation

Invoke requests via [OpenAI's API format](https://platform.openai.com/docs/api-reference/introduction):

```shell
bash deploy/openai.sh $MODEL_PATH
bash scripts/deploy/openai.sh -m $MODEL_PATH -p "Hello, my name is" --port 8080 --max-tokens 4096 --temperature 0.7 --top-p 0.8 --top-k 20 --repetition-penalty 1.05 --system-prompt "You are a helpful assistant."
```
where `-p` is the input prompt.

#### 4. Performance Evaluation

Evaluate the performance of quantized model using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness), recommended version`lm-eval>=0.4.8`:

```shell
bash deploy/lm_eval.sh $MODEL_PATH
bash scripts/deploy/lm_eval.sh -d 0,1 -t 2 -g 0.8 -r $RESULT_PATH -b "auto" --tasks ceval-valid,mmlu,gsm8k,humaneval -n 0 $MODEL_PATH
```
where `RESULT_PATH` is the directory for saving test results, `-b` is batch size, `--tasks` specifies the evaluation tasks, and `-n` is the number of few-shot examples.

For more detaileds, please refer to the [Deployment Documentation](https://angelslim.readthedocs.io/zh-cn/latest/deployment/deploy.html).

Expand Down
2 changes: 2 additions & 0 deletions angelslim/compressor/diffusion/quant/ptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def export_quantized_weight(self, model: torch.nn.Module, save_path: str):
), "Currently only FP8_PER_TENSOR is supported for export"
self.convert_linear(model)
save_quantized_model(model, save_path, self.fp8_scales_map)
logger.info(f"Quantized model saved to {save_path}")
logger.info(f"Quantized scales saved to {save_path}/fp8_scales.safetensors")

@staticmethod
def load_quantized_model(model_class, save_path: str, device: str = "cpu"):
Expand Down
65 changes: 0 additions & 65 deletions deploy/lm_eval.sh

This file was deleted.

59 changes: 0 additions & 59 deletions deploy/lmms_eval.sh

This file was deleted.

22 changes: 0 additions & 22 deletions deploy/openai.sh

This file was deleted.

12 changes: 0 additions & 12 deletions deploy/run_sglang.sh

This file was deleted.

14 changes: 0 additions & 14 deletions deploy/run_vllm.sh

This file was deleted.

Loading