更新时间:2025-07-29 GMT+08:00
分享

Ascend-vLLM推理常见问题

问题1:在推理预测过程中遇到NPU out of memory

解决方法:调整推理服务启动时的显存利用率,将--gpu-memory-utilization的值调小。

问题2:在推理预测过程中遇到ValueError:User-specified max_model_len is greater than the drived max_model_len

解决方法:

修改config.json文件中的"seq_length"的值,"seq_length"需要大于等于 --max-model-len的值。config.json存在模型对应的路径下,例如:/data/nfs/benchmark/tokenizer/chatglm3-6b/config.json

问题3:使用autoAWQ进行qwen-7b模型量化时报错

使用autoAWQ进行qwen-7b模型量化时报错:TypeError: 'NoneType' object is not subscriptable

解决方法:

修改qwen-7b权重路径下modeling_qwen.py第39行为SUPPORT_FP16 = True

问题4:使用benchmark-tools对GLM系列模型进行性能测试报错

使用benchmark-tools对GLM系列模型进行性能测试报错TypeError: _pad() got an unexpected keyword argument 'padding_side'

解决方法:

1、下载最新的tokenization_chatglm.py,替换原来权重里的tokenization_chatglm.py。

https://huggingface.co/THUDM/glm-4-9b-chat/blob/main/tokenization_chatglm.py

https://huggingface.co/THUDM/chatglm3-6b/blob/main/tokenization_chatglm.py

或者2、修改tokenization_chatglm.py,在266行增加padding_side: str = "left",如图1所示。

图1 tokenization_chatglm.py

问题5:使用benchmark-tools访问推理服务返回报错

使用benchmark-tools访问推理服务时,输入输出的token和大于max_model_len,服务端返回报错Response payload is not completed,见图2

再次设置输入输出的token和小于max_model_len访问推理服务,服务端响应200,见图3

客户端仍返回报错Response payload is not completed,见图4

图2 服务端返回报错Response payload is not completed
图3 服务端响应200
图4 仍返回报错Response payload is not completed

解决方法:

安装brotlipy后返回正确报错

pip install brotlipy

问题6:使用benchmark-tools访问推理客户端返回报错或警告

使用benchmark-tools访问推理客户端返回报错或警告:actual output_tokens_length < expected output_len

解决方法:

减少参数--prompt-tokens和--output-tokens的值,或者增大启动服务的参数--max-model-len的值。

问题7:使用离线推理时,性能较差或精度异常

解决方法:将block_size大小设置为128

from vllm import LLM, SamplingParams
llm = LLM(model="facebook/opt-125m", block_size=128)

问题8:使用SmoothQuant做权重转换时,scale显示为nan,或推理时精度异常

涉及模型:qwen2-1.5b、qwen2-7b

解决方法:修改AscendCloud/AscendCloud-LLM/llm_tools/AutoSmoothQuant/autosmoothquant/utils/utils.py中的build_model_and_tokenizer函数,将torch_dtype类型从torch.float16改成torch.bfloat16

kwargs = {"torch_dtype": torch.bfloat16, "device_map": "auto"}

问题9:使用SmoothQuant做权重转换时,有如下报错

涉及模型:qwen2-1.5b、qwen2-0.5b

解决方法:修改AscendCloud/AscendCloud-LLM/llm_tools/AutoSmoothQuant/autosmoothquant/examples/smoothquant_model.py中的main函数,保存模型时将safe_serialization指定为False

int8_model.save_pretrained(output_path,safe_serialization=False)

问题10:使用qwen2.5-vl系列模型进行推理时报错

需使用特定版本的transformers。安装方式如下:

git clone https://github.com/huggingface/transformers
cd transformers
git checkout 1931a351408dbd1d0e2c4d6d7ee0eb5e8807d7bf
pip install -e .

问题11:使用MME精度测评工具报错

需安装shortuuid,安装方式如下:

pip install shortuuid

相关文档