clean up engine.cpp thread state (#63115)
authoralbanD <desmaison.alban@gmail.com>
Wed, 25 Aug 2021 18:07:24 +0000 (11:07 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 25 Aug 2021 18:08:43 +0000 (11:08 -0700)
commitab954cb0d176a5632f123ac19d9469e6f863d39a
tree34c2d021f82ed6540dca244099cb9841d570ec74
parentc06dfd7c26102ac2436ca25609c92fa794e972ca
clean up engine.cpp thread state (#63115)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63115

This actually changes:
- callbacks now run with proper grad mode even in worker threads
- graphtask's Future callbacks now run with proper TLS when erroring
  out from a worker thread

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D30388100

Pulled By: albanD

fbshipit-source-id: 7ae9c461c2f0040548dd9e1e314f25e8da0c2e67
torch/csrc/autograd/engine.cpp
torch/csrc/distributed/autograd/engine/dist_engine.cpp