mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-11-05 01:07:28 +00:00
[GH-ISSUE #885] [Bug] 模型推理过程出现nan #642
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/ktransformers#642
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tunantu on GitHub (Mar 14, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/885
检查清单
问题描述
在部署DeepSeek-R1-Q4_K_M和DeepSeek-R1-Q8_0后,进行推理的时候报错:
File "/home/wangks/.conda/envs/ktransformers/lib/python3.11/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/wangks/ktransformers/ktransformers/local_chat_bak.py", line 178, in local_chat
generated = prefill_and_generate(
^^^^^^^^^^^^^^^^^^^^^
File "/home/wangks/ktransformers/ktransformers/util/utils.py", line 239, in prefill_and_generate
next_token = torch.multinomial(probs, num_samples=1).squeeze(1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with
TORCH_USE_CUDA_DSAto enable device-side assertions./pytorch/aten/src/ATen/native/cuda/TensorCompare.cu:110: _assert_async_cuda_kernel: block: [0,0,0], thread: [0,0,0] Assertion
probability tensor contains eitherinf,nanor element < 0failed.同样的环境,运行:DeepSeek-V2-Lite-Chat.Q6_K_M不会出错。
我已经检查过,g++是符合版本要求的:
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
复现步骤
执行命令:python -m ktransformers.local_chat --model_path deepseek-ai/DeepSeek-R1 --gguf_path DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M --optimize_config_path ./ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-4.yaml
模型:DeepSeek-R1-Q4_K_M和DeepSeek-R1-Q8_0
环境信息
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.。
单张/4张4090。
CPU: Model name: Intel(R) Xeon(R) Gold 6230R CPU @ 2.10GHz
@Atream commented on GitHub (Mar 15, 2025):
请更新最新版本的代码并重新编译,为确保重新编译生效,建议先删除旧版本的编译结果。如果仍然有nan的问题,请提供prompt
@tunantu commented on GitHub (Mar 18, 2025):
问题已经解决。
原因: 下载到本地的GGUF文件和huggingface上官方版本的文件相比,文件遭到了损害。
解决思路:通过sha256sum计算下载下来的每个gguf文件的sha56值,和官方文件公布的sha256值进行对比,定位出受损害的文件。
解决方法: 定位出受损害的文件后,重新下载该文件即可。