deepseek-vl2 inference with OpenAI-compatible AssertionError: the number of <IMAGE_TOKEN> is not equal to input images, 2 vs 1
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 748
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 54
Description
I want to run this command with OpenAI-compatible api:
$ curl http://x.x.x.x:8001/v1/chat/completions \
--header 'Authorization: Bearer sk-xxxxxxx' \
-H "Content-Type: application/json" \
-d '{
"model": "/data/models/deepseek-vl2",
"messages": [
{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/cat.png"}},
{
"type": "text",
"text": "Describe the image please"
}
]},
{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/dog.png"}},
{
"type": "text",
"text": "Describe the image please"
}
]}
]
}'
Internal Server Error
**The log from lmdploy as follows:**
INFO: 218.205.209.238:63106 - "POST /v1/chat/completions HTTP/1.1" 200 OK
INFO: 218.205.209.238:63141 - "POST /v1/chat/completions HTTP/1.1" 422 Unprocessable Entity
INFO: 218.205.209.238:63186 - "POST /v1/chat/completions HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/data/software/miniconda3/envs/lmdeploy/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 "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in __call__
await self.app(scope, receive, send)
File "/data/software/miniconda3/envs/lmdeploy/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 "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/routing.py", line 714, in __call__
await self.middleware_stack(scope, receive, send)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/lmdeploy/serve/openai/api_server.py", line 451, in chat_completions_v1
async for res in result_generator:
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/lmdeploy/serve/async_engine.py", line 663, in generate
prompt_input = await self._get_prompt_input(prompt,
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/lmdeploy/serve/vl_async_engine.py", line 89, in _get_prompt_input
results = await self.vl_encoder.wrap_for_pytorch(results, self.chat_template, self.tokenizer,
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/lmdeploy/vl/engine.py", line 81, in wrap_for_pytorch
result = self.model.to_pytorch(messages, chat_template, tokenizer, sequence_start)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/lmdeploy/vl/model/deepseek_vl2.py", line 164, in to_pytorch
return self.to_pytorch_aux(messages, prompt, IMAGE_TOKEN, tokenizer, sequence_start)
File "/data/software/miniconda3/envs/lmdeploy/lib/python3.10/site-packages/lmdeploy/vl/model/base.py", line 188, in to_pytorch_aux
assert len(segs) == len(preps) + 1, (f'the number of {IMAGE_TOKEN} is not equal '
AssertionError: the number of is not equal to input images, 2 vs 1
Contributor guide
Assessment
This issue has not been assessed yet.