Skip to content

Conversation

@yopknopixx
Copy link
Contributor

@yopknopixx yopknopixx commented Aug 28, 2021

What does this PR do?

Follow up to #8313
Fixes #9849
Closes #9849

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 🙃

@yopknopixx yopknopixx requested a review from ananthsub August 28, 2021 17:43
@ananthsub ananthsub added the deprecation Includes a deprecation label Aug 28, 2021
@ananthsub ananthsub added this to the v1.5 milestone Aug 28, 2021
@mergify mergify bot removed the has conflicts label Aug 29, 2021
Copy link
Contributor

@carmocca carmocca left a comment

Choose a reason for hiding this comment

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

2 questions regarding the difference between terminate_on_nan and detect_anomaly:

@yopknopixx
Copy link
Contributor Author

2 questions regarding the difference between terminate_on_nan and detect_anomaly:

Anomaly detection doesn't raise an error for infs. Also, since detect_anomaly doesn't check the loss I think the loss check should be kept after terminate_on_nan is removed.

@yopknopixx yopknopixx requested a review from carmocca August 29, 2021 15:40
@carmocca
Copy link
Contributor

Anomaly detection doesn't raise an error for infs. Also, since detect_anomaly doesn't check the loss I think the loss check should be kept after terminate_on_nan is removed.

In that case, I don't think we should deprecate terminate_on_nan but instead add the anomaly detection functionality to the existing flag.

@mergify mergify bot removed the ready PRs ready to be merged label Sep 23, 2021
@cowwoc
Copy link
Contributor

cowwoc commented Oct 5, 2021

Per #9799 we only want to turn on detect_anomaly after the scaler value converges to a stable value:

At the beginning of training, in the first few iterations it can happen that the grads become inf or nan. AMP will skip the optimizer.step() in that case and adjust the scale factor iteratively until it converges to a point where that doesn't happen.

@awaelchli awaelchli self-assigned this Oct 7, 2021
@yopknopixx yopknopixx requested a review from rohitgr7 as a code owner October 11, 2021 14:08
@mergify mergify bot removed the has conflicts label Oct 11, 2021
@awaelchli awaelchli changed the title Add trainer argument for detect_anomaly. Deprecate terminate_on_nan Trainer argument in favor of detect_anomaly Oct 11, 2021
@awaelchli
Copy link
Contributor

@yopknopixx After #9848 got merged, I am repurposing your PR here for the deprecation of the old terminate_on_nan argument so we can include your contribution. Thanks for your patience!

@awaelchli awaelchli requested a review from Borda October 11, 2021 14:27
@awaelchli awaelchli added the ready PRs ready to be merged label Oct 11, 2021
@mergify mergify bot removed the ready PRs ready to be merged label Oct 11, 2021
@mergify mergify bot added the ready PRs ready to be merged label Oct 11, 2021
@awaelchli awaelchli enabled auto-merge (squash) October 11, 2021 16:44
@awaelchli awaelchli merged commit 173f4c8 into Lightning-AI:master Oct 11, 2021
rohitgr7 pushed a commit to Tshimanga/pytorch-lightning that referenced this pull request Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecation Includes a deprecation ready PRs ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants