mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-11-05 01:07:28 +00:00
[GH-ISSUE #171] 1T内存混合4*3090推理问题 #95
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/ktransformers#95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @edward-ng-duke on GitHub (Feb 12, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/171
情况
目前使用的是ktransformers0.2.0, 使用配置为 4*3090 + 1T DDR4 RAM, 按照whl安装项目
启动命令
启动命令为ktransformers --model_path ./DeepSeek-R1 --gguf_path /home/weiqu/r1_full_model/DeepSeek-R1-GGUF/DeepSeek-R1-UD-IQ1_S/ --port 5000 --host 0.0.0.0 --cpu_infer 25 --optimize_config_path /home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu.yaml --cache_lens 12000
bug情况
已经显示后台启动成功:
INFO: Started server process [4573]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:5000 (Press CTRL+C to quit)
INFO: 10.0.0.64:52317 - "POST /v1/chat/completions HTTP/1.1" 200 OK
但是随即报错,以下是完整log
oading blk.60.attn_kv_a_norm.weight to cuda:1
loading blk.60.attn_kv_b.weight to cuda:1
loading blk.60.attn_norm.weight to cuda:1
loading blk.60.ffn_norm.weight to cuda:1
loading output_norm.weight to cuda:1
loading output.weight to cuda:1
2025-02-12 17:44:14,077 DEBUG /home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/backend/context_manager.py[21]: Creating Context Manager
INFO: Started server process [4573]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:5000 (Press CTRL+C to quit)
INFO: 10.0.0.64:52317 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-02-12 17:44:31,847 DEBUG /home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py[192]: get input ids of shape torch.Size([1, 44])
2025-02-12 17:44:31,847 DEBUG /home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[122]: input_ids: torch.Size([1, 44])
2025-02-12 17:44:31,868 DEBUG /home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[148]: cache position: 0 to 44
/home/weiqu/miniconda3/envs/k021/lib/python3.11/contextlib.py:105: FutureWarning:
torch.backends.cuda.sdp_kernel()is deprecated. In the future, this context manager will be removed. Please seetorch.nn.attention.sdpa_kernel()for the new context manager, with updated signature.self.gen = func(*args, **kwds)
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/responses.py", line 268, in call
await wrap(partial(self.listen_for_disconnect, receive))
File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/responses.py", line 264, in wrap
await func()
File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/responses.py", line 233, in listen_for_disconnect
message = await receive()
^^^^^^^^^^^^^^^
File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 531, in receive
await self.message_event.wait()
File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/asyncio/locks.py", line 213, in wait
await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 7fab542f29d0
During handling of the above exception, another exception occurred:
| File "/home/weiqu/miniconda3/envs/k021/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 "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
| return await self.app(scope, receive, send)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
| await super().call(scope, receive, send)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/applications.py", line 112, in call
| await self.middleware_stack(scope, receive, send)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in call
| raise exc
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in call
| await self.app(scope, receive, _send)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in call
| await self.app(scope, receive, send)
| File "/home/weiqu/miniconda3/envs/k021/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 "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
| raise exc
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
| await app(scope, receive, sender)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/routing.py", line 715, in call
| await self.middleware_stack(scope, receive, send)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
| await route.handle(scope, receive, send)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
| await self.app(scope, receive, send)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
| await wrap_app_handling_exceptions(app, request)(scope, receive, send)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
| raise exc
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
| await app(scope, receive, sender)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/routing.py", line 74, in app
| await response(scope, receive, send)
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/responses.py", line 261, in call
| async with anyio.create_task_group() as task_group:
| File "/home/weiqu/miniconda3/envs/k021/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 "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/responses.py", line 264, in wrap
| await func()
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/starlette/responses.py", line 245, in stream_response
| async for chunk in self.body_iterator:
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link
| async for event in async_events:
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply
| async for event in async_events:
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done
| async for event in async_events:
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk
| async for event in async_events:
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 26, in inner
| async for token in interface.inference(input_message,id):
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 337, in inference
| for t in self.generate():
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
| response = gen.send(None)
| ^^^^^^^^^^^^^^
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 295, in generate
| next_token = self.decode_one_tokens()
| ^^^^^^^^^^^^^^^^^^^^^^^^
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 98, in decode_one_tokens
| return self.logits_to_token(logits)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/home/weiqu/miniconda3/envs/k021/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 213, in logits_to_token
| last = torch.multinomial(probs, num_samples=1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| RuntimeError: CUDA error: device-side assert triggered
| CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
| For debugging consider passing CUDA_LAUNCH_BLOCKING=1
| Compile with
TORCH_USE_CUDA_DSAto enable device-side assertions.|
+------------------------------------
/pytorch/aten/src/ATen/native/cuda/TensorCompare.cu:110: _assert_async_cuda_kernel: block: [0,0,0], thread: [0,0,0] Assertion
probability tensor contains eitherinf,nanor element < 0failed.^CINFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [4573]
Aborted (core dumped)
@edward-ng-duke commented on GitHub (Feb 12, 2025):
补充
这个情况只在DeepSeek-R1-UD-IQ1_S中出现, 也就是unsloth的1.58bit动态量化版本
把模型换成DeepSeek-R1-UD-Q2_K_XL就好了, 综合bug info , 是不是量化位数太低导致torch的推理问题?
@20000419 commented on GitHub (Feb 12, 2025):
请问如何配置多GPU?您是让4张3090都参与运算了吗?
@Kiciot commented on GitHub (Feb 12, 2025):
配置多GPU网上很多,可以找一下,一般来说四到八块能并行运算。不过更多是为了拓展显存
@KMSorSMS commented on GitHub (Feb 12, 2025):
是目前支持了Qx_k和IQ4,你先试试它们。后续我们会加上这些支持的~
@aimms321 commented on GitHub (Feb 12, 2025):
楼主能测一下128K的上下文对显存的占用量么?谢谢 @edward-ng-duke
@zerotorunaway commented on GitHub (Feb 12, 2025):
4卡盟提升推理速度吗?在这个框架下?能提升多少
@edward-ng-duke commented on GitHub (Feb 13, 2025):
文档中提到1卡和2卡速度区别不大, 只有上下文长度的区别, 这和我的实际测试是一致的
@edward-ng-duke commented on GitHub (Feb 13, 2025):
直接使用multi_gpu.yaml即可, 多个GPU按我的理解只提升上下文
@magicyuan876 commented on GitHub (Feb 13, 2025):
请问下4卡的上下文最大能支持到多少?并发性能怎样?
@ruralharry commented on GitHub (Feb 13, 2025):
请问下4卡的上下文最大能支持到多少?并发性能怎样?
同问,4卡到底有哪些优势和劣势啊