@@ -278,6 +278,41 @@ def expand_ajet_hierarchical_config(config, write_to=None):
278278 return config_final
279279
280280
281+ def _validate_input_yaml_no_overlap_with_auto_convertion_config (input_yaml_config , config_final ):
282+ """Validate that input yaml doesn't contain keys that will be auto-converted with different values."""
283+ import json
284+ import re
285+
286+ jsonc_path = os .path .join (os .path .dirname (__file__ ), ".." , "default_config" , "verl" , "config_auto_convertion_verl.jsonc" )
287+ with open (jsonc_path , "r" , encoding = "utf-8" ) as f :
288+ content = f .read ()
289+ content = re .sub (r'//.*' , '' , content )
290+ convertion_json = json .loads (content )
291+
292+ errors = []
293+ for from_key , to_keys in convertion_json .items ():
294+ to_keys = to_keys if isinstance (to_keys , list ) else [to_keys ]
295+ for to_key in to_keys :
296+ try :
297+ input_value = _dive_to_fetch_value (input_yaml_config , to_key )
298+ except ValueError :
299+ continue
300+ final_value = _dive_to_fetch_value (config_final , to_key )
301+ if str (input_value ) != str (final_value ):
302+ errors .append (
303+ f" - Key '{ to_key } ': input_yaml value = { input_value } , "
304+ f"but ajet config sets it to = { final_value } "
305+ )
306+
307+ if errors :
308+ error_msg = (
309+ "We found a configuration conflict between AgentJet and Verl! Input yaml contains keys that conflict with ajet default config values:\n "
310+ + "\n " .join (errors )
311+ + "\n Please use ajet.xxx to assign training parameters instead."
312+ )
313+ raise ValueError (error_msg )
314+
315+
281316def prepare_experiment_config (yaml_path , exp_base_dir , backbone , override_param_callback = None , storage = True ):
282317 """
283318 Prepare experiment configuration by reading YAML, setting up backup directories,
@@ -299,7 +334,7 @@ def prepare_experiment_config(yaml_path, exp_base_dir, backbone, override_param_
299334
300335 ## 0. read yaml & get experiment_name
301336 with open (yaml_path , "r" , encoding = "utf-8" ) as file :
302- config = yaml .safe_load (file )
337+ config = input_yaml_config = yaml .safe_load (file )
303338 try :
304339 exp_name = config .get ("ajet" ).get ("experiment_name" )
305340 except Exception :
@@ -367,6 +402,8 @@ def prepare_experiment_config(yaml_path, exp_base_dir, backbone, override_param_
367402 )
368403 config_final = expand_ajet_hierarchical_config (config , write_to = yaml_backup_dst )
369404
405+ _validate_input_yaml_no_overlap_with_auto_convertion_config (input_yaml_config , config_final )
406+
370407 if not storage :
371408 shutil .rmtree (os .path .join (exp_base_dir , exp_name ))
372409
0 commit comments