24
24
from mergekit .plan import MergePlanner
25
25
from mergekit .tokenizer import TokenizerInfo
26
26
27
- logger = logging .getLogger (__name__ )
27
+ LOG = logging .getLogger (__name__ )
28
28
29
29
30
30
def run_merge (
@@ -61,7 +61,7 @@ def run_merge(
61
61
loader_cache .get (model )
62
62
del pbar
63
63
64
- logger .info ("Planning operations" )
64
+ LOG .info ("Planning operations" )
65
65
targets = MergePlanner (
66
66
merge_config ,
67
67
arch_info ,
@@ -94,7 +94,7 @@ def run_merge(
94
94
cfg_out , arch_info , tokenizer , pad_to_multiple_of = pad_to_multiple_of
95
95
)
96
96
97
- logger .info ("Saving config" )
97
+ LOG .info ("Saving config" )
98
98
cfg_out .save_pretrained (out_path )
99
99
100
100
if options .write_model_card :
@@ -115,7 +115,7 @@ def run_merge(
115
115
fp .write (config_source )
116
116
117
117
if tokenizer is not None :
118
- logger .info ("Saving tokenizer" )
118
+ LOG .info ("Saving tokenizer" )
119
119
_set_chat_template (tokenizer , merge_config )
120
120
tokenizer .save_pretrained (out_path , safe_serialization = True )
121
121
else :
@@ -125,12 +125,12 @@ def run_merge(
125
125
merge_config , out_path , trust_remote_code = options .trust_remote_code
126
126
)
127
127
except Exception as e :
128
- logger .error (
128
+ LOG .error (
129
129
"Failed to copy tokenizer. The merge was still successful, just copy it from somewhere else." ,
130
130
exc_info = e ,
131
131
)
132
132
elif merge_config .chat_template :
133
- logger .warning (
133
+ LOG .warning (
134
134
"Chat template specified but no tokenizer found. Chat template will not be saved."
135
135
)
136
136
@@ -180,13 +180,13 @@ def _set_chat_template(
180
180
if template :
181
181
model_templates .append (template .strip ())
182
182
except Exception as e :
183
- logger .warning (f"Unable to load tokenizer for { model } " , exc_info = e )
183
+ LOG .warning (f"Unable to load tokenizer for { model } " , exc_info = e )
184
184
185
185
if not model_templates :
186
186
return
187
187
188
188
chat_template = Counter (model_templates ).most_common (1 )[0 ][0 ]
189
- logger .info (f"Auto-selected chat template: { chat_template } " )
189
+ LOG .info (f"Auto-selected chat template: { chat_template } " )
190
190
191
191
elif importlib .resources .is_resource (chat_templates , chat_template + ".jinja" ):
192
192
with importlib .resources .open_text (
@@ -210,7 +210,7 @@ def _copy_tagalong_files(
210
210
211
211
for file_name in files :
212
212
if os .path .exists (os .path .join (donor_model .model .path , file_name )):
213
- logger .info (f"Copying { file_name } from { donor_model } " )
213
+ LOG .info (f"Copying { file_name } from { donor_model } " )
214
214
shutil .copy (
215
215
os .path .join (donor_model .model .path , file_name ),
216
216
os .path .join (out_path , file_name ),
@@ -234,7 +234,7 @@ def _copy_tokenizer(
234
234
or os .path .exists (os .path .join (donor_model .model .path , "tokenizer.model" ))
235
235
)
236
236
):
237
- logger .info (f"Copying tokenizer from { donor_model } " )
237
+ LOG .info (f"Copying tokenizer from { donor_model } " )
238
238
239
239
for file_name in [
240
240
"tokenizer_config.json" ,
@@ -253,7 +253,7 @@ def _copy_tokenizer(
253
253
return
254
254
255
255
# fallback: try actually loading the tokenizer and saving it
256
- logger .info (f"Reserializing tokenizer from { donor_model } " )
256
+ LOG .info (f"Reserializing tokenizer from { donor_model } " )
257
257
tokenizer = transformers .AutoTokenizer .from_pretrained (
258
258
donor_model .model .path ,
259
259
revision = donor_model .model .revision ,
@@ -299,7 +299,7 @@ def _model_out_config(
299
299
cfg_key = module_info .architecture .num_layers_config_key ()
300
300
set_config_value (res , cfg_key , module_layers [module_name ])
301
301
except Exception as e :
302
- logger .warning (
302
+ LOG .warning (
303
303
f"Unable to set number of layers for module { module_name } in output config "
304
304
"- you may need to manually correct it." ,
305
305
exc_info = e ,
@@ -322,7 +322,7 @@ def _update_config_vocab(
322
322
config , arch_info .vocab_size_config_key or "vocab_size" , vocab_size
323
323
)
324
324
except Exception as e :
325
- logger .warning (
325
+ LOG .warning (
326
326
"Unable to set vocabulary size in output config - you may need to manually correct it." ,
327
327
exc_info = e ,
328
328
)
0 commit comments