Skip to content

Commit 407e01b

Browse files
Update community_import.py
lint Signed-off-by: Stan Kirdey <stan@inflection.ai>
1 parent 3e46452 commit 407e01b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

nemo_rl/models/megatron/community_import.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)