Skip to content

Commit 5936a61

Browse files
authored
convert : BailingMoE : fix qkv split when head_dim is 0 (#12687)
NOTE: Ling-lite-base is broken, see https://huggingface.co/inclusionAI/Ling-lite-base/discussions/2
1 parent 3fd072a commit 5936a61

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

convert_hf_to_gguf.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -5146,10 +5146,7 @@ def set_vocab(self):
51465146
def set_gguf_parameters(self):
51475147
super().set_gguf_parameters()
51485148
hparams = self.hparams
5149-
if hparams.get("head_dim"):
5150-
rope_dim = hparams["head_dim"]
5151-
else:
5152-
rope_dim = hparams["hidden_size"] // hparams["num_attention_heads"]
5149+
rope_dim = hparams.get("head_dim") or hparams["hidden_size"] // hparams["num_attention_heads"]
51535150

51545151
self.gguf_writer.add_rope_dimension_count(rope_dim)
51555152
self.gguf_writer.add_rope_scaling_type(gguf.RopeScalingType.NONE)
@@ -5175,7 +5172,7 @@ def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iter
51755172
n_head = self.hparams["num_attention_heads"]
51765173
n_kv_head = self.hparams.get("num_key_value_heads")
51775174
n_embd = self.hparams["hidden_size"]
5178-
head_dim = self.hparams.get("head_dim", n_embd // n_head)
5175+
head_dim = self.hparams.get("head_dim") or n_embd // n_head
51795176

51805177
output_name = self.format_tensor_name(gguf.MODEL_TENSOR.OUTPUT)
51815178

0 commit comments

Comments
 (0)