5.2. chatglm3

chatglm系列模型,使用vllm 0.6.1.post2及以上版本时,需要手动降级transformers库版本

python3 -m pip install transformers==4.43.0

chatglm3-6b

模型下载

从huggingface上下载下列任意模型的预训练ckpt,路径记为[path of chatglmckpt]

批量离线推理

python3 -m vllm_utils.benchmark_test \
 --model=[path of chatglmckpt] \
 --demo=te \
 --dtype=float16 \
 --output-len=256 \
 --trust-remote-code

性能测试

python3 -m vllm_utils.benchmark_test --perf \
 --model=[path of chatglmckpt] \
 --input-len=28672 \
 --output-len=4096 \
 --num-prompts=16 \
 --block-size=64 \
 --dtype=float16 \
 --max-model-len=32768 \
 --device "gcu" \
 --tokenizer "chatglm3-6b-32k"

注:

  • 本模型支持的max-model-len为8192(chatglm3-6b ckpt)/32768(chatglm3-6b-32k ckpt);

  • input-lenoutput-lennum-prompts可按需调整;

  • 配置 output-len为1时,输出内容中的latency即为time_to_first_token_latency;

  • chatglm3 32k模型运行时需要添加环境变量:

    • export PYTORCH_GCU_ALLOC_CONF=backend:topsMallocAsync

chatglm3-6b-w8a16_gptq

本模型推理及性能测试需要1张enflame gcu。

模型下载

  • 如需要下载权重,请联系商务人员开通EGC权限进行下载

  • 下载 ChatGLM3-6b-8k-w8a16_gptq.tarChatGLM3-6b-32k-w8a16_gptq.tar 文件并解压,将压缩包内的内容全部拷贝到chatglm_w8a16_gptq文件夹中。

  • chatglm_w8a16_gptq目录结构如下所示:

chatglm_w8a16_gptq/
├── config.json
├── configuration_chatglm.py
├── model.safetensors
├── quantize_config.json
├── tokenization_chatglm.py
├── tokenizer_config.json
├── tokenizer.model
└── tops_quantize_info.json

批量离线推理

python3 -m vllm_utils.benchmark_test \
 --model=[path of chatglm_w8a16_gptq] \
 --demo=te \
 --dtype=float16 \
 --quantization=gptq \
 --output-len=256 \
 --disable-log-stats