File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
nemo_automodel/_transformers Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -907,7 +907,11 @@ def _retry(**override):
907907 device = torch .cuda .current_device ()
908908
909909 # Neither of these parallelization methods support meta device initialization
910- is_meta_device = not isinstance (model_wrapper , (MegatronFSDPManager , DDPManager )) and not force_hf
910+ is_meta_device = (
911+ not isinstance (model_wrapper , (MegatronFSDPManager , DDPManager ))
912+ and not force_hf
913+ and get_world_size_safe () > 1
914+ )
911915 init_ctx = ContextManagers ([no_init_weights (), init_empty_weights ()]) if is_meta_device else nullcontext ()
912916
913917 try :
@@ -1115,7 +1119,11 @@ def _retry(**override):
11151119 device = torch .cuda .current_device ()
11161120
11171121 # Neither of these parallelization methods support meta device initialization
1118- is_meta_device = not isinstance (model_wrapper , (MegatronFSDPManager , DDPManager )) and not force_hf
1122+ is_meta_device = (
1123+ not isinstance (model_wrapper , (MegatronFSDPManager , DDPManager ))
1124+ and not force_hf
1125+ and get_world_size_safe () > 1
1126+ )
11191127 init_ctx = ContextManagers ([no_init_weights (), init_empty_weights ()]) if is_meta_device else nullcontext ()
11201128
11211129 try :
You can’t perform that action at this time.
0 commit comments