mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-11-05 01:07:28 +00:00
[GH-ISSUE #1195] [Bug] 0.2.4Post1 Cannot Load Unsloth Dynamic v2.0 UD-Q4_K_XL #817
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/ktransformers#817
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 @Ning18 on GitHub (Apr 25, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1195
Originally assigned to: @Azure-Tang on GitHub.
Checklist
Describe the bug
The Unsloth Dynamic v2.0 UD-Q4_K_XL released a day ago, downloaded from https://huggingface.co/unsloth/DeepSeek-R1-GGUF-UD/tree/main/UD-Q4_K_XL, cannot be loaded by 0.2.4Post1.
[Note]
Exception: can't find blk.0.attn_kv_b.weight in GGUF file!
[log]
Injecting model.layers.60.mlp.shared_experts.down_proj as ktransformers.operators.linear . KTransformersLinear
Injecting model.layers.60.mlp.shared_experts.act_fn as default
Injecting model.layers.60.input_layernorm as ktransformers.operators.layernorm . RMSNorm
Injecting model.layers.60.post_attention_layernorm as ktransformers.operators.layernorm . RMSNorm
Injecting model.norm as ktransformers.operators.layernorm . RMSNorm
Injecting cache as default
Injecting lm_head as ktransformers.operators.linear . KTransformersLinear
loading token_embd.weight to cpu
loading token_embd.weight with CPU
loading blk.0.attn_q_a_norm.weight to cuda
loading blk.0.attn_kv_a_norm.weight to cuda
Process SpawnProcess-1:
...
...
File "... .../ktransformers/util/utils.py", line 118, in load_cur_state_dict
raise Exception(f"can't find {translated_key} in GGUF file!")
Exception: can't find blk.0.attn_kv_b.weight in GGUF file!
Reproduction
#!/bin/bash
#gguf_path="/models/R1-Q2KXL"
gguf_path="/models/R1-UD2-Q4KXL"
optimize_config_path="ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-serve.yaml"
python ktransformers/server/main.py
--port 10002
--model_name R1
--model_path /models/R1
--gguf_path "$gguf_path"
--optimize_config_path "$optimize_config_path"
--max_new_tokens 32000
--cache_lens 260000
--chunk_size 256
--max_batch_size 4
--backend_type balance_serve
--force_think
--log_file R1.log
--temperature 0.6
Environment
OS: ubuntu 22.04
GPU: RTX 5000ada 32GB
CPU: EPYC9654x1
DDR5 768GB
@Azure-Tang commented on GitHub (Apr 25, 2025):
Can you check gguf sha256sum is corresponding with huggingface.
@Ning18 commented on GitHub (Apr 25, 2025):
Yes, as I said in the [Note] section of the original post. I checked sha256sum of all the ggufs, and produced the same values as huggingface's.
@Ning18 commented on GitHub (Apr 25, 2025):
I think I have found the direct reason for the problem. The new UD 2.0 ggufs changed its weight's name and tensor size.
Just as the error message suggests: "Exception: can't find blk.0.attn_kv_b.weight in GGUF file!"
[new gguf, cannot load]
blk.0.attn_k_b.weight [128, 512, 128]
blk.0.attn_v_b.weight [512, 128, 128]
[old, can load]
They removed blk.0.attn_kv_b.weight, and added blk.0.attn_k_b.weight and blk.0.attn_v_b.weight.
Can the problem be overcome by modifying optimize_config file?
@Azure-Tang commented on GitHub (Apr 26, 2025):
No, I think we need to adjust the logic for how we process attn_kv_b. In our implementation, part of attn_kv_b is merged into o_projection during the inference stage to achieve better performance.
I will work on finding a solution that can support both formats.
@Azure-Tang commented on GitHub (Apr 26, 2025):
If you're eager to try the latest Unsloth, I suggest modifying the code as follows:
Update [this line](
github.com/kvcache-ai/ktransformers@a7b995365e/ktransformers/models/modeling_deepseek_v3.py (L676)) by replacingself.kv_b_projwith:Disable the absorb function [here](
github.com/kvcache-ai/ktransformers@a7b995365e/ktransformers/operators/attention.py (L405)).Then, replace the two matmul operations related to
q_absorbandout_absorbwithself.attn_k_bandself.attn_v_brespectively.I believe this approach should work.
@Ning18 commented on GitHub (Apr 26, 2025):
Thanks for the instant response! I'll have a try during the May-Day holiday.
@adonispujols commented on GitHub (May 6, 2025):
Fixing this would be greatly appreciated!
@ltcs11 commented on GitHub (May 22, 2025):
still have some problems with:
or can we specific a llama.cpp commit id that create old style attn_kv_b
i found is 06bb53ad9b6e6d92b6ab6979927530080b1c990c (before 25.04.15 this commit
github.com/ggml-org/llama.cpp@daa422881a)@trilog-inc commented on GitHub (May 29, 2025):
Hi ,
I am running into this problem with the new R1-0528 quants from unsloth. Tried the fix mentionned above but didn't work. Has anyone gotten it to work with the new attn_kv split?
@Martossien commented on GitHub (May 29, 2025):
Same here with R1-0528 ...
@344303947 commented on GitHub (May 30, 2025):
Same here with R1-0528 ...
UD-Q2_K_XL
find blk.0.attn_kv_b.weight in GGUF
@344303947 commented on GitHub (May 30, 2025):
loading blk.0.attn_q_a_norm.weight to cuda
loading blk.0.attn_kv_a_norm.weight to cuda
Process SpawnProcess-1:
Traceback (most recent call last):
File "/home/sean/miniconda3/envs/kt/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/home/sean/miniconda3/envs/kt/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 244, in run_engine
engine = Engine(args, token_queue, broadcast_endpoint)
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 162, in init
optimize_and_load_gguf(self.model, optimize_config_path, gguf_path, config)
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/optimize/optimize.py", line 131, in optimize_and_load_gguf
load_weights(module, gguf_loader)
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 127, in load_weights
module.load()
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/operators/base_operator.py", line 63, in load
utils.load_weights(child, self.gguf_loader, self.key+".")
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 127, in load_weights
module.load()
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/operators/base_operator.py", line 63, in load
utils.load_weights(child, self.gguf_loader, self.key+".")
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 123, in load_weights
load_cur_state_dict(module, gguf_loader, prefix)
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/util/utils.py", line 118, in load_cur_state_dict
raise Exception(f"can't find {translated_key} in GGUF file!")
Exception: can't find blk.0.attn_kv_b.weight in GGUF file!
^CTraceback (most recent call last):
File "/home/sean/ubuntu/ktransformers/ktransformers/server/main.py", line 145, in
main()
File "/home/sean/ubuntu/ktransformers/ktransformers/server/main.py", line 132, in main
create_interface(config=cfg, default_args=cfg)
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/server/utils/create_interface.py", line 30, in create_interface
GlobalInterface.interface = BackendInterface(default_args)
File "/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 284, in init
start_event.wait()
File "/home/sean/miniconda3/envs/kt/lib/python3.10/multiprocessing/synchronize.py", line 349, in wait
self._cond.wait(timeout)
File "/home/sean/miniconda3/envs/kt/lib/python3.10/multiprocessing/synchronize.py", line 261, in wait
return self._wait_semaphore.acquire(True, timeout)
KeyboardInterrupt
@Azure-Tang commented on GitHub (May 30, 2025):
We are downloading latest gguf to test this issue.
@apalesnail commented on GitHub (May 30, 2025):
Same issue observed in Q4_K_M deepseek r1 0528
@trilog-inc commented on GitHub (May 30, 2025):
Thanks @Azure-Tang ! I may try to quantize R1 0528 using an old version of llama.cpp, gonna have to fetch a new drive for storage though ...
Otherwise it seems that this needs to be addressed. The gguf quantization scripts of llama.cpp are all configured to output this new type of GGUF from now on.
@344303947 commented on GitHub (Jun 2, 2025):
deepseek r1 0528 main分支代码已解决问题。
@Ning18 commented on GitHub (Jun 2, 2025):
The issue is solved by [Patch] lload DeepSeek-R1-0528.
I confirmed that the main branch right now (0.3.1) can successfully load UD-Q4_K_XL under unsloth/DeepSeek-V3-0324-GGUF-UD.
@StormMapleleaf commented on GitHub (Jun 6, 2025):
Could you please provide more details on the second point?“Then, replace the two matmul operations related to
q_absorbandout_absorbwithself.attn_k_bandself.attn_v_brespectively.”