@@ -150,6 +150,7 @@ class ModelType(Enum):
150150 Gemma = 0x1300
151151 Gemma2 = 0x1301
152152 Gemma3 = 0x1302
153+ RNJ_1 = 0x1303
153154
154155 CohereCommand = 0x1400
155156 CohereAya23 = 0x1401
@@ -5613,7 +5614,6 @@ def get_weight_names(config):
56135614
56145615class Gemma3Converter (BaseConverter ):
56155616 MODEL_TYPE = ModelType .Gemma3
5616- FILE_VERSION = 1
56175617
56185618 @classmethod
56195619 def pp (cls , config , name : str , tensor ):
@@ -5786,6 +5786,40 @@ def get_weight_names(config):
57865786
57875787 return weight_names
57885788
5789+ class RNJ_1Converter (BaseConverter ):
5790+ MODEL_TYPE = ModelType .RNJ_1
5791+
5792+ @classmethod
5793+ def state_dict_pp (cls , config , state_dict ):
5794+ return Gemma3Converter .state_dict_pp (config , state_dict )
5795+
5796+ @staticmethod
5797+ def dump_config (f , config , ggml_type ):
5798+ final_logit_softcapping = config .final_logit_softcapping
5799+ attn_logit_softcapping = config .attn_logit_softcapping
5800+ rope_scaling = config .rope_scaling
5801+ config .rope_scaling = None
5802+ config .final_logit_softcapping = None
5803+ config .attn_logit_softcapping = None
5804+
5805+ Gemma3Converter .dump_config (f , config , ggml_type )
5806+
5807+ config_values = [
5808+ rope_scaling ['attn_factor' ],
5809+ rope_scaling ['beta_fast' ],
5810+ rope_scaling ['beta_slow' ],
5811+ rope_scaling ['extrapolation_factor' ],
5812+ rope_scaling ['factor' ],
5813+ rope_scaling ['original_max_position_embeddings' ],
5814+ final_logit_softcapping if final_logit_softcapping is not None else - 1.0 ,
5815+ attn_logit_softcapping if attn_logit_softcapping is not None else - 1.0 ,
5816+ ]
5817+ f .write (struct .pack ("<" + "fffffiff" , * config_values ))
5818+
5819+ @staticmethod
5820+ def get_weight_names (config ):
5821+ return Gemma3Converter .get_weight_names (config )
5822+
57895823class Grok1Converter (BaseConverter ):
57905824 MODEL_TYPE = ModelType .Grok1
57915825 tensor_map = []
@@ -8844,7 +8878,10 @@ def main():
88448878 elif arch == 'Gemma2ForCausalLM' :
88458879 Gemma2Converter .convert (config , model_files , vocab , ggml_type , args .save_path )
88468880 elif arch == 'Gemma3ForCausalLM' :
8847- Gemma3Converter .convert (config , model_files , vocab , ggml_type , args .save_path )
8881+ if config .rope_scaling and (config .rope_scaling ['rope_type' ] == 'yarn' ):
8882+ RNJ_1Converter .convert (config , model_files , vocab , ggml_type , args .save_path )
8883+ else :
8884+ Gemma3Converter .convert (config , model_files , vocab , ggml_type , args .save_path )
88488885 elif arch == 'Gemma3ForConditionalGeneration' :
88498886 if config .vision_config is not None :
88508887 Gemma3Converter .MODEL_TYPE = ModelType .Gemma3Vis
0 commit comments