[GH-ISSUE #1374] [Bug] ktransformers 0.31跑deepseekr1报错assert self.gate_type == GGMLQuantizationType.BF16 #920

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

Originally created by @south-ocean on GitHub (Jun 8, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1374

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 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.
  • 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.
  • 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

我使用ktransformers-0.3.1版本跑deepseekr1,CPU是Intel(R) Xeon(R) Platinum 8468V,运行指令是USE_NUMA=1 python3 ./ktransformers/local_chat.py --model_path /home/DeepSeek-R1-GGUF/ --gguf_path /home/deepseek-r1/ --cpu_infer 65 --max_new_tokens 1000 --optimize-config-path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-amx.yaml,
报错日志如下:
loading model.layers.1.self_attn.q_a_layernorm.weight to cuda
loading model.layers.1.self_attn.kv_a_layernorm.weight to cuda
loading model.layers.1.self_attn.kv_b_proj.weight to cuda
loading model.layers.1.input_layernorm.weight to cuda
loading model.layers.1.post_attention_layernorm.weight to cuda
loading model.layers.2.self_attn.q_a_layernorm.weight to cuda
loading model.layers.2.self_attn.kv_a_layernorm.weight to cuda
loading model.layers.2.self_attn.kv_b_proj.weight to cuda
loading model.layers.2.input_layernorm.weight to cuda
loading model.layers.2.post_attention_layernorm.weight to cuda
loading model.layers.3.self_attn.q_a_layernorm.weight to cuda
loading model.layers.3.self_attn.kv_a_layernorm.weight to cuda
loading model.layers.3.self_attn.kv_b_proj.weight to cuda
Traceback (most recent call last):
File "/home/kt-0.3/ktransformers/./ktransformers/local_chat.py", line 191, in
fire.Fire(local_chat)
File "/root/anaconda3/envs/kt/lib/python3.10/site-packages/fire/core.py", line 135, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/root/anaconda3/envs/kt/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/root/anaconda3/envs/kt/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/home/kt-0.3/ktransformers/./ktransformers/local_chat.py", line 118, in local_chat
optimize_and_load_gguf(model, optimize_config_path, gguf_path, config, default_device=device)
File "/home/kt-0.3/ktransformers/./ktransformers/optimize/optimize.py", line 131, in optimize_and_load_gguf
load_weights(module, weights_loader, device=default_device)
File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights
load_weights(child, gguf_loader, prefix+name+".", device=device)
File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 166, in load_weights
module.load()
File "/home/kt-0.3/ktransformers/./ktransformers/operators/base_operator.py", line 63, in load
utils.load_weights(child, self.gguf_loader, self.key+".")
File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights
load_weights(child, gguf_loader, prefix+name+".", device=device)
File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights
load_weights(child, gguf_loader, prefix+name+".", device=device)
File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights
load_weights(child, gguf_loader, prefix+name+".", device=device)
File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 166, in load_weights
module.load()
File "/home/kt-0.3/ktransformers/./ktransformers/operators/base_operator.py", line 63, in load
utils.load_weights(child, self.gguf_loader, self.key+".")
File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights
load_weights(child, gguf_loader, prefix+name+".", device=device)
File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 166, in load_weights
module.load()
File "/home/kt-0.3/ktransformers/./ktransformers/operators/experts.py", line 684, in load
self.generate_experts.load(w, warmup=warmup)
File "/home/kt-0.3/ktransformers/./ktransformers/operators/experts.py", line 226, in load
assert self.gate_type == GGMLQuantizationType.BF16
具体配置及报错见下图:
请问下intel的amx优化是只支持BF16的权重在线量化成int8(CPU端)及int4(GPU端)么?是否支持DeepSeek-R1-Q4_K_M?amx具体的优势场景有说明么?

Reproduction

USE_NUMA=1 python3 ./ktransformers/local_chat.py --model_path /home/DeepSeek-R1-GGUF/ --gguf_path /home/deepseek-r1/ --cpu_infer 65 --max_new_tokens 1000 --optimize-config-path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-amx.yam
DeepSeek-R1-Q4_K_M

Environment

L20 GPU Intel(R) Xeon(R) Platinum 8468V CPU

Originally created by @south-ocean on GitHub (Jun 8, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1374 ### Checklist - [ ] 1. I have searched related issues but cannot get the expected help. - [ ] 2. The bug has not been fixed in the latest version. - [ ] 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. - [ ] 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. - [ ] 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 我使用ktransformers-0.3.1版本跑deepseekr1,CPU是Intel(R) Xeon(R) Platinum 8468V,运行指令是USE_NUMA=1 python3 ./ktransformers/local_chat.py --model_path /home/DeepSeek-R1-GGUF/ --gguf_path /home/deepseek-r1/ --cpu_infer 65 --max_new_tokens 1000 --optimize-config-path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-amx.yaml, 报错日志如下: loading model.layers.1.self_attn.q_a_layernorm.weight to cuda loading model.layers.1.self_attn.kv_a_layernorm.weight to cuda loading model.layers.1.self_attn.kv_b_proj.weight to cuda loading model.layers.1.input_layernorm.weight to cuda loading model.layers.1.post_attention_layernorm.weight to cuda loading model.layers.2.self_attn.q_a_layernorm.weight to cuda loading model.layers.2.self_attn.kv_a_layernorm.weight to cuda loading model.layers.2.self_attn.kv_b_proj.weight to cuda loading model.layers.2.input_layernorm.weight to cuda loading model.layers.2.post_attention_layernorm.weight to cuda loading model.layers.3.self_attn.q_a_layernorm.weight to cuda loading model.layers.3.self_attn.kv_a_layernorm.weight to cuda loading model.layers.3.self_attn.kv_b_proj.weight to cuda Traceback (most recent call last): File "/home/kt-0.3/ktransformers/./ktransformers/local_chat.py", line 191, in <module> fire.Fire(local_chat) File "/root/anaconda3/envs/kt/lib/python3.10/site-packages/fire/core.py", line 135, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/root/anaconda3/envs/kt/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire component, remaining_args = _CallAndUpdateTrace( File "/root/anaconda3/envs/kt/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "/home/kt-0.3/ktransformers/./ktransformers/local_chat.py", line 118, in local_chat optimize_and_load_gguf(model, optimize_config_path, gguf_path, config, default_device=device) File "/home/kt-0.3/ktransformers/./ktransformers/optimize/optimize.py", line 131, in optimize_and_load_gguf load_weights(module, weights_loader, device=default_device) File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights load_weights(child, gguf_loader, prefix+name+".", device=device) File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 166, in load_weights module.load() File "/home/kt-0.3/ktransformers/./ktransformers/operators/base_operator.py", line 63, in load utils.load_weights(child, self.gguf_loader, self.key+".") File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights load_weights(child, gguf_loader, prefix+name+".", device=device) File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights load_weights(child, gguf_loader, prefix+name+".", device=device) File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights load_weights(child, gguf_loader, prefix+name+".", device=device) File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 166, in load_weights module.load() File "/home/kt-0.3/ktransformers/./ktransformers/operators/base_operator.py", line 63, in load utils.load_weights(child, self.gguf_loader, self.key+".") File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 164, in load_weights load_weights(child, gguf_loader, prefix+name+".", device=device) File "/home/kt-0.3/ktransformers/./ktransformers/util/utils.py", line 166, in load_weights module.load() File "/home/kt-0.3/ktransformers/./ktransformers/operators/experts.py", line 684, in load self.generate_experts.load(w, warmup=warmup) File "/home/kt-0.3/ktransformers/./ktransformers/operators/experts.py", line 226, in load assert self.gate_type == GGMLQuantizationType.BF16 具体配置及报错见下图: 请问下intel的amx优化是只支持BF16的权重在线量化成int8(CPU端)及int4(GPU端)么?是否支持DeepSeek-R1-Q4_K_M?amx具体的优势场景有说明么? <!-- Failed to upload "image.png" --> <!-- Failed to upload "image.png" --> ### Reproduction USE_NUMA=1 python3 ./ktransformers/local_chat.py --model_path /home/DeepSeek-R1-GGUF/ --gguf_path /home/deepseek-r1/ --cpu_infer 65 --max_new_tokens 1000 --optimize-config-path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-amx.yam DeepSeek-R1-Q4_K_M ### Environment L20 GPU Intel(R) Xeon(R) Platinum 8468V CPU
Author
Owner

@MeJerry215 commented on GitHub (Jun 9, 2025):

r1-q4_k_M 的gate_type Q4_K = 12, 已经量化后的weight,所以如果要能用这个 看起来应该需要支持 将Q4_K 反量化为 BF16 load weight的时候。
不过我看他说使用deepseek-v3 int8 性能达到了 418 TPS, 这个性能怎么测试出来的。。

<!-- gh-comment-id:2954500643 --> @MeJerry215 commented on GitHub (Jun 9, 2025): r1-q4_k_M 的gate_type Q4_K = 12, 已经量化后的weight,所以如果要能用这个 看起来应该需要支持 将Q4_K 反量化为 BF16 load weight的时候。 不过我看他说使用deepseek-v3 int8 性能达到了 418 TPS, 这个性能怎么测试出来的。。
Author
Owner

@qiuqiu10 commented on GitHub (Jun 10, 2025):

intel的amx优化目前只支持BF16的权重格式,DeepSeek-R1-Q4_K_M请用DeepSeek-V3-Chat-serve.yaml或DeepSeek-V3-Chat.yaml

<!-- gh-comment-id:2957526970 --> @qiuqiu10 commented on GitHub (Jun 10, 2025): intel的amx优化目前只支持BF16的权重格式,DeepSeek-R1-Q4_K_M请用DeepSeek-V3-Chat-serve.yaml或DeepSeek-V3-Chat.yaml
Author
Owner

@Big2Wheel commented on GitHub (Oct 27, 2025):

大佬你好,请问下DeepSeek-R1-Q4_K_M模型权重现在可以支持AMXInt8了嘛

<!-- gh-comment-id:3451043152 --> @Big2Wheel commented on GitHub (Oct 27, 2025): 大佬你好,请问下DeepSeek-R1-Q4_K_M模型权重现在可以支持AMXInt8了嘛
Author
Owner

@Big2Wheel commented on GitHub (Oct 27, 2025):

intel的amx优化目前只支持BF16的权重格式,DeepSeek-R1-Q4_K_M请用DeepSeek-V3-Chat-serve.yaml或DeepSeek-V3-Chat.yaml

大佬你好,请问下DeepSeek-R1-Q4_K_M模型权重现在可以支持AMXInt8了嘛

<!-- gh-comment-id:3451135091 --> @Big2Wheel commented on GitHub (Oct 27, 2025): > intel的amx优化目前只支持BF16的权重格式,DeepSeek-R1-Q4_K_M请用DeepSeek-V3-Chat-serve.yaml或DeepSeek-V3-Chat.yaml 大佬你好,请问下DeepSeek-R1-Q4_K_M模型权重现在可以支持AMXInt8了嘛
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#920
No description provided.