lmdeploy icon indicating copy to clipboard operation
lmdeploy copied to clipboard

[Bug] 0.10.1版本调用工具时会出现content异常的报错。

Open waveman800 opened this issue 2 months ago • 1 comments

Checklist

  • [ ] 1. I have searched related issues but cannot get the expected help.
  • [ ] 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

在调用工具的时候,会出现content异常的问题,大模型是Qwen3-14B-AWQ。 具体日志见下:INFO: 10.216.7.14:50394 - "POST /v1/chat/completions HTTP/1.1" 200 OK ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last): | File "/opt/py3/lib/python3.10/site-packages/starlette/_utils.py", line 76, in collapse_excgroups | yield | File "/opt/py3/lib/python3.10/site-packages/starlette/responses.py", line 263, in call | async with anyio.create_task_group() as task_group: | File "/opt/py3/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 772, in aexit | raise BaseExceptionGroup( | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/opt/py3/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi | result = await app( # type: ignore[func-returns-value] | File "/opt/py3/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call | return await self.app(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call | await super().call(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/applications.py", line 112, in call | await self.middleware_stack(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in call | raise exc | File "/opt/py3/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in call | await self.app(scope, receive, _send) | File "/opt/py3/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in call | await self.app(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in call | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/opt/py3/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 714, in call | await self.middleware_stack(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 734, in app | await route.handle(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle | await self.app(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 76, in app | await wrap_app_handling_exceptions(app, request)(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/opt/py3/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 74, in app | await response(scope, receive, send) | File "/opt/py3/lib/python3.10/site-packages/starlette/responses.py", line 262, in call | with collapse_excgroups(): | File "/usr/lib/python3.10/contextlib.py", line 153, in exit | self.gen.throw(typ, value, traceback) | File "/opt/py3/lib/python3.10/site-packages/starlette/_utils.py", line 82, in collapse_excgroups | raise exc | File "/opt/py3/lib/python3.10/site-packages/starlette/responses.py", line 266, in wrap | await func() | File "/opt/py3/lib/python3.10/site-packages/starlette/responses.py", line 246, in stream_response | async for chunk in self.body_iterator: | File "/opt/lmdeploy/lmdeploy/serve/openai/api_server.py", line 459, in completion_stream_generator | async for res in result_generator: | File "/opt/lmdeploy/lmdeploy/serve/async_engine.py", line 728, in generate | prompt_input = await self._get_prompt_input(prompt, | File "/opt/lmdeploy/lmdeploy/serve/async_engine.py", line 608, in _get_prompt_input | prompt = chat_template.messages2prompt(messages, sequence_start, tools=tools) | File "/opt/lmdeploy/lmdeploy/model.py", line 229, in messages2prompt | content = get_text(message['content']) | KeyError: 'content' +------------------------------------

During handling of the above exception, another exception occurred:

Reproduction

docker run -d --name lmdeploy_Qwen3-14B-AWQ
--runtime=nvidia --gpus "device=1"
-v /mnt/nvme0/models:/root/model
-v /mnt/nvme0/logs:/root/logs
-p 8010:23333
--ipc=host
harbor.bhidi.com/ai/lmdeploy:0.10.1-long-cuda118
lmdeploy serve api_server /root/model/Qwen3-14B-AWQ
--model-name Qwen3-14B-AWQ --session-len 262144
--cache-max-entry-count 0.8 --max-batch-size 20
--backend turbomind --model-format awq
--tool-call-parser qwen
--enable-dynamic-compression
--importance-threshold 0.6
--min-compression-ratio 0.5
--max-compression-ratio 0.8
--segment-strategy paragraph

以上脚本执行的镜像是我在0.10.1版本上做了二次开发的打包镜像。

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: NVIDIA GeForce RTX 4090
CUDA_HOME: /usr/local/cuda-12.1
NVCC: Cuda compilation tools, release 12.1, V12.1.105
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.8.0+68eca6e
transformers: 4.52.4
gradio: 3.43.0
fastapi: 0.115.12
pydantic: 2.11.7
triton: 3.2.0
NVIDIA Topology: 
	GPU0	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	0-31,64-95	0		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

INFO:     10.216.7.14:50394 - "POST /v1/chat/completions HTTP/1.1" 200 OK
ERROR:    Exception in ASGI application
  + Exception Group Traceback (most recent call last):
  |   File "/opt/py3/lib/python3.10/site-packages/starlette/_utils.py", line 76, in collapse_excgroups
  |     yield
  |   File "/opt/py3/lib/python3.10/site-packages/starlette/responses.py", line 263, in __call__
  |     async with anyio.create_task_group() as task_group:
  |   File "/opt/py3/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
  |     raise BaseExceptionGroup(
  | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/opt/py3/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    |     result = await app(  # type: ignore[func-returns-value]
    |   File "/opt/py3/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    |     return await self.app(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
    |     await super().__call__(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__
    |     await self.middleware_stack(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in __call__
    |     raise exc
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in __call__
    |     await self.app(scope, receive, _send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in __call__
    |     await self.app(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    |     raise exc
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    |     await app(scope, receive, sender)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 714, in __call__
    |     await self.middleware_stack(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 734, in app
    |     await route.handle(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
    |     await self.app(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
    |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    |     raise exc
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    |     await app(scope, receive, sender)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/routing.py", line 74, in app
    |     await response(scope, receive, send)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/responses.py", line 262, in __call__
    |     with collapse_excgroups():
    |   File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    |     self.gen.throw(typ, value, traceback)
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
    |     raise exc
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/responses.py", line 266, in wrap
    |     await func()
    |   File "/opt/py3/lib/python3.10/site-packages/starlette/responses.py", line 246, in stream_response
    |     async for chunk in self.body_iterator:
    |   File "/opt/lmdeploy/lmdeploy/serve/openai/api_server.py", line 459, in completion_stream_generator
    |     async for res in result_generator:
    |   File "/opt/lmdeploy/lmdeploy/serve/async_engine.py", line 728, in generate
    |     prompt_input = await self._get_prompt_input(prompt,
    |   File "/opt/lmdeploy/lmdeploy/serve/async_engine.py", line 608, in _get_prompt_input
    |     prompt = chat_template.messages2prompt(messages, sequence_start, tools=tools)
    |   File "/opt/lmdeploy/lmdeploy/model.py", line 229, in messages2prompt
    |     content = get_text(message['content'])
    | KeyError: 'content'
    +------------------------------------

During handling of the above exception, another exception occurred:

waveman800 avatar Nov 19 '25 01:11 waveman800

This may have been fixed in #4029 in release v0.10.2 . You can check if this release fix your issue.

windreamer avatar Nov 19 '25 03:11 windreamer

This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 5 days if the stale label is not removed or if there is no further response.

github-actions[bot] avatar Jan 01 '26 02:01 github-actions[bot]

This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.

github-actions[bot] avatar Jan 07 '26 02:01 github-actions[bot]