-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Restore allow_unused functionality #6553
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
Conversation
| if (!grad_fn) { | ||
| output_edges.emplace_back(); | ||
| } else { | ||
| THPUtils_assert(grad_fn, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
apaszke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor things, and it's good to merge.
I actually can't remember why I changed that, sorry to hear that it caused those problems. I know for sure that I wanted to remove only_inputs, but I can't think of any reasons why allow_unused got cut.
It might have been that I've heard many comments saying that returning None is what most people expect, and this is also what other libraries do, but I think it's ok to be strict in this case. This often happens when taking higher order derivatives.
| unsigned char keep_graph = 0; | ||
| unsigned char create_graph = 0; | ||
| PyObject *inputs = nullptr; | ||
| unsigned char allow_unreachable = 1; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| THPObjectPtr py_outputs {PyTuple_New(num_inputs)}; | ||
| if (!py_outputs) return nullptr; | ||
| for (int i = 0; i < num_inputs; i++) { | ||
| THPUtils_assert(allow_unreachable || outputs[i].defined(), "One of the differentiated " |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
test/test_jit.py
Outdated
| l1_ge, recording_inputs, create_graph=True, allow_unused=True) | ||
| l2_ge = (allSum(grads_ge) * l1_ge) | ||
| grads2_ge = torch.autograd.grad(l2_ge, recording_inputs) | ||
| grads2_ge = torch.autograd.grad(l2_ge, recording_inputs, allow_unused=True) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Hi @apaszke , What is the reason for deprecating the I think it was useful to do partial backpropagations while still filling the gradient buffers on the way. Without it, is there another way to halt the backpropagation flow at a given node when calling Thanks! |
Addresses #6535
I'll do a Variable -> Tensor codemod in a separate PR.