[GH-ISSUE #483] Enable optimize_rule of multi-gpu on A100 leads to RuntimeError #340

Open
opened 2026-10-29 14:38:08 +00:00 by bsakaguchi · 6 comments
Owner

Originally created by @ArYuZzz on GitHub (Feb 19, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/483

Precondition

Device: Dual A100(PCIe) + Xeon 3
Engine Version: ktransformers-0.2.1.post1+cu124torch24avx512-cp311-cp311-linux_x86_6409f5c5e
Environment: docker ubuntu 22.04 with privileged. host ubuntu 24.04.
Optimize Rule: ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-marlin.yaml 0564ac8
Command:

ktransformers --gguf_path DeepSeek-R1-Q4_K_M --model_path deepseek-r1-config --optimize_config_path DeepSeek-V3-Chat-multi-gpu-marlin-0564ac8.yaml

Result

The output log of ktransformers:
The operator injecting and weight loading seems successful.
Image
However, the log shows that 30~60 layers weight still be loaded into cuda:0
Image

VRAM Usage:
Meanwhile, the Memory-usage of cuda:1 does increases.
Image
Error Thrown:
While input prompt, the following RuntimeError will be thrown,
Image
Image

Originally created by @ArYuZzz on GitHub (Feb 19, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/483 ## Precondition **Device**: Dual A100(PCIe) + Xeon 3 **Engine Version**: [`ktransformers-0.2.1.post1+cu124torch24avx512-cp311-cp311-linux_x86_64`](https://github.com/kvcache-ai/ktransformers/releases/tag/v0.2.1.post1)`09f5c5e` **Environment**: docker `ubuntu 22.04 with privileged`. host `ubuntu 24.04`. **Optimize Rule**: [`ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-marlin.yaml`](https://github.com/kvcache-ai/ktransformers/blob/main/ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-marlin.yaml) `0564ac8 ` **Command**: ``` ktransformers --gguf_path DeepSeek-R1-Q4_K_M --model_path deepseek-r1-config --optimize_config_path DeepSeek-V3-Chat-multi-gpu-marlin-0564ac8.yaml ``` ## Result **The output log of ktransformers**: The operator injecting and weight loading *seems* successful. ![Image](https://github.com/user-attachments/assets/884ee5c2-589f-45f1-9d9d-a0aefaa0fce6) *However*, the log shows that 30~60 layers weight still be loaded into `cuda:0` ![Image](https://github.com/user-attachments/assets/a03fa366-3120-416b-974a-4dbde23d8de5) **VRAM Usage**: *Meanwhile*, the Memory-usage of `cuda:1` **does** increases. ![Image](https://github.com/user-attachments/assets/7121c352-125b-4027-b96b-8ea5b8cbd8d4) **Error Thrown**: While input prompt, the following `RuntimeError` will be thrown, ![Image](https://github.com/user-attachments/assets/e40cddfc-5843-4006-892c-308d6f273c3d) ![Image](https://github.com/user-attachments/assets/1af27f66-1acc-4074-bd45-656cb249c1bc)
Author
Owner

@ArYuZzz commented on GitHub (Feb 19, 2025):

@Azure-Tang Please check the issue.

<!-- gh-comment-id:2667424430 --> @ArYuZzz commented on GitHub (Feb 19, 2025): @Azure-Tang Please check the issue.
Author
Owner

@Jotakak-yu commented on GitHub (Feb 22, 2025):

Same issue. Any updates?

<!-- gh-comment-id:2676269022 --> @Jotakak-yu commented on GitHub (Feb 22, 2025): Same issue. Any updates?
Author
Owner

@proxy2008 commented on GitHub (Feb 24, 2025):

me 2

<!-- gh-comment-id:2677842850 --> @proxy2008 commented on GitHub (Feb 24, 2025): me 2
Author
Owner

@tempgidam commented on GitHub (Mar 2, 2025):

I have the same problem on 2x A6000 and Ubuntu 22.04. I tried both ktransformers v0.2.1 and v0.2.2.

<!-- gh-comment-id:2692674088 --> @tempgidam commented on GitHub (Mar 2, 2025): I have the same problem on 2x A6000 and Ubuntu 22.04. I tried both ktransformers v0.2.1 and v0.2.2.
Author
Owner

@ruralharry commented on GitHub (Jun 2, 2025):

INFO: 192.168.71.50:57796 - "OPTIONS /v1/chat/completions HTTP/1.1" 200 OK
INFO: 192.168.71.50:57796 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-06-02 14:14:02,267 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py[209]: get input ids of shape torch.Size([1, 5])
2025-06-02 14:14:02,267 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[144]: input_ids: torch.Size([1, 5])
2025-06-02 14:14:02,267 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[169]: same prefix len: 4
2025-06-02 14:14:02,269 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[178]: input_ids: torch.Size([1, 1])
2025-06-02 14:14:02,269 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[179]: generate_ids: torch.Size([1, 4])
2025-06-02 14:14:02,269 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[194]: cache position: 4 to 5
ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 76, in collapse_excgroups
    | yield
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 263, in call
    | async with anyio.create_task_group() as task_group:
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
    | return await self.app(scope, receive, send)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in call
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in call
    | await self.app(scope, receive, _send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in call
    | await self.simple_response(scope, receive, send, request_headers=headers)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    | await self.app(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app
    | await route.handle(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
    | await self.app(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
    | await response(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in call
    | with collapse_excgroups():
    | ^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in exit
    | self.gen.throw(value)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap
    | await func()
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response
    | async for chunk in self.body_iterator:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner
    | async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference
    | async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference
    | for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens):
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
    | response = gen.send(None)
    | ^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill
    | logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end])
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill
    | logits = self.model(
    | ^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward
    | outputs = self.model(
    | ^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward
    | layer_outputs = decoder_layer(
    | ^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward
    | hidden_states = self.input_layernorm(hidden_states)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward
    | return self.weight * hidden_states.to(input_dtype)
    | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!
    +------------------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in call
await self.simple_response(scope, receive, send, request_headers=headers)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response
await self.app(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in call
await self.middleware_stack(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
await response(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in call
with collapse_excgroups():
^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in exit
self.gen.throw(value)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap
await func()
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response
async for chunk in self.body_iterator:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner
async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference
async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference
for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
response = gen.send(None)
^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill
logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill
logits = self.model(
^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward
outputs = self.model(
^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward
layer_outputs = decoder_layer(
^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward
hidden_states = self.input_layernorm(hidden_states)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward
return self.weight * hidden_states.to(input_dtype)
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!
INFO: 192.168.71.50:57797 - "OPTIONS /v1/chat/completions HTTP/1.1" 200 OK
INFO: 192.168.71.50:57797 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-06-02 14:14:02,792 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py[209]: get input ids of shape torch.Size([1, 5])
2025-06-02 14:14:02,792 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[144]: input_ids: torch.Size([1, 5])
2025-06-02 14:14:02,793 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[169]: same prefix len: 4
2025-06-02 14:14:02,794 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[178]: input_ids: torch.Size([1, 1])
2025-06-02 14:14:02,794 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[179]: generate_ids: torch.Size([1, 4])
2025-06-02 14:14:02,794 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[194]: cache position: 4 to 5
ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 76, in collapse_excgroups
    | yield
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 263, in call
    | async with anyio.create_task_group() as task_group:
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
    | return await self.app(scope, receive, send)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in call
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in call
    | await self.app(scope, receive, _send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in call
    | await self.simple_response(scope, receive, send, request_headers=headers)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    | await self.app(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app
    | await route.handle(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
    | await self.app(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
    | await response(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in call
    | with collapse_excgroups():
    | ^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in exit
    | self.gen.throw(value)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap
    | await func()
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response
    | async for chunk in self.body_iterator:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner
    | async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference
    | async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference
    | for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens):
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
    | response = gen.send(None)
    | ^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill
    | logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end])
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill
    | logits = self.model(
    | ^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward
    | outputs = self.model(
    | ^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward
    | layer_outputs = decoder_layer(
    | ^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward
    | hidden_states = self.input_layernorm(hidden_states)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward
    | return self.weight * hidden_states.to(input_dtype)
    | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!
    +------------------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in call
await self.simple_response(scope, receive, send, request_headers=headers)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response
await self.app(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in call
await self.middleware_stack(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
await response(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in call
with collapse_excgroups():
^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in exit
self.gen.throw(value)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap
await func()
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response
async for chunk in self.body_iterator:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner
async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference
async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference
for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
response = gen.send(None)
^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill
logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill
logits = self.model(
^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward
outputs = self.model(
^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward
layer_outputs = decoder_layer(
^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward
hidden_states = self.input_layernorm(hidden_states)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward
return self.weight * hidden_states.to(input_dtype)
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!
INFO: 192.168.71.50:57805 - "OPTIONS /v1/chat/completions HTTP/1.1" 200 OK
INFO: 192.168.71.50:57805 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-06-02 14:14:03,839 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py[209]: get input ids of shape torch.Size([1, 5])
2025-06-02 14:14:03,839 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[144]: input_ids: torch.Size([1, 5])
2025-06-02 14:14:03,840 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[169]: same prefix len: 4
2025-06-02 14:14:03,841 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[178]: input_ids: torch.Size([1, 1])
2025-06-02 14:14:03,841 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[179]: generate_ids: torch.Size([1, 4])
2025-06-02 14:14:03,841 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[194]: cache position: 4 to 5
ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 76, in collapse_excgroups
    | yield
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 263, in call
    | async with anyio.create_task_group() as task_group:
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
    | return await self.app(scope, receive, send)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in call
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in call
    | await self.app(scope, receive, _send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in call
    | await self.simple_response(scope, receive, send, request_headers=headers)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    | await self.app(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app
    | await route.handle(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
    | await self.app(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
    | await response(scope, receive, send)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in call
    | with collapse_excgroups():
    | ^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in exit
    | self.gen.throw(value)
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
    | raise exc
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap
    | await func()
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response
    | async for chunk in self.body_iterator:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk
    | async for event in async_events:
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner
    | async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference
    | async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens):
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference
    | for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens):
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
    | response = gen.send(None)
    | ^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill
    | logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end])
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill
    | logits = self.model(
    | ^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward
    | outputs = self.model(
    | ^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward
    | layer_outputs = decoder_layer(
    | ^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward
    | hidden_states = self.input_layernorm(hidden_states)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    | return self._call_impl(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    | return forward_call(*args, **kwargs)
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward
    | return self.weight * hidden_states.to(input_dtype)
    | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!
    +------------------------------------

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in call
await self.simple_response(scope, receive, send, request_headers=headers)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response
await self.app(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in call
await self.middleware_stack(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
await response(scope, receive, send)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in call
with collapse_excgroups():
^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in exit
self.gen.throw(value)
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
raise exc
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap
await func()
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response
async for chunk in self.body_iterator:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk
async for event in async_events:
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner
async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference
async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens):
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference
for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
response = gen.send(None)
^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill
logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill
logits = self.model(
^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward
outputs = self.model(
^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward
layer_outputs = decoder_layer(
^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward
hidden_states = self.input_layernorm(hidden_states)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward
return self.weight * hidden_states.to(input_dtype)
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!

我也遇到了这个问题。

环境信息

代码分支:[github.com/kvcache-ai/ktransformers@7071970339],20250601最新
运行硬件:AMD EPYC 9755 *2 ,1TB内存,5080 *4
运行系统:Ubuntu 22.04 conda python3.12 cmake3.31.6
其他信息:
📌 NVIDIA CUDA 版本:
Cuda compilation tools, release 12.8, V12.8.93

📌 NVIDIA 驱动版本:
/usr/bin/nvidia-smi
| NVIDIA-SMI 570.133.07 Driver Version: 570.133.07 CUDA Version: 12.8 |

📌 PyTorch 版本:
2.7.0+cu128

📌 NumPy 版本:
2.1.2

📌 cpufeature 版本:
0.2.1

📌 flash-attn 版本:
2.7.4.post1
(自己编译)

📌 triton 版本:
Version: 3.3.0+gitcda42295
(自己编译)

我有4个GPU,在配置文件DeepSeek-V3-Chat-multi-gpu.yaml 中指定的 cuda:2和cuda:3
运行的是Deepseek-r1-0528-q8

Image
<!-- gh-comment-id:2931078902 --> @ruralharry commented on GitHub (Jun 2, 2025): INFO: 192.168.71.50:57796 - "OPTIONS /v1/chat/completions HTTP/1.1" 200 OK INFO: 192.168.71.50:57796 - "POST /v1/chat/completions HTTP/1.1" 200 OK 2025-06-02 14:14:02,267 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py[209]: get input ids of shape torch.Size([1, 5]) 2025-06-02 14:14:02,267 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[144]: input_ids: torch.Size([1, 5]) 2025-06-02 14:14:02,267 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[169]: same prefix len: 4 2025-06-02 14:14:02,269 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[178]: input_ids: torch.Size([1, 1]) 2025-06-02 14:14:02,269 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[179]: generate_ids: torch.Size([1, 4]) 2025-06-02 14:14:02,269 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[194]: cache position: 4 to 5 ERROR: Exception in ASGI application + Exception Group Traceback (most recent call last): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 76, in collapse_excgroups | yield | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 263, in __call__ | async with anyio.create_task_group() as task_group: | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi | result = await app( # type: ignore[func-returns-value] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ | return await self.app(scope, receive, send) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ | await super().__call__(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ | await self.middleware_stack(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ | await self.app(scope, receive, _send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in __call__ | await self.simple_response(scope, receive, send, request_headers=headers) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response | await self.app(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ | await self.middleware_stack(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app | await route.handle(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle | await self.app(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app | await wrap_app_handling_exceptions(app, request)(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app | await response(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in __call__ | with collapse_excgroups(): | ^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in __exit__ | self.gen.throw(value) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap | await func() | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response | async for chunk in self.body_iterator: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner | async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference | async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference | for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context | response = gen.send(None) | ^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill | logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill | logits = self.model( | ^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward | outputs = self.model( | ^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward | layer_outputs = decoder_layer( | ^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward | hidden_states = self.input_layernorm(hidden_states) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward | return self.weight * hidden_states.to(input_dtype) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0! +------------------------------------ During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ await self.app(scope, receive, _send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in __call__ await self.simple_response(scope, receive, send, request_headers=headers) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response await self.app(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ await self.middleware_stack(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app await route.handle(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app await response(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in __call__ with collapse_excgroups(): ^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap await func() File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response async for chunk in self.body_iterator: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill logits = self.model( ^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward outputs = self.model( ^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward layer_outputs = decoder_layer( ^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward hidden_states = self.input_layernorm(hidden_states) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward return self.weight * hidden_states.to(input_dtype) ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0! INFO: 192.168.71.50:57797 - "OPTIONS /v1/chat/completions HTTP/1.1" 200 OK INFO: 192.168.71.50:57797 - "POST /v1/chat/completions HTTP/1.1" 200 OK 2025-06-02 14:14:02,792 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py[209]: get input ids of shape torch.Size([1, 5]) 2025-06-02 14:14:02,792 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[144]: input_ids: torch.Size([1, 5]) 2025-06-02 14:14:02,793 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[169]: same prefix len: 4 2025-06-02 14:14:02,794 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[178]: input_ids: torch.Size([1, 1]) 2025-06-02 14:14:02,794 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[179]: generate_ids: torch.Size([1, 4]) 2025-06-02 14:14:02,794 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[194]: cache position: 4 to 5 ERROR: Exception in ASGI application + Exception Group Traceback (most recent call last): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 76, in collapse_excgroups | yield | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 263, in __call__ | async with anyio.create_task_group() as task_group: | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi | result = await app( # type: ignore[func-returns-value] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ | return await self.app(scope, receive, send) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ | await super().__call__(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ | await self.middleware_stack(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ | await self.app(scope, receive, _send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in __call__ | await self.simple_response(scope, receive, send, request_headers=headers) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response | await self.app(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ | await self.middleware_stack(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app | await route.handle(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle | await self.app(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app | await wrap_app_handling_exceptions(app, request)(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app | await response(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in __call__ | with collapse_excgroups(): | ^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in __exit__ | self.gen.throw(value) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap | await func() | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response | async for chunk in self.body_iterator: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner | async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference | async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference | for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context | response = gen.send(None) | ^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill | logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill | logits = self.model( | ^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward | outputs = self.model( | ^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward | layer_outputs = decoder_layer( | ^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward | hidden_states = self.input_layernorm(hidden_states) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward | return self.weight * hidden_states.to(input_dtype) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0! +------------------------------------ During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ await self.app(scope, receive, _send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in __call__ await self.simple_response(scope, receive, send, request_headers=headers) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response await self.app(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ await self.middleware_stack(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app await route.handle(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app await response(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in __call__ with collapse_excgroups(): ^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap await func() File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response async for chunk in self.body_iterator: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill logits = self.model( ^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward outputs = self.model( ^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward layer_outputs = decoder_layer( ^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward hidden_states = self.input_layernorm(hidden_states) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward return self.weight * hidden_states.to(input_dtype) ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0! INFO: 192.168.71.50:57805 - "OPTIONS /v1/chat/completions HTTP/1.1" 200 OK INFO: 192.168.71.50:57805 - "POST /v1/chat/completions HTTP/1.1" 200 OK 2025-06-02 14:14:03,839 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py[209]: get input ids of shape torch.Size([1, 5]) 2025-06-02 14:14:03,839 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[144]: input_ids: torch.Size([1, 5]) 2025-06-02 14:14:03,840 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[169]: same prefix len: 4 2025-06-02 14:14:03,841 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[178]: input_ids: torch.Size([1, 1]) 2025-06-02 14:14:03,841 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[179]: generate_ids: torch.Size([1, 4]) 2025-06-02 14:14:03,841 DEBUG /home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py[194]: cache position: 4 to 5 ERROR: Exception in ASGI application + Exception Group Traceback (most recent call last): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 76, in collapse_excgroups | yield | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 263, in __call__ | async with anyio.create_task_group() as task_group: | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi | result = await app( # type: ignore[func-returns-value] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ | return await self.app(scope, receive, send) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ | await super().__call__(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ | await self.middleware_stack(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ | await self.app(scope, receive, _send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in __call__ | await self.simple_response(scope, receive, send, request_headers=headers) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response | await self.app(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ | await self.middleware_stack(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app | await route.handle(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle | await self.app(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app | await wrap_app_handling_exceptions(app, request)(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app | await response(scope, receive, send) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in __call__ | with collapse_excgroups(): | ^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in __exit__ | self.gen.throw(value) | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups | raise exc | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap | await func() | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response | async for chunk in self.body_iterator: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk | async for event in async_events: | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner | async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference | async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens): | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference | for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens): | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context | response = gen.send(None) | ^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill | logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end]) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill | logits = self.model( | ^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward | outputs = self.model( | ^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward | layer_outputs = decoder_layer( | ^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward | hidden_states = self.input_layernorm(hidden_states) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl | return self._call_impl(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl | return forward_call(*args, **kwargs) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward | return self.weight * hidden_states.to(input_dtype) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0! +------------------------------------ During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ await self.app(scope, receive, _send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 93, in __call__ await self.simple_response(scope, receive, send, request_headers=headers) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/cors.py", line 144, in simple_response await self.app(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ await self.middleware_stack(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 734, in app await route.handle(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/routing.py", line 74, in app await response(scope, receive, send) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 262, in __call__ with collapse_excgroups(): ^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups raise exc File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 266, in wrap await func() File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/starlette/responses.py", line 246, in stream_response async for chunk in self.body_iterator: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 80, in check_client_link async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 93, in to_stream_reply async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 87, in add_done async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/schemas/assistants/streaming.py", line 107, in filter_chat_chunk async for event in async_events: File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 266, in inner async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 241, in inference async for v in super().inference(local_messages, thread_id, temperature, top_p, max_tokens, max_completion_tokens): File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 466, in inference for t in self.prefill(input_ids, self.check_is_new(thread_id), temperature, top_p, max_tokens, max_completion_tokens): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 36, in generator_context response = gen.send(None) ^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 224, in prefill logits = chunk_prefill(input_ids[:, chunk_start:chunk_end], cache_position[chunk_start:chunk_end]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 207, in chunk_prefill logits = self.model( ^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1690, in forward outputs = self.model( ^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/operators/models.py", line 751, in forward layer_outputs = decoder_layer( ^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 1204, in forward hidden_states = self.input_layernorm(hidden_states) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ruralharry/miniconda3/envs/kt/lib/python3.12/site-packages/ktransformers/models/modeling_deepseek_v3.py", line 110, in forward return self.weight * hidden_states.to(input_dtype) ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0! 我也遇到了这个问题。 环境信息 代码分支:[https://github.com/kvcache-ai/ktransformers/commit/70719703396d4efabeb047f0f480436131f05918],20250601最新 运行硬件:AMD EPYC 9755 *2 ,1TB内存,5080 *4 运行系统:Ubuntu 22.04 conda python3.12 cmake3.31.6 其他信息: 📌 NVIDIA CUDA 版本: Cuda compilation tools, release 12.8, V12.8.93 📌 NVIDIA 驱动版本: /usr/bin/nvidia-smi | NVIDIA-SMI 570.133.07 Driver Version: 570.133.07 CUDA Version: 12.8 | 📌 PyTorch 版本: 2.7.0+cu128 📌 NumPy 版本: 2.1.2 📌 cpufeature 版本: 0.2.1 📌 flash-attn 版本: 2.7.4.post1 (自己编译) 📌 triton 版本: Version: 3.3.0+gitcda42295 (自己编译) 我有4个GPU,在配置文件DeepSeek-V3-Chat-multi-gpu.yaml 中指定的 cuda:2和cuda:3 运行的是Deepseek-r1-0528-q8 <img width="916" alt="Image" src="https://github.com/user-attachments/assets/b1afd281-fd7d-4169-8ce5-e2b4a06c44bd" />
Author
Owner

@ruralharry commented on GitHub (Jun 2, 2025):

@Atream 您好,还有人在关注这个问题吗?v0.2.1 就存在的问题,现在v0.3.1 了,还存在呢?

<!-- gh-comment-id:2931102327 --> @ruralharry commented on GitHub (Jun 2, 2025): @Atream 您好,还有人在关注这个问题吗?v0.2.1 就存在的问题,现在v0.3.1 了,还存在呢?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/ktransformers#340
No description provided.