InternLM / lmdeploy

LMDeploy is a toolkit for compressing, deploying, and serving LLMs.
https://lmdeploy.readthedocs.io/en/latest/
Apache License 2.0
4.74k stars 432 forks source link

[Bug] cannot get gpqa's score on Qwen2.5-7b model by using lmdeploy backend and opencompass #2693

Closed zhulinJulia24 closed 4 weeks ago

zhulinJulia24 commented 4 weeks ago

Checklist

Describe the bug

from mmengine.config import read_base with read_base(): from opencompass.configs.models.qwen2_5.lmdeploy_qwen2_5_7b import ( models as lmdeploy_qwen2_5_7b_model, ) from opencompass.configs.datasets.gpqa.gpqa_few_shot_ppl_4b5a83 import ( gpqa_datasets, ) models = [lmdeploy_qwen2_5_7b_model] datasets = [gpqa_datasets]

Reproduction

  1. create oc config, the config is
    from mmengine.config import read_base
    with read_base():
    from opencompass.configs.models.qwen2_5.lmdeploy_qwen2_5_7b import (
        models as lmdeploy_qwen2_5_7b_model,
    )
    from opencompass.configs.datasets.gpqa.gpqa_few_shot_ppl_4b5a83 import (
        gpqa_datasets,
    )
    models = [*lmdeploy_qwen2_5_7b_model]
    datasets = [*gpqa_datasets]
  2. run opencompass config.py

Environment

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 A800-SXM4-80GB
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.1+
transformers: 4.46.1
gradio: Not Found
fastapi: 0.115.4
pydantic: 2.9.2
triton: 3.0.0
NVIDIA Topology: 
        GPU0    GPU1    NIC0    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      NV2     PHB     0-15            N/A             N/A
GPU1    NV2      X      PHB     0-15            N/A             N/A
NIC0    PHB     PHB      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

Error traceback

2024-10-31 16:49:23,411 - lmdeploy - INFO - utils.py:212 - sorted indices: [12, 15, 3, 5, 13, 0, 10, 9, 1, 7, 6, 2, 8, 11, 14, 4]
2024-10-31 16:49:23,411 - lmdeploy - INFO - utils.py:214 - start: 0, end: 0
 14%|██████████████▌                                                                                       | 1/7 [00:01<00:08,  1.38s/it]
Traceback (most recent call last):
  File "/cpfs01/shared/public/qa-llm-cicd/miniconda3/envs/test_cu12/lib/python3.10/site-packages/opencompass/tasks/openicl_infer.py", line 161, in <module>
    inferencer.run()
  File "/cpfs01/shared/public/qa-llm-cicd/miniconda3/envs/test_cu12/lib/python3.10/site-packages/opencompass/tasks/openicl_infer.py", line 89, in run
    self._inference()
  File "/cpfs01/shared/public/qa-llm-cicd/miniconda3/envs/test_cu12/lib/python3.10/site-packages/opencompass/tasks/openicl_infer.py", line 128, in _inference
    inferencer.inference(retriever,
  File "/cpfs01/shared/public/qa-llm-cicd/miniconda3/envs/test_cu12/lib/python3.10/site-packages/opencompass/openicl/icl_inferencer/icl_ppl_inferencer.py", line 159, in inference
    sub_res = self.model.get_ppl_from_template(sub_prompt_list).tolist()
  File "/cpfs01/shared/public/qa-llm-cicd/miniconda3/envs/test_cu12/lib/python3.10/site-packages/opencompass/models/base.py", line 174, in get_ppl_from_template
    return self.get_ppl(inputs, mask_length)
  File "/cpfs01/shared/public/qa-llm-cicd/miniconda3/envs/test_cu12/lib/python3.10/site-packages/opencompass/models/turbomind.py", line 179, in get_ppl
    results.append(self.pipe.get_ppl(input_ids[i:i + 128]))
  File "/cpfs01/shared/public/qa-llm-cicd/miniconda3/envs/test_cu12/lib/python3.10/site-packages/lmdeploy/serve/utils.py", line 217, in get_ppl
    loss, target_count = self._get_long_text_ppl(
  File "/cpfs01/shared/public/qa-llm-cicd/miniconda3/envs/test_cu12/lib/python3.10/site-packages/lmdeploy/serve/utils.py", line 264, in _get_long_text_ppl
    assert isinstance(input_ids, List) and len(input_ids) == 1
AssertionError
[TM][INFO] [InternalThreadEntry] stop requested.
[TM][INFO] [OutputThreadEntry] stop requested.
lvhan028 commented 4 weeks ago

Fixed in PR #2697