From d00cfb265e28aeeb4c65ae62eabcb776b051b71b Mon Sep 17 00:00:00 2001 From: CaffreyR <1750293985@qq.com> Date: Thu, 17 Nov 2022 22:26:45 +0800 Subject: [PATCH 1/5] Update profiler.py --- .../profiling/flops_profiler/profiler.py | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/deepspeed/profiling/flops_profiler/profiler.py b/deepspeed/profiling/flops_profiler/profiler.py index a93c6fc23486..414032467c39 100644 --- a/deepspeed/profiling/flops_profiler/profiler.py +++ b/deepspeed/profiling/flops_profiler/profiler.py @@ -1149,6 +1149,7 @@ def get_model_profile( as_string=True, output_file=None, ignore_modules=None, + mode='forward' ): """Returns the total floating-point operations, MACs, and parameters of a model. @@ -1196,18 +1197,29 @@ def get_model_profile( args = [input] assert (len(args) > 0) or (len(kwargs) > 0), "args and/or kwargs must be specified if input_shape is None" - for _ in range(warm_up): if kwargs: - _ = model(*args, **kwargs) + if mode == 'forward': + _ = model(*args, **kwargs) + if mode == 'generate': + _ = model.generate(*args, **kwargs) else: - _ = model(*args) + if mode == 'forward': + _ = model(*args) + if mode == 'generate': + _ = model.generate(*args) prof.start_profile(ignore_list=ignore_modules) if kwargs: - _ = model(*args, **kwargs) + if mode == 'forward': + _ = model(*args, **kwargs) + if mode == 'generate': + _ = model.generate(*args, **kwargs) else: - _ = model(*args) + if mode == 'forward': + _ = model(*args) + if mode == 'generate': + _ = model.generate(*args) flops = prof.get_total_flops() macs = prof.get_total_macs() From 6dc17f276a7e59e0f4c4d457cdd0ed2e201282b1 Mon Sep 17 00:00:00 2001 From: CaffreyR <1750293985@qq.com> Date: Fri, 18 Nov 2022 13:32:47 +0800 Subject: [PATCH 2/5] pre-commit run --all-files --- .DS_Store | Bin 0 -> 8196 bytes deepspeed/.DS_Store | Bin 0 -> 6148 bytes deepspeed/profiling/.DS_Store | Bin 0 -> 6148 bytes .../profiling/flops_profiler/profiler.py | 28 ++++++++---------- 4 files changed, 13 insertions(+), 15 deletions(-) create mode 100644 .DS_Store create mode 100644 deepspeed/.DS_Store create mode 100644 deepspeed/profiling/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..eefdff3228ae34ac1c3d0484c511b307bc0601eb GIT binary patch literal 8196 zcmeHMU2GIp6u#fI&>1?=0a{tG1Dh^Hz!qu?w)`dAKjpv3wsczx%kIud2c|R2&g>Q} zHI0ccAR3=E{zaesA@ZQ2#1~BzMIRMSFvbUr#-9gG^hM>tGjnI5wB>~uW8>Ur?%8wB zJ@?*o?sx9&*)qn^UeNAgEW#KQ>G7yiN!>Kf(|ga9CIpglq9A+59F}7`{b`wzDWgL{ z7=bVXVFbbmgb@fM@Lz}ky|cY0-r~K_wP7DdAdJBOG6LTH5T(bX@qmtV>R%ny`6U2R zuLSTLeWp6Vw}}Qc9?)@4eN&o~R}TnG5tJC<=A@5$!->WNI?gFKXW-@x!O93K6!@!? zUDO}W5a%@P!w7^Cm>K~ueI%y&ReNq?{qE#4rkx?}g-p&g9JjIYO9*ATRZ(FdouLR^?>#wrTFM9mAWZKk4enT~9Yf zl^k&FyxZYVmQs|0qwm#eE~BV-(u_{hpd~%S>Pc=wIyZ08vgIoqnp!r;ySD9m;Bu8R zf5AezMjoJ;TCVY+q38S4PFA-x!#dnMVrcGAU(s-kjH&ln>0w=(k9z5HRb=s!J8M;y z54d4a8k#I*jAI4EJ)y)z(O)B~*2#k!ZElyXd8=rma-Qa))mNx>>V8ktk=Lo$0)tiR z-ExmZK8Q-14_qTR$~{L343gq-Nwd6O?KRUG-INrKuhS}TRQrlN{*tnT3%AHMYBFmN z50i_I#AR)2hkDRkc4yjgyK}nbZRrx%-AB3sXDFT5yGIC&!H%|*)IU;^dq!QF;o82E zqOrS9Rr|f^+BD7gVM%0hm6}j{MddS*j>xcz1|9Ba9 zWAVm7ATpITu}-#=9b$Pl%FeK-*;)1$yU0FbU$Af3kL)-02Y}hAz#LSf8cVPo^;nM< zv|K=kWqw#7lS$Z{SUw$J=-hm+%Qb z#pk$+Z}A zq&rY@Fp!@hI?Z)LNf%rv!nx^_uJ-<|+qTO)XH3#vndhfjbA4x zi2oGcudu7^2lgwwMtGlxg^1uTG!n|&u@$?0oF~wWgGk{JGSDy#3pS1s;!k1>4`UpU z5Z)gn#6N*2@eH2DbAW6 z$8#}}w@lkQOxjW=+-x`_xH7)Wh*$r2-TL?c8R1K~$uI(81a2<^DDO;kwv+9x?lP~| zj?#0892s8ZdN%QZj&n*9YXABV0TaKE-~N~G@ckdY J|7Z03|8F6Desll; literal 0 HcmV?d00001 diff --git a/deepspeed/.DS_Store b/deepspeed/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1ebe02d06c9c73368a715db968fd4af03775a394 GIT binary patch literal 6148 zcmeHKPfG$p6n~?ZyGY=nz~ewyA=AjB%VPEg+NeW??V{Pzwj-5Am6g;3~kL=Zy+3G~Cs zN;Dh(A_KH{E({v!h+=a1fqBZkYjQ zV3~ou8J4O3Uwr@mUryo?Gr$b|D+WZN?YCRFBwJfo7Du&KqCTLKP+Vqkk%ApviZPZ- daRpTi+9h=mJ&Tz^w4m@sK-0htGw`bnd;tZPO@06X literal 0 HcmV?d00001 diff --git a/deepspeed/profiling/.DS_Store b/deepspeed/profiling/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..97a9091cc61b194cc3e586c8a35bcfc437cdee28 GIT binary patch literal 6148 zcmeHK%}N6?5T3NvZYfF+3OxqA7ObuKgO{b&7jQ)nDs`7uU0gS1x3z~-*t5QnPvY}9 zlVrtG^&*Ir8JK*N$xK4NESU`eh|ajb15g712bHi;!R8C0anc1TSP!AlbEMFNAta#S zb|IP_|B(SYyLCLR2+wQ?pU*Eu-vE+ek`9AN1sL}l45Kg|HJfjuP%N#imYuRwb*{a8 zHStFNXq3GJ_u} jXy{Umu~drds9Ml3$v|{1W(LuN!ao9<25y*vKV{$@n;ubJ literal 0 HcmV?d00001 diff --git a/deepspeed/profiling/flops_profiler/profiler.py b/deepspeed/profiling/flops_profiler/profiler.py index 414032467c39..8d095ad0450d 100644 --- a/deepspeed/profiling/flops_profiler/profiler.py +++ b/deepspeed/profiling/flops_profiler/profiler.py @@ -1136,21 +1136,19 @@ def get_module_duration(module): return duration -def get_model_profile( - model, - input_shape=None, - args=[], - kwargs={}, - print_profile=True, - detailed=True, - module_depth=-1, - top_modules=1, - warm_up=1, - as_string=True, - output_file=None, - ignore_modules=None, - mode='forward' -): +def get_model_profile(model, + input_shape=None, + args=[], + kwargs={}, + print_profile=True, + detailed=True, + module_depth=-1, + top_modules=1, + warm_up=1, + as_string=True, + output_file=None, + ignore_modules=None, + mode='forward'): """Returns the total floating-point operations, MACs, and parameters of a model. Example: From 3fc7b217e8a037684fb36e0bce03faa21a5463d3 Mon Sep 17 00:00:00 2001 From: CaffreyR <84232793+CaffreyR@users.noreply.github.com> Date: Fri, 18 Nov 2022 19:56:34 +0800 Subject: [PATCH 3/5] Delete .DS_Store --- .DS_Store | Bin 8196 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index eefdff3228ae34ac1c3d0484c511b307bc0601eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMU2GIp6u#fI&>1?=0a{tG1Dh^Hz!qu?w)`dAKjpv3wsczx%kIud2c|R2&g>Q} zHI0ccAR3=E{zaesA@ZQ2#1~BzMIRMSFvbUr#-9gG^hM>tGjnI5wB>~uW8>Ur?%8wB zJ@?*o?sx9&*)qn^UeNAgEW#KQ>G7yiN!>Kf(|ga9CIpglq9A+59F}7`{b`wzDWgL{ z7=bVXVFbbmgb@fM@Lz}ky|cY0-r~K_wP7DdAdJBOG6LTH5T(bX@qmtV>R%ny`6U2R zuLSTLeWp6Vw}}Qc9?)@4eN&o~R}TnG5tJC<=A@5$!->WNI?gFKXW-@x!O93K6!@!? zUDO}W5a%@P!w7^Cm>K~ueI%y&ReNq?{qE#4rkx?}g-p&g9JjIYO9*ATRZ(FdouLR^?>#wrTFM9mAWZKk4enT~9Yf zl^k&FyxZYVmQs|0qwm#eE~BV-(u_{hpd~%S>Pc=wIyZ08vgIoqnp!r;ySD9m;Bu8R zf5AezMjoJ;TCVY+q38S4PFA-x!#dnMVrcGAU(s-kjH&ln>0w=(k9z5HRb=s!J8M;y z54d4a8k#I*jAI4EJ)y)z(O)B~*2#k!ZElyXd8=rma-Qa))mNx>>V8ktk=Lo$0)tiR z-ExmZK8Q-14_qTR$~{L343gq-Nwd6O?KRUG-INrKuhS}TRQrlN{*tnT3%AHMYBFmN z50i_I#AR)2hkDRkc4yjgyK}nbZRrx%-AB3sXDFT5yGIC&!H%|*)IU;^dq!QF;o82E zqOrS9Rr|f^+BD7gVM%0hm6}j{MddS*j>xcz1|9Ba9 zWAVm7ATpITu}-#=9b$Pl%FeK-*;)1$yU0FbU$Af3kL)-02Y}hAz#LSf8cVPo^;nM< zv|K=kWqw#7lS$Z{SUw$J=-hm+%Qb z#pk$+Z}A zq&rY@Fp!@hI?Z)LNf%rv!nx^_uJ-<|+qTO)XH3#vndhfjbA4x zi2oGcudu7^2lgwwMtGlxg^1uTG!n|&u@$?0oF~wWgGk{JGSDy#3pS1s;!k1>4`UpU z5Z)gn#6N*2@eH2DbAW6 z$8#}}w@lkQOxjW=+-x`_xH7)Wh*$r2-TL?c8R1K~$uI(81a2<^DDO;kwv+9x?lP~| zj?#0892s8ZdN%QZj&n*9YXABV0TaKE-~N~G@ckdY J|7Z03|8F6Desll; From 72518e75ceaa6ed2f357a2c60acae207b3b65208 Mon Sep 17 00:00:00 2001 From: CaffreyR <84232793+CaffreyR@users.noreply.github.com> Date: Fri, 18 Nov 2022 19:56:51 +0800 Subject: [PATCH 4/5] Delete .DS_Store --- deepspeed/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 deepspeed/.DS_Store diff --git a/deepspeed/.DS_Store b/deepspeed/.DS_Store deleted file mode 100644 index 1ebe02d06c9c73368a715db968fd4af03775a394..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKPfG$p6n~?ZyGY=nz~ewyA=AjB%VPEg+NeW??V{Pzwj-5Am6g;3~kL=Zy+3G~Cs zN;Dh(A_KH{E({v!h+=a1fqBZkYjQ zV3~ou8J4O3Uwr@mUryo?Gr$b|D+WZN?YCRFBwJfo7Du&KqCTLKP+Vqkk%ApviZPZ- daRpTi+9h=mJ&Tz^w4m@sK-0htGw`bnd;tZPO@06X From 56972244b9c920c5c5f94373722c9701f4485724 Mon Sep 17 00:00:00 2001 From: CaffreyR <84232793+CaffreyR@users.noreply.github.com> Date: Fri, 18 Nov 2022 19:57:06 +0800 Subject: [PATCH 5/5] Delete .DS_Store --- deepspeed/profiling/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 deepspeed/profiling/.DS_Store diff --git a/deepspeed/profiling/.DS_Store b/deepspeed/profiling/.DS_Store deleted file mode 100644 index 97a9091cc61b194cc3e586c8a35bcfc437cdee28..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}N6?5T3NvZYfF+3OxqA7ObuKgO{b&7jQ)nDs`7uU0gS1x3z~-*t5QnPvY}9 zlVrtG^&*Ir8JK*N$xK4NESU`eh|ajb15g712bHi;!R8C0anc1TSP!AlbEMFNAta#S zb|IP_|B(SYyLCLR2+wQ?pU*Eu-vE+ek`9AN1sL}l45Kg|HJfjuP%N#imYuRwb*{a8 zHStFNXq3GJ_u} jXy{Umu~drds9Ml3$v|{1W(LuN!ao9<25y*vKV{$@n;ubJ