Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing Hooks #6

Open
16 of 37 tasks
CarloLucibello opened this issue Feb 14, 2023 · 0 comments
Open
16 of 37 tasks

missing Hooks #6

CarloLucibello opened this issue Feb 14, 2023 · 0 comments

Comments

@CarloLucibello
Copy link
Owner

CarloLucibello commented Feb 14, 2023

These are the hooks defined in lightning https://pytorch-lightning.readthedocs.io/en/stable/extensions/callbacks.html#callback-api

  • setup(trainer, pl_module, stage). Called when fit, validate, test, predict, or tune begins.

  • teardown(trainer, pl_module, stage). Called when fit, validate, test, predict, or tune ends.

  • on_fit_start(trainer, pl_module). Called when fit begins.

  • on_fit_end(trainer, pl_module). Called when fit ends.

  • on_sanity_check_start(trainer, pl_module). Called when the validation sanity check starts.- [ ]

  • on_sanity_check_end(trainer, pl_module). Called when the validation sanity check ends.

  • on_train_batch_start(trainer, pl_module, batch, batch_idx). Called when the train batch begins.

  • on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx). Called when the train batch ends.

  • on_train_epoch_start(trainer, pl_module). Called when the train epoch begins.

  • on_train_epoch_end(trainer, pl_module). Called when the train epoch ends.
    To access all batch outputs at the end of the epoch, either:
    Implement training_epoch_end in the LightningModule and access outputs via the module OR
    Cache data across train batch hooks inside the callback implementation to post-process in this hook.

  • on_validation_epoch_start(trainer, pl_module). Called when the val epoch begins.

  • on_validation_epoch_end(trainer, pl_module). Called when the val epoch ends.

  • on_test_epoch_start(trainer, pl_module). Called when the test epoch begins.

  • on_test_epoch_end(trainer, pl_module). Called when the test epoch ends.

  • on_predict_epoch_start(trainer, pl_module). Called when the predict epoch begins.

  • on_predict_epoch_end(trainer, pl_module, outputs).
    Called when the predict epoch ends.

  • on_validation_batch_start(trainer, pl_module, batch, batch_idx, dataloader_idx)
    Called when the validation batch begins.

  • on_validation_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx)
    Called when the validation batch ends.

  • on_test_batch_start(trainer, pl_module, batch, batch_idx, dataloader_idx)
    Called when the test batch begins.

  • on_test_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx)
    Called when the test batch ends.

  • on_predict_batch_start(trainer, pl_module, batch, batch_idx, dataloader_idx)
    Called when the predict batch begins.

  • on_predict_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx)
    Called when the predict batch ends.

  • on_train_start(trainer, pl_module)
    Called when the train begins.

  • on_train_end(trainer, pl_module)
    Called when the train ends.

  • on_validation_start(trainer, pl_module)
    Called when the validation loop begins.

  • on_validation_end(trainer, pl_module)
    Called when the validation loop ends.

  • on_test_start(trainer, pl_module)
    Called when the test begins.

  • on_test_end(trainer, pl_module)
    Called when the test ends.

  • on_predict_start(trainer, pl_module)
    Called when the predict begins.

  • on_predict_end(trainer, pl_module)
    Called when predict ends.

  • on_exception(trainer, pl_module, exception)
    Called when any trainer execution is interrupted by an exception.

  • on_save_checkpoint(trainer, pl_module, checkpoint)
    Called when saving a checkpoint to give you a chance to store anything else you might want to save.

  • on_load_checkpoint(trainer, pl_module, checkpoint)
    Called when loading a model checkpoint, use to reload state.

  • on_before_backward(trainer, pl_module, loss)
    Called before loss.backward(). [on_before_backprop here] [NOT NEEDED]

  • on_after_backward(trainer, pl_module)
    Called after loss.backward() and before optimizers are stepped. [NOT NEEDED]

  • on_before_optimizer_step(trainer, pl_module, optimizer, opt_idx)
    Called before optimizer.step(). [implemented as on_before_update]

  • on_before_zero_grad(trainer, pl_module, optimizer)
    Called before optimizer.zero_grad(). [NO: with Zygote we don't zero the gradient]

@CarloLucibello CarloLucibello changed the title add callbacks support missing Hooks Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant