InternLM / lmdeploy

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

[Bug] WSL2环境下0.6.2版本无法推理W8A8的Orca-2-13b量化模型 #2726

Closed HelloCard closed 2 weeks ago

HelloCard commented 2 weeks ago

Checklist

Describe the bug

怀疑可能是因为我使用了llm-compressor的量化脚本?https://github.com/vllm-project/llm-compressor

Reproduction

lmdeploy serve api_server /mnt/e/Code/models/Orca-2-13b-W8A8 --server-port 8000 --tp 2 --dtype float16 --backend pytorch

Environment

(base) root@DESKTOP-PEPA2G9:/mnt/c/Windows/system32# lmdeploy check_env
sys.platform: linux
Python: 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:12:24) [GCC 11.2.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0,1: NVIDIA GeForce RTX 2080 Ti
CUDA_HOME: None
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: AVX2
  - 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+
transformers: 4.45.2
gradio: Not Found
fastapi: 0.115.2
pydantic: 2.9.2
triton: 3.0.0
NVIDIA Topology:
        GPU0    GPU1    CPU Affinity    NUMA Affinity
GPU0     X      NV2
GPU1    NV2      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

Error traceback

(base) root@DESKTOP-PEPA2G9:/mnt/c/Windows/system32# lmdeploy serve api_server /mnt/e/Code/models/Orca-2-13b-W8A8 --server-port 8000 --tp 2 --dtype float16 --backend pytorch
2024-11-07 18:54:49,683 - lmdeploy - ERROR - model_agent.py:493 - Rank[1] failed.
Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.12/site-packages/lmdeploy/pytorch/engine/model_agent.py", line 490, in _start_tp_process
    func(rank, *args, **kwargs)
  File "/root/miniconda3/lib/python3.12/site-packages/lmdeploy/pytorch/engine/model_agent.py", line 433, in _tp_model_loop
    patched_model, cache_engine, _ = _tp_build_model(rank,
                                     ^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/lmdeploy/pytorch/engine/model_agent.py", line 394, in _tp_build_model
    raise e
  File "/root/miniconda3/lib/python3.12/site-packages/lmdeploy/pytorch/engine/model_agent.py", line 364, in _tp_build_model
    load_model_weights(patched_model, model_path, device=device_map)
  File "/root/miniconda3/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/lib/python3.12/site-packages/lmdeploy/pytorch/weight_loader/model_weight_loader.py", line 158, in load_model_weights
    loader.load_model_weights(model, device=device)
  File "/root/miniconda3/lib/python3.12/site-packages/lmdeploy/pytorch/weight_loader/model_weight_loader.py", line 146, in load_model_weights
    model.load_weights(state_dict.items())
  File "/root/miniconda3/lib/python3.12/site-packages/lmdeploy/pytorch/models/llama.py", line 467, in load_weights
    param = params_dict[name]
            ~~~~~~~~~~~^^^^^^
KeyError: 'model.layers.30.mlp.down_proj.weight_scale'
2024-11-07 18:54:50,675 - lmdeploy - ERROR - model_agent.py:511 - TP process [0] failed.
/root/miniconda3/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 4 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '
(base) root@DESKTOP-PEPA2G9:/mnt/c/Windows/system32# lmdeploy check_env
grimoire commented 2 weeks ago

我们还没有对接 llm-compressor 可以用 lmdeploy.lite 进行量化

HelloCard commented 2 weeks ago

好的,我会试试的。