[Bug]
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.
- [ ] 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
目前使用lmdeploy部署所有模型推理时,上下文长度一但超出就会提示“400 status code(no body)“,lmdeploy推理服务日志是提示超出长度,见下。[INFO:swift] Traceback (most recent call last): File "/mnt/nvme0/envs/swift/lib/python3.10/site-packages/swift/llm/infer/deploy.py", line 171, in create_chat_completion res_or_gen = await self.infer_async(infer_request, request_config, template=self.template, **infer_kwargs) File "/mnt/nvme0/envs/swift/lib/python3.10/site-packages/swift/llm/infer/infer_engine/lmdeploy_engine.py", line 310, in infer_async inputs = await loop.run_in_executor(None, template.encode, infer_request) File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/mnt/nvme0/envs/swift/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) File "/mnt/nvme0/envs/swift/lib/python3.10/site-packages/swift/llm/template/base.py", line 374, in encode encoded = Template._encode(self, inputs) File "/mnt/nvme0/envs/swift/lib/python3.10/site-packages/swift/llm/template/base.py", line 963, in _encode raise MaxLengthError(f'Current length of row({len(input_ids)}) is larger' swift.llm.template.base.MaxLengthError: Current length of row(885804) is larger than the max_length(128000).,但是ollama对应模型服务就没有任何问题。请帮忙看看。
Reproduction
CUDA_VISIBLE_DEVICES=2 nohup lmdeploy serve api_server
/mnt/nvme0/models/Qwen2.5-VL-32B-Instruct-AWQ
--model-name Qwen2.5-VL-32B-Instruct-AWQ
--server-port 8014
--model-format awq
--quant-policy 8 \
--cache-max-entry-count 0.5
--session-len 128000
--rope-scaling-factor 3.0 > qwen2_5_vl—32b-3.log 2>&1 & sleep 1 && tail -f qwen2_5_vl—32b-3.log,不仅仅是这个模型,还有qwq-32b-awq等模型。
Environment
sys.platform: linux
Python: 3.10.12 (main, Feb 4 2025, 14:57:36) [GCC 11.4.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0,1,2,3,4,5,6,7: NVIDIA GeForce RTX 4090
CUDA_HOME: /usr/local/cuda-12.8
NVCC: Cuda compilation tools, release 12.8, V12.8.93
GCC: x86_64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
PyTorch: 2.6.0+cu124
PyTorch compiling details: PyTorch built with:
- GCC 9.3
- C++ Version: 201703
- Intel(R) oneAPI Math Kernel Library Version 2024.2-Product Build 20240605 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v3.5.3 (Git Hash 66f0cb9eb66affd2da3bf5f8d897376f04aae6af)
- 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.4
- 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
- Magma 2.6.1
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, COMMIT_SHA=2236df1770800ffea5697b11b0bb0d910b2e59e1, CUDA_VERSION=12.4, 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 -DLIBKINETO_NOXPUPTI=ON -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-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wsuggest-override -Wno-psabi -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, TORCH_VERSION=2.6.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.21.0+cu124
LMDeploy: 0.7.3+
transformers: 4.51.3
gradio: 5.25.0
fastapi: 0.115.12
pydantic: 2.11.3
triton: 3.2.0
NVIDIA Topology:
GPU0 GPU1 GPU2 GPU3 GPU4 GPU5 GPU6 GPU7 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X NODE NODE NODE SYS SYS SYS SYS 0-31,64-95 0 N/A
GPU1 NODE X NODE NODE SYS SYS SYS SYS 0-31,64-95 0 N/A
GPU2 NODE NODE X NODE SYS SYS SYS SYS 0-31,64-95 0 N/A
GPU3 NODE NODE NODE X SYS SYS SYS SYS 0-31,64-95 0 N/A
GPU4 SYS SYS SYS SYS X NODE NODE NODE 32-63,96-127 1 N/A
GPU5 SYS SYS SYS SYS NODE X NODE NODE 32-63,96-127 1 N/A
GPU6 SYS SYS SYS SYS NODE NODE X NODE 32-63,96-127 1 N/A
GPU7 SYS SYS SYS SYS NODE NODE NODE X 32-63,96-127 1 N/A
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
麻烦启动 server 的时候,增加 --log-level INFO,开启 INFO 日志吧。
日志中有关于 kv cache block 相关的信息,能帮助定位问题