Skip to content

Commit abb1238

Browse files
committed
fix conversion
1 parent 6472d8c commit abb1238

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

convert_hf_to_gguf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,6 +3425,11 @@ def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iter
34253425
head_dim = n_embd // num_heads
34263426
num_groups = num_heads // q_per_kv
34273427

3428+
name = name.replace("language_model.", "") # InternVL
3429+
if name.startswith("mlp") or name.startswith("vision_model"):
3430+
# skip visual tensors
3431+
return []
3432+
34283433
if bid is not None and f"model.layers.{bid}.attention.wqkv" in name:
34293434
qkv = data_torch
34303435

@@ -3498,6 +3503,10 @@ def set_gguf_parameters(self):
34983503
def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:
34993504
n_head = self.hparams["num_attention_heads"]
35003505
n_kv_head = self.hparams.get("num_key_value_heads")
3506+
name = name.replace("language_model.", "") # InternVL
3507+
if name.startswith("mlp") or name.startswith("vision_model"):
3508+
# skip visual tensors
3509+
return []
35013510
if name.endswith(("q_proj.weight", "q_proj.bias")):
35023511
data_torch = LlamaModel.permute(data_torch, n_head, n_head)
35033512
if name.endswith(("k_proj.weight", "k_proj.bias")):

0 commit comments

Comments
 (0)