Skip to content

Commit ae803bf

Browse files
authored
convert : bailingmoe : set yarn metadata if present (#13312)
1 parent 66645a5 commit ae803bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

convert_hf_to_gguf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5680,7 +5680,12 @@ def set_gguf_parameters(self):
56805680
rope_dim = hparams.get("head_dim") or hparams["hidden_size"] // hparams["num_attention_heads"]
56815681

56825682
self.gguf_writer.add_rope_dimension_count(rope_dim)
5683-
self.gguf_writer.add_rope_scaling_type(gguf.RopeScalingType.NONE)
5683+
if (self.hparams.get("rope_scaling") or {}).get("type") == "yarn" and "factor" in self.hparams["rope_scaling"]:
5684+
self.gguf_writer.add_rope_scaling_type(gguf.RopeScalingType.YARN)
5685+
self.gguf_writer.add_rope_scaling_factor(self.hparams["rope_scaling"]["factor"])
5686+
self.gguf_writer.add_rope_scaling_orig_ctx_len(self.hparams["rope_scaling"]["original_max_position_embeddings"])
5687+
else:
5688+
self.gguf_writer.add_rope_scaling_type(gguf.RopeScalingType.NONE)
56845689
self.gguf_writer.add_leading_dense_block_count(hparams["first_k_dense_replace"])
56855690
self.gguf_writer.add_vocab_size(hparams["vocab_size"])
56865691
self.gguf_writer.add_expert_feed_forward_length(hparams["moe_intermediate_size"])

0 commit comments

Comments
 (0)