@@ -329,16 +329,17 @@ def main(config, test_args): # pylint: disable=W0621
329329 }
330330 all_data_to_save .append (data_to_save )
331331
332- max_logging .log ("\n [test criteria]" )
333- max_logging .log (
334- f"Checking Numerical Differences between train logits and golden logits against "
335- f"atol={ test_args .rtol } rtol={ test_args .atol } ."
336- )
337- rtol_val = float (test_args .rtol )
338- atol_val = float (test_args .atol )
339- assert jax .numpy .allclose (
340- train_logits_slice , golden_logits_slice , rtol = rtol_val , atol = atol_val , equal_nan = False
341- ), f"Logits do not match closely enough. Required rtol={ test_args .rtol } , atol={ test_args .atol } ."
332+ if test_args .atol is not None :
333+ max_logging .log ("\n [test criteria]" )
334+ max_logging .log (
335+ f"Checking Numerical Differences between train logits and golden logits against "
336+ f"atol={ test_args .rtol } rtol={ test_args .atol } ."
337+ )
338+ rtol_val = float (test_args .rtol )
339+ atol_val = float (test_args .atol )
340+ assert jax .numpy .allclose (
341+ train_logits_slice , golden_logits_slice , rtol = rtol_val , atol = atol_val , equal_nan = False
342+ ), f"Logits do not match closely enough. Required rtol={ test_args .rtol } , atol={ test_args .atol } ."
342343
343344 if test_args .max_kl_div is not None :
344345 max_logging .log (
@@ -451,8 +452,8 @@ def main(config, test_args): # pylint: disable=W0621
451452 os .environ ["TF_CPP_MIN_LOG_LEVEL" ] = "0"
452453
453454 parser = argparse .ArgumentParser ()
454- parser .add_argument ("--atol" , type = float , required = False , default = 0.1 )
455- parser .add_argument ("--rtol" , type = float , required = False , default = 0.1 )
455+ parser .add_argument ("--atol" , type = float , required = False , default = None )
456+ parser .add_argument ("--rtol" , type = float , required = False , default = 1e-05 ) # default from jnp.allclose
456457 parser .add_argument ("--token_size" , type = int , required = False )
457458 parser .add_argument ("--max_kl_div" , type = float , required = False , default = None )
458459 parser .add_argument ("--golden_logits_path" , type = str , required = False , default = "" )
@@ -479,6 +480,9 @@ def main(config, test_args): # pylint: disable=W0621
479480 model_args = [s for s in model_args if not s .startswith (arg )]
480481
481482 cfg = pyconfig .initialize (model_args )
483+ assert (
484+ test_args .atol is not None or test_args .max_kl_div is not None
485+ ), "At least one of --atol or --max_kl_div must be specified to define the test criteria."
482486 if cfg .use_multimodal :
483487 assert not test_args .run_hf_model , (
484488 "Multimodal does not support running hf model on-the-fly, please generate hf golden logits "
0 commit comments