Skip to content
Merged
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/megatron/bridge/training/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from megatron.bridge.training.callbacks import Callback, CallbackManager
from megatron.bridge.training.config import ConfigContainer
from megatron.bridge.training.forward_step_func_types import ForwardStepCallable
from megatron.bridge.training.pretrain import pretrain
Expand All @@ -22,6 +23,7 @@
def finetune(
config: ConfigContainer,
forward_step_func: ForwardStepCallable,
callbacks: list[Callback] | CallbackManager | None = None,
) -> None:
"""Main function to run the finetuning.

Expand All @@ -34,6 +36,7 @@ def finetune(
- 3 args: (data_iterator, model, return_schedule_plan=False)
OR (state: GlobalState, data_iterator, model)
- 4 args: (state: GlobalState, data_iterator, model, return_schedule_plan=False)
callbacks: Optional list of Callback instances, a CallbackManager, or None.

Note:
Use the signature with GlobalState type hint for full access to configuration, timers, and training state.
Expand All @@ -47,4 +50,4 @@ def finetune(
assert config.checkpoint.pretrained_checkpoint is not None or config.checkpoint.load is not None, (
"Finetuning requires a loading from a pretrained checkpoint or resuming from a checkpoint"
)
return pretrain(config, forward_step_func)
return pretrain(config, forward_step_func, callbacks=callbacks)
Loading