Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/megatron/bridge/models/conversion/auto_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def load_hf_weights(self, model: list[MegatronModelT], hf_path: str | Path | Non
pre_trained = self.hf_pretrained
else:
pre_trained = PreTrainedCausalLM.from_pretrained(hf_path)
self._model_bridge.load_weights_hf_to_megatron(model, pre_trained)
self._model_bridge.load_weights_hf_to_megatron(pre_trained, model)

return model

Expand Down
5 changes: 3 additions & 2 deletions tests/unit_tests/models/test_auto_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def test_load_hf_weights(self):
bridge = AutoBridge(mock_hf_model)
bridge.load_hf_weights(mock_megatron_model)

mock_model_bridge.load_weights_hf_to_megatron.assert_called_once_with(mock_megatron_model, mock_hf_model)
mock_model_bridge.load_weights_hf_to_megatron.assert_called_once_with(mock_hf_model, mock_megatron_model)

def test_load_hf_weights_from_path(self):
"""Test loading weights from a different path."""
Expand Down Expand Up @@ -444,7 +444,8 @@ def test_load_hf_weights_from_path(self):

mock_from_pretrained.assert_called_once_with("./custom_model")
mock_model_bridge.load_weights_hf_to_megatron.assert_called_once_with(
mock_megatron_model, mock_loaded_model
mock_loaded_model,
mock_megatron_model,
)

def test_load_hf_weights_no_path_config_only(self):
Expand Down
Loading