InternLM / InternLM/lmdeploy

[Bug] Accuracy of W8A8 is big different from that of the original model

Open
#2,730 6 comments 0 reactions 1 assignee Claimed by @AllentDan View on GitHub
Dominant language
Python
Stars
8.1k
Forks
748
Avg merge
6d 2h
Merged PRs (30d)
54

Description

### Checklist

- [X] 1. I have searched related issues but cannot get the expected help.
- [X] 2. The bug has not been fixed in the latest version.
- [X] 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.

### Describe the bug

下载microsoft/Orca-2-13b
量化Orca-2-13b为Orca-2-13b-w8
使用lm_eval对lmdeploy运行的Orca-2-13b-w8 OpenAI Compatible Server进行评估。
相同评估指令得到的评估结果为差异巨大
```
local-completions (model=/root/autodl-tmp/Orca-2-13b-w8,base_url=http://0.0.0.0:23333/v1/completions,tokenized_requests=False), gen_kwargs: (None), limit: 30.0, num_fewshot: 5, batch_size: auto
|Tasks|Version| Filter |n-shot| Metric | |Value| |Stderr|
|-----|------:|----------------|-----:|-----------|---|----:|---|-----:|
|gsm8k| 3|flexible-extract| 5|exact_match|↑ | 0|± | 0|
| | |strict-match | 5|exact_match|↑ | 0|± | 0|

local-completions (model=/root/autodl-tmp/Orca-2-13b,base_url=http://0.0.0.0:23333/v1/completions,tokenized_requests=False), gen_kwargs: (None), limit: 30.0, num_fewshot: 5, batch_size: auto
|Tasks|Version| Filter |n-shot| Metric | |Value | |Stderr|
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k| 3|flexible-extract| 5|exact_match|↑ |0.4667|± |0.0926|
| | |strict-match | 5|exact_match|↑ |0.4333|± |0.0920|
```

此外,无法使用opencompass对Orca-2-13b-w8进行评估,因为在按照这里是说明拉取项目粘贴编辑脚本后,得到了lmdeploy不支持 quant_method"smooth_quant"的提示。https://github.com/InternLM/lmdeploy/blob/78ab485e4a563e82f8d560e836ebeeec4a2c22b1/docs/zh_cn/benchmark/evaluate_with_opencompass.md
在这一情况下,我不知道如何将--backend pytorch添加到脚本中。

### Reproduction

lmdeploy lite smooth_quant /root/autodl-tmp/Orca-2-13b --work-dir ./Orca-2-13b-w8
lmdeploy serve api_server /root/autodl-tmp/Orca-2-13b-w8 --server-port 23333 --backend pytorch
lmdeploy serve api_server /root/autodl-tmp/Orca-2-13b --server-port 23333
lm_eval --model local-completions --model_args model=/root/autodl-tmp/Orca-2-13b,base_url=http://0.0.0.0:23333/v1/completions,tokenized_requests=False --tasks gsm8k --num_fewshot 5 --limit 30 --batch_size 'auto' --output_path /root/autodl-tmp/lm_eval
lm_eval --model local-completions --model_args model=/root/autodl-tmp/Orca-2-13b-w8,base_url=http://0.0.0.0:23333/v1/completions,tokenized_requests=False --tasks gsm8k --num_fewshot 5 --limit 30 --batch_size 'auto' --output_path /root/autodl-tmp/lm_eval

### Environment

```Shell
root@autodl-container-61bb4e82b9-21d3700f:~/autodl-tmp/opencompass/workdir/20241109_131838/logs/infer/Orca-2-13b-w8-turbomind# lmdeploy check_env
sys.platform: linux
Python: 3.10.15 (main, Oct 3 2024, 07:27:34) [GCC 11.2.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0,1: NVIDIA GeForce RTX 4090 D
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.1, V12.1.105
GCC: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
PyTorch: 2.4.0+cu121
PyTorch compiling details: PyTorch built with:
- GCC 9.3
- C++ Version: 201703
- Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v3.4.2 (Git Hash 1137e04ec0b5251ca2b4400a4fd3c667ce843d67)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX512
- CUDA Runtime 12.1
- NVCC architecture flags: -gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_90,code=sm_90
- CuDNN 90.1 (built against CUDA 12.4)
- Magma 2.6.1
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.1, CUDNN_VERSION=9.1.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wsuggest-override -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=2.4.0, USE_CUDA=ON, USE_CUDNN=ON, USE_CUSPARSELT=1, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_GLOO=ON, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, USE_ROCM_KERNEL_ASSERT=OFF,

TorchVision: 0.19.0+cu121
LMDeploy: 0.6.2.post1+a0ef2fd
transformers: 4.46.2
gradio: Not Found
fastapi: 0.115.4
pydantic: 2.9.2
triton: 3.0.0
NVIDIA Topology:
GPU0 GPU1 NIC0 NIC1 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X SYS SYS SYS 0-47,96-143 0 N/A
GPU1 SYS X SYS SYS 48-95,144-191 1 N/A
NIC0 SYS SYS X PIX
NIC1 SYS SYS PIX X

Legend:

X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks

NIC Legend:

NIC0: mlx5_0
NIC1: mlx5_1
```

### Error traceback

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.