File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -105,21 +105,25 @@ def export_model_from_megatron(
105105 )
106106
107107 try :
108- from megatron .bridge .training .model_load_save import temporary_distributed_context
108+ from megatron .bridge .training .model_load_save import (
109+ temporary_distributed_context ,
110+ )
109111 except ImportError :
110112 raise ImportError ("megatron.bridge.training is not available." )
111113
112114 bridge = AutoBridge .from_hf_pretrained (hf_model_name , trust_remote_code = True )
113-
115+
114116 # Export performs on CPU with proper distributed context
115117 with temporary_distributed_context (backend = "gloo" ):
116118 # Load the Megatron model
117- megatron_model = bridge .load_megatron_model (input_path , skip_temp_dist_context = True )
118-
119+ megatron_model = bridge .load_megatron_model (
120+ input_path , skip_temp_dist_context = True
121+ )
122+
119123 # Save in HuggingFace format
120124 bridge .save_hf_pretrained (megatron_model , output_path )
121125
122126 # resetting mcore state
123- import megatron .core .rerun_state_machine
127+ import megatron .core .rerun_state_machinec
124128
125129 megatron .core .rerun_state_machine .destroy_rerun_state_machine ()
You can’t perform that action at this time.
0 commit comments