17
17
from aiu_fms_testing_utils .testing .validation import get_default_validation_prefix
18
18
19
19
from aiu_fms_testing_utils .utils import prepare_inputs
20
- from aiu_fms_testing_utils .utils .metrics_utils import tensor_abs_diff , tensor_cos_sim
20
+ from aiu_fms_testing_utils .utils .metrics_utils import tensor_abs_diff , tensor_cos_sim , save_layers_output
21
21
22
22
23
23
logger = logging .getLogger (__name__ )
@@ -390,8 +390,7 @@ def generate_layers_metrics(model_path, batch_size, seq_length, max_new_tokens):
390
390
seq_length = seq_length , max_new_tokens = max_new_tokens ,
391
391
tokenizer = tokenizer )
392
392
393
- with open (os .path .join (output_path ,f"{ model_path } -layer-output-stack-cpu.json" ), 'w' ) as f :
394
- json .dump (layer_stack_cpu , f )
393
+ save_layers_output (os .path .join (output_path ,f"{ model_path } -layer-output-stack-cpu.json" ),layer_stack_cpu )
395
394
396
395
global generate_iters
397
396
generate_iters = 0
@@ -403,8 +402,7 @@ def generate_layers_metrics(model_path, batch_size, seq_length, max_new_tokens):
403
402
seq_length = seq_length , max_new_tokens = max_new_tokens ,
404
403
tokenizer = tokenizer )
405
404
406
- with open (os .path .join (output_path ,f"{ model_path } -layer-output-stack-gpu.json" ), 'w' ) as f :
407
- json .dump (layer_stack_cuda , f )
405
+ save_layers_output (os .path .join (output_path ,f"{ model_path } -layer-output-stack-gpu.json" ), layer_stack_cuda )
408
406
409
407
assert len (layer_stack_cuda .keys ()) == len (layer_stack_cpu .keys ())
410
408
0 commit comments