mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-24 23:54:56 +08:00
Preserve python backtrace in autograd engine errors. (#43684)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/43684 This PR attempts to address #42560 by capturing the appropriate exception_ptr in the autograd engine and passing it over to the Future. As part of this change, there is a significant change the Future API where we now only accept an exception_ptr as part of setError. For the example in #42560, the exception trace would now look like: ``` > Traceback (most recent call last): > File "test_autograd.py", line 6914, in test_preserve_backtrace > Foo.apply(t).sum().backward() > File "torch/tensor.py", line 214, in backward > torch.autograd.backward(self, gradient, retain_graph, create_graph) > File "torch/autograd/__init__.py", line 127, in backward > allow_unreachable=True) # allow_unreachable flag > File "torch/autograd/function.py", line 87, in apply > return self._forward_cls.backward(self, *args) > File "test_autograd.py", line 6910, in backward > raise ValueError("something") > ValueError: something ``` ghstack-source-id: 111109637 Test Plan: waitforbuildbot Reviewed By: albanD Differential Revision: D23365408 fbshipit-source-id: 1470c4776ec8053ea92a6ee1663460a3bae6edc5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
825c109eb7
commit
f1624b82b5
@ -254,8 +254,8 @@ void OwnerRRef::setValue(IValue&& value) {
|
||||
future_->markCompleted(value);
|
||||
}
|
||||
|
||||
void OwnerRRef::setError(const std::string& error) {
|
||||
future_->setErrorIfNeeded(error);
|
||||
void OwnerRRef::setError(std::exception_ptr eptr) {
|
||||
future_->setErrorIfNeeded(std::move(eptr));
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const RRef& rref) {
|
||||
|
||||
Reference in New Issue
Block a user