Skip to content

after_save_checkpoint hook for generic Callback #9202

@favrei

Description

@favrei

🚀 Feature

Create the after_save_checkpint hook for Callback in the same fashion as the hook in the logger.

Motivation

In our group, we will create a symlink whenever a better checkpoint is saved, so the automated scripts in the background can find the right checkpoint to start their job. Our in-house framework will handle the symlinks, but I find no entry point after we moved to Pytorch Lightning to implement the same feature.

Pitch

A callback hook e.g., Callback.after_save_checkpoint so users can define their custom tasks whenever a better checkpoint is saved. For example:

class UpdateBestCheckpointCB(Callback):
    def after_save_checkpint(self, trainer, pl_module, **others):
        update_symlink_to_best(trainer)

Alternatives

For now, we can always regard the latest checkpoint as the best, but it will be better if I can be sure about which is the best one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    callbackdesignIncludes a design discussionfeatureIs an improvement or enhancementgood first issueGood for newcomerswon't fixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions