ztxz16 / fastllm

纯c++的全平台llm加速库,支持python调用,chatglm-6B级模型单卡可达10000+token / s,支持glm, llama, moss基座,手机端流畅运行
Apache License 2.0
3.3k stars 334 forks source link

采用向量化访存优化旧架构GPU性能 #449

Closed TylunasLi closed 5 months ago

TylunasLi commented 5 months ago

修改内容

  1. 针对单条推理decode阶段的GPU GEMV算子优化 a. 在CUDA_NO_TENSOR_CORE编译选项下,fp16/int8 修改为向量化访存,获得一定速度提升; b. 对全部架构int4的GEMV开启向量化访存。

  2. 针对int8/int4批量推理的反量化操作 a. 在CUDA_NO_TENSOR_CORE编译选项下,修改为向量化访存。

测试情况

单条推理优化后结果,采用benchmark测试:

GPU 编译器 CUDA 模型-精度 优化前 优化后
Tesla P40 VS2015 CUDA 9.2 ChatGLM fp16 20.7tps 21.4tps
Tesla P40 GCC9.4 CUDA 10.0 ChatGLM fp16 20.8tps 21.5tps
Tesla P40 VS2015 CUDA 9.2 ChatGLM2 int8 23.6tps 24.9tps
Tesla P40 GCC9.4 CUDA 10.0 ChatGLM2 int8 23.6tps 24.5tps
Tesla P40 VS2015 CUDA 9.2 ChatGLM2 int4 15.0tps 27.6tps
Tesla P40 GCC9.4 CUDA 10.0 ChatGLM2 int4 14.8tps 27.2tps
GTX1080Ti GCC8.3 CUDA 11.6 ChatGLM2 int4 17.9tps 32.9tps
RTX 3090 GCC7.5 CUDA 11.0 ChatGLM2 int4 99.8tps 117.7tps
RTX 3090 GCC8.3 CUDA 11.6 ChatGLM2 int4 95.4tps 101.3tps