ktransformers icon indicating copy to clipboard operation
ktransformers copied to clipboard

Web UI throw errors for the second conversation

Open hetong007 opened this issue 1 year ago • 4 comments

I set up the webui for DeepSeek-R1 Q4. It responded to my initial message well, but when I continue to provide the next message, the frontend didn't return anything, and in the log it has

2025-02-13 06:05:09,750 INFO /opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/backend/base.py[64]: Performance(T/s): prefill 8.394581584255356, decode 5.173606081401556. Time(s): tokenize 0.0007636547088623047, prefill 1.1912446022033691, decode 99.35043215751648
INFO:     127.0.0.1:48906 - "GET /v1/assistants/status HTTP/1.1" 200 OK
INFO:     127.0.0.1:48906 - "GET /v1/threads?limit=100 HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:48906 - "GET /v1/threads/?limit=100 HTTP/1.1" 200 OK
INFO:     127.0.0.1:48906 - "GET /v1/threads/1879a6c8-6b2e-4c66-8276-1f928196a58e/messages?limit=100&order=asc HTTP/1.1" 200 OK
INFO:     127.0.0.1:60030 - "GET /v1/assistants/b7be2681-975f-49c7-959a-d6ea86d90d9c HTTP/1.1" 200 OK
2025-02-13 06:08:07,358 DEBUG /opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/backend/context_manager.py[49]: found context for thread 1879a6c8-6b2e-4c66-8276-1f928196a58e
INFO:     127.0.0.1:60030 - "POST /v1/threads/1879a6c8-6b2e-4c66-8276-1f928196a58e/messages HTTP/1.1" 200 OK
INFO:     127.0.0.1:60030 - "POST /v1/threads/1879a6c8-6b2e-4c66-8276-1f928196a58e/runs HTTP/1.1" 200 OK
2025-02-13 06:08:07,558 DEBUG /opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/backend/context_manager.py[29]: keys dict_keys(['f313e5cf-f1a9-4a1c-b86f-303957421ffa', '1879a6c8-6b2e-4c66-8276-1f928196a58e'])
2025-02-13 06:08:07,558 DEBUG /opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/backend/base.py[122]: start working
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/responses.py", line 268, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/responses.py", line 264, in wrap
    await func()
  File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/responses.py", line 233, in listen_for_disconnect
    message = await receive()
              ^^^^^^^^^^^^^^^
  File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 531, in receive
    await self.message_event.wait()
  File "/opt/conda/envs/ktransformer/lib/python3.11/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 741d74b44250

During handling of the above exception, another exception occurred:

  + Exception Group Traceback (most recent call last):
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
  |     result = await app(  # type: ignore[func-returns-value]
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
  |     return await self.app(scope, receive, send)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
  |     await super().__call__(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/applications.py", line 112, in __call__
  |     await self.middleware_stack(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__
  |     raise exc
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__
  |     await self.app(scope, receive, _send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/middleware/cors.py", line 93, in __call__
  |     await self.simple_response(scope, receive, send, request_headers=headers)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/middleware/cors.py", line 144, in simple_response
  |     await self.app(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
  |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
  |     raise exc
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
  |     await app(scope, receive, sender)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__
  |     await self.middleware_stack(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
  |     await route.handle(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
  |     await self.app(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
  |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
  |     raise exc
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
  |     await app(scope, receive, sender)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/routing.py", line 74, in app
  |     await response(scope, receive, send)
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/responses.py", line 261, in __call__
  |     async with anyio.create_task_group() as task_group:
  |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 767, in __aexit__
  |     raise BaseExceptionGroup(
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/responses.py", line 264, in wrap
    |     await func()
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/starlette/responses.py", line 245, in stream_response
    |     async for chunk in self.body_iterator:
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link
    |     async for event in async_events:
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply
    |     async for event in async_events:
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done
    |     async for event in async_events:
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 101, in filter_api_event
    |     async for event in async_events:
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/api/openai/assistants/runs.py", line 28, in inner
    |     async for event in ctx.work():
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/backend/base.py", line 145, in work
    |     async for token in self.interface.inference(local_messages,self.thread.id):
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 319, in inference
    |     input_ids = self.format_and_tokenize_input_ids(thread_id, local_messages)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/opt/conda/envs/ktransformer/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 186, in format_and_tokenize_input_ids
    |     unequal_mask = torch.ne(x,y)
    |                    ^^^^^^^^^^^^^
    | RuntimeError: The size of tensor a (524) must match the size of tensor b (246) at non-singleton dimension 1
    +------------------------------------
INFO:     127.0.0.1:55104 - "GET /v1/assistants/status HTTP/1.1" 200 OK
INFO:     127.0.0.1:55104 - "GET /v1/threads?limit=100 HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:55104 - "GET /v1/threads/?limit=100 HTTP/1.1" 200 OK
INFO:     127.0.0.1:55104 - "GET /v1/threads/1879a6c8-6b2e-4c66-8276-1f928196a58e/messages?limit=100&order=asc HTTP/1.1" 200 OK

hetong007 avatar Feb 13 '25 06:02 hetong007

Meet similar problem when integrates with AnythingLLM

ArYuZzz avatar Feb 13 '25 07:02 ArYuZzz

What is the length of the text you entered twice? According to our experience, it may be caused by the cache_lens parameter being too small.

qiyuxinlin avatar Feb 13 '25 11:02 qiyuxinlin

Same issue here. It prompts this error when you attempt a second conversation, no matter how long the text is. Will more than appreciate if someone can provide a more detailed document for ktransformer command flags, especially default values.

2025-02-15 17:16:12,091 DEBUG ~/.pyenv/versions/3.11.3/envs/llm_env/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[148]: cache position: 0 to 716
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "~/.pyenv/versions/3.11.3/envs/llm_env/lib/python3.11/site-packages/starlette/responses.py", line 268, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File "~/.pyenv/versions/3.11.3/envs/llm_env/lib/python3.11/site-packages/starlette/responses.py", line 264, in wrap
    await func()
  File "~/.pyenv/versions/3.11.3/envs/llm_env/lib/python3.11/site-packages/starlette/responses.py", line 233, in listen_for_disconnect
    message = await receive()
              ^^^^^^^^^^^^^^^
  File "~/.pyenv/versions/3.11.3/envs/llm_env/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 531, in receive
    await self.message_event.wait()
  File "~/.pyenv/versions/3.11.3/lib/python3.11/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 79e6fe74f110

lingzhic avatar Feb 15 '25 06:02 lingzhic

This issue has been automatically closed due to inactivity for 60 days.

If you believe this issue is still relevant, please feel free to reopen it with additional information or context.

Thank you for your contribution to KTransformers!


此 issue 因超过 60 天无活动而被自动关闭。

如果您认为此问题仍然存在,请随时重新打开并提供更多信息或上下文。

感谢您对 KTransformers 的贡献!

ErvinXie avatar Dec 11 '25 03:12 ErvinXie