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

Replace occurrences of on_before_accelerator_backend_setup_called with setup hook #11568

Merged
merged 21 commits into from
Feb 3, 2022
Merged

Replace occurrences of on_before_accelerator_backend_setup_called with setup hook #11568

merged 21 commits into from
Feb 3, 2022

Conversation

krishnakalyan3
Copy link
Contributor

@krishnakalyan3 krishnakalyan3 commented Jan 21, 2022

What does this PR do?

Part-1/2 #11559

Does your PR introduce any breaking changes? If yes, please list them.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@ananthsub ananthsub changed the title Depricate on_before_accelerator_backend_setup Deprecate on_before_accelerator_backend_setup Jan 21, 2022
@krishnakalyan3 krishnakalyan3 changed the title Deprecate on_before_accelerator_backend_setup Deprecate on_before_accelerator_backend_setup hook Jan 21, 2022
@krishnakalyan3 krishnakalyan3 changed the title Deprecate on_before_accelerator_backend_setup hook Deprecate on_before_accelerator_backend_setup hook Jan 21, 2022
Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @krishnakalyan3

I'd make this into 2 PRs:

  1. Transition all Lightning callbacks to use setup instead of on_before_accelerator_backend_setup. These callsites are shared in the initial issue
  2. Mark the callback hook as deprecated (adding to the config validator, change the docstring of the hook to reflect it's deprecated, etc)

docs/source/extensions/callbacks.rst Outdated Show resolved Hide resolved
pytorch_lightning/trainer/callback_hook.py Outdated Show resolved Hide resolved
@ananthsub ananthsub changed the title Deprecate on_before_accelerator_backend_setup hook Deprecate on_before_accelerator_backend_setup hook [1/2] Jan 22, 2022
Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/callbacks/test_finetuning_callback.py Outdated Show resolved Hide resolved
@krishnakalyan3
Copy link
Contributor Author

Since this is a minor change do I need to update the change logs?.

@daniellepintz
Copy link
Contributor

A few comments:

  1. It looks like you are missing references in two tests: test_swa_deepcopy and test_deepspeed_assert_config_zero_offload_disabled
  2. no need to update the changelog for this, but in the next PR yes
  3. please update the title and description of this PR. this PR no longer fixes the issue directly, that will be the next PR

@krishnakalyan3
Copy link
Contributor Author

krishnakalyan3 commented Jan 23, 2022

@daniellepintz Let me know if the new changes look good.

@krishnakalyan3
Copy link
Contributor Author

@daniellepintz let me know if this looks better.

Copy link
Contributor

@daniellepintz daniellepintz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please fix the lint errors. You can check lint locally by running pre-commit (https://pre-commit.com/)

tests/callbacks/test_finetuning_callback.py Outdated Show resolved Hide resolved
@krishnakalyan3
Copy link
Contributor Author

@awaelchli let me know if the new changes look okay?.

@krishnakalyan3
Copy link
Contributor Author

krishnakalyan3 commented Jan 23, 2022

@daniellepintz

Looks like the pre-commit messages are picking up this from this signature def setup(self, trainer: "pl.Trainer", pl_module: "pl.LightningModule") -> None:

Any suggestions on how to resolve this?

tests/strategies/test_deepspeed_strategy.py:409: [F821] undefined name 'pl'
tests/strategies/test_deepspeed_strategy.py:409: [F821] undefined name 'pl'
tests/callbacks/test_finetuning_callback.py:271: [F821] undefined name 'pl'
tests/callbacks/test_finetuning_callback.py:271: [F821] undefined name 'pl'
tests/callbacks/test_stochastic_weight_avg.py:236: [F821] undefined name 'pl'
tests/callbacks/test_stochastic_weight_avg.py:236: [F821] undefined name 'pl'

@awaelchli
Copy link
Contributor

add import pytorch_lightning as pl
:)

tests/callbacks/test_stochastic_weight_avg.py Outdated Show resolved Hide resolved
tests/callbacks/test_stochastic_weight_avg.py Outdated Show resolved Hide resolved
tests/strategies/test_deepspeed_strategy.py Outdated Show resolved Hide resolved
tests/strategies/test_deepspeed_strategy.py Outdated Show resolved Hide resolved
tests/callbacks/test_finetuning_callback.py Outdated Show resolved Hide resolved
tests/callbacks/test_finetuning_callback.py Outdated Show resolved Hide resolved
tests/callbacks/test_stochastic_weight_avg.py Outdated Show resolved Hide resolved
@krishnakalyan3
Copy link
Contributor Author

krishnakalyan3 commented Jan 24, 2022

@rohitgr7 since stage is not referenced anywhere don't we have to initialize it somewhere as a global or a local variable?. In general, do we prefer typecasting the code for example trainer: "pl.Trainer" or as you suggested?.

@rohitgr7
Copy link
Contributor

rohitgr7 commented Jan 24, 2022

@rohitgr7 since stage is not referenced anywhere don't we have to initialize it somewhere as a global or a local variable?. In general, do we prefer typecasting the code for example trainer: "pl.Trainer" or as you suggested?.

@krishnakalyan3 stage will be set up trainer and passed to the callback's setup internally.
for tests, typing isn't required.

@mergify mergify bot added the ready PRs ready to be merged label Jan 25, 2022
@carmocca carmocca enabled auto-merge (squash) February 3, 2022 03:55
@carmocca carmocca merged commit 6291af5 into Lightning-AI:master Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants