kvcache-ai / kvcache-ai/ktransformers
[Bug] DeepSeek-V3-0324 671b:Q4_K_M one prompt crash / insanity
- Dominant language
- Python
- Stars
- 19.5k
- Forks
- 1.6k
- Avg merge
- 19h 32m
- Merged PRs (30d)
- 27
Description
### Checklist
- [x] 1. I have searched related issues but cannot get the expected help.
- [x] 2. The bug has not been fixed in the latest version.
- [x] 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
- [x] 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/kvcache-ai/ktransformers/discussions. Otherwise, it will be closed.
- [x] 5. To help the community, I will use Chinese/English or attach an Chinese/English translation if using another language. Non-Chinese/English content without translation may be closed.
### Describe the bug
I have a one shot prompt that "crashes" ktransformers when running DeepSeek V3 0324 Q4_K_M. Sometimes I get a backtrace, but sometimes it just outputs gibberish afterward. Here's the backtrace when I get it:
```
INFO: 192.168.0.201:65208 - "POST /v1/chat/completions HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 403,
in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60,
in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call
__
await super().__call__(scope, receive, send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/applications.py", line 112, in __cal
l__
await self.middleware_stack(scope, receive, send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in
__call__
raise exc
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in
__call__
await self.app(scope, receive, _send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in __c
all__
await self.app(scope, receive, send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62,
in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in
wrapped_app
raise exc
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in
wrapped_app
await app(scope, receive, sender)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/routing.py", line 714, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in
wrapped_app
raise exc
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in
wrapped_app
await app(scope, receive, sender)
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/ktransformers/server/api/openai/endpoints/chat.py", line 436, in chat_completion
async for res in interface.inference(input_message, id, create.temperature, create.top_p, create.max_tokens, create.max_completion_tokens):
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/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/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 474, in inference
for t, finish_reason in self.generate():
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 36, in generator_context
response = gen.send(None)
^^^^^^^^^^^^^^
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 411, in generate
next_token = self.decode_one_tokens()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/ktransformers.py", line 127, in decode_one_tokens
return self.logits_to_token(logits)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jesse/anaconda3/envs/ktransformers_head_cu128/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/transformers.py", line 299, in logits_to_token
last = last.item()
^^^^^^^^^^^
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
```
### Reproduction
I recorded this session using `mitmdump`. You can read all about it and download a curl script to replay the prompt here: https://github.com/createthis/ktransformers_8dc1ab9_bug_deepseek_v3_0324
I mention a specific commit of ktransformers in the README, but I just reproduced it using HEAD `64ec0ec` too.
### Environment
dual EPYC 9355
768gb RAM
96gb blackwell 6000 pro
CUDA Version: 12.8
Driver Version: 570.124.06
OS: ubuntu 24.04.02 LTS
Contributor guide
Assessment
This issue has not been assessed yet.