From 3db9a07d85f00920b2322970c68c6a611fd33285 Mon Sep 17 00:00:00 2001 From: hxxhl88 <736544296@qq.com> Date: Tue, 19 Apr 2022 12:32:25 +0800 Subject: [PATCH] modify for bucket config --- .../bert/run_pretraining_bucket.py | 21 +++++++++++++++---- .../test/train_full_8p_192bs_bucket.sh | 4 ++-- .../test/train_performance_8p_192bs_bucket.sh | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/bert/run_pretraining_bucket.py b/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/bert/run_pretraining_bucket.py index f9b770b7c..a1f4dc045 100644 --- a/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/bert/run_pretraining_bucket.py +++ b/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/bert/run_pretraining_bucket.py @@ -121,7 +121,7 @@ flags.DEFINE_integer('num_accumulation_steps', 1, flags.DEFINE_float('stop_threshold', 0.912, 'Stop threshold for MLPerf.') flags.DEFINE_float('poly_power', 1.0, 'The power of poly decay.') -flags.DEFINE_multi_integer("seq_len_buckets", [64,128,192,256,384,512], +flags.DEFINE_multi_integer("seq_len_buckets", [64,128,192,256,320,384,448,512], "sequence length bucketizations boundaries") flags.DEFINE_integer('max_tockens_num', 12288, 'max_tockens_num = bs * seq_len') @@ -132,9 +132,22 @@ FLAGS = flags.FLAGS def npu_config(): FLAGS = flags.FLAGS - npu_device.global_options().input_shape = "data_0:-1,-1;data_1:-1,-1;data_2:-1,-1;data_3:-1,-1;data_4:-1,-1;data_5:-1,-1;data_6:-1,-1" - npu_device.global_options().dynamic_node_type = "0" - npu_device.global_options().dynamic_dims = "192,64,192,64,192,64,192,76,192,76,192,76,192,1;96,128,96,128,96,128,96,76,96,76,96,76,96,1;64,192,64,192,64,192,64,76,64,76,64,76,64,1;48,256,48,256,48,256,48,76,48,76,48,76,48,1;32,384,32,384,32,384,32,76,32,76,32,76,32,1;24,512,24,512,24,512,24,76,24,76,24,76,24,1" + npu_device.global_options().experimental.multi_branches_config.input_shape = "data_0:-1,-1;" \ + "data_1:-1,-1;" \ + "data_2:-1,-1;" \ + "data_3:-1,-1;" \ + "data_4:-1,-1;" \ + "data_5:-1,-1;" \ + "data_6:-1,-1" + npu_device.global_options().experimental.multi_branches_config.dynamic_node_type = "0" + npu_device.global_options().experimental.multi_branches_config.dynamic_dims = "192,64,192,64,192,64,192,76,192,76,192,76,192,1;" \ + "96,128,96,128,96,128,96,76,96,76,96,76,96,1;" \ + "64,192,64,192,64,192,64,76,64,76,64,76,64,1;" \ + "48,256,48,256,48,256,48,76,48,76,48,76,48,1;" \ + "38,320,38,320,38,320,38,76,38,76,38,76,38,1;" \ + "32,384,32,384,32,384,32,76,32,76,32,76,32,1;" \ + "28,448,28,448,28,448,28,76,28,76,28,76,28,1;" \ + "24,512,24,512,24,512,24,76,24,76,24,76,24,1" if FLAGS.data_dump_flag: npu_device.global_options().dump_config.enable_dump = True diff --git a/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/test/train_full_8p_192bs_bucket.sh b/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/test/train_full_8p_192bs_bucket.sh index 1840e4192..9f6dac2b5 100644 --- a/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/test/train_full_8p_192bs_bucket.sh +++ b/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/test/train_full_8p_192bs_bucket.sh @@ -180,8 +180,8 @@ echo "------------------ Final result ------------------" FPS=0.0 for((ID=0; ID<8; ID++)) do - single_batch_step_sec=`grep TimeHistory $cur_path/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $8}'` - avg_bs=`grep avg_bs $cur_path/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $8}'` + single_batch_step_sec=`grep TimeHistory $cur_path/output/${ID}/train_${ID}.log|awk 'END {print $8}'` + avg_bs=`grep avg_bs $cur_path/output/${ID}/train_${ID}.log|awk 'END {print $8}'` PER_FPS=`awk 'BEGIN{printf "%.2f\n",'${single_batch_step_sec}'*'${avg_bs}'}'` FPS=`awk 'BEGIN{printf "%.2f\n",'${PER_FPS}'+'${FPS}'}'` done diff --git a/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/test/train_performance_8p_192bs_bucket.sh b/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/test/train_performance_8p_192bs_bucket.sh index 14b7b631d..225afcb73 100644 --- a/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/test/train_performance_8p_192bs_bucket.sh +++ b/TensorFlow2/built-in/nlp/BertLarge_ID0634_for_TensorFlow2.X/test/train_performance_8p_192bs_bucket.sh @@ -176,8 +176,8 @@ echo "------------------ Final result ------------------" FPS=0.0 for((ID=0; ID<8; ID++)) do - single_batch_step_sec=`grep TimeHistory $cur_path/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $8}'` - avg_bs=`grep avg_bs $cur_path/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $8}'` + single_batch_step_sec=`grep TimeHistory $cur_path/output/${ID}/train_${ID}.log|awk 'END {print $8}'` + avg_bs=`grep avg_bs $cur_path/output/${ID}/train_${ID}.log|awk 'END {print $8}'` PER_FPS=`awk 'BEGIN{printf "%.2f\n",'${single_batch_step_sec}'*'${avg_bs}'}'` FPS=`awk 'BEGIN{printf "%.2f\n",'${PER_FPS}'+'${FPS}'}'` done -- Gitee