Fake: copy over grad attribute#82593
Conversation
[ghstack-poisoned]
🔗 Helpful links
❌ 32 New FailuresAs of commit eeac921 (more details on the Dr. CI page): Expand to see more
🕵️ 32 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages
|
| if type(t) is torch.nn.Parameter: | ||
| out = torch.nn.Parameter(out, requires_grad=out.requires_grad) # type: ignore[assignment] | ||
| if safe_is_leaf(t) and t.grad is not None: | ||
| out.grad = self.from_real_tensor(fake_mode, t.grad) |
There was a problem hiding this comment.
what if we have grad on a non-leaf tensor 🤔
There was a problem hiding this comment.
TBH, i'm not really sure...
There was a problem hiding this comment.
I think I'd just drop the leaf check
>>> torch.zeros(2, requires_grad=True)
tensor([0., 0.], requires_grad=True)
>>> x = torch.zeros(2, requires_grad=True)
>>> y = x * 2
>>> y.grad = torch.zeros(2)
>>> y
tensor([0., 0.], grad_fn=<MulBackward0>)
>>> y.grad
tensor([0., 0.])
Copy over the grad attribute... let me any suggestions of other tests/opinfos/crossrefs I should be doing to make this more comprehensive. [ghstack-poisoned]
Copy over the grad attribute... let me any suggestions of other tests/opinfos/crossrefs I should be doing to make this more comprehensive. [ghstack-poisoned]
Copy over the grad attribute... let me any suggestions of other tests/opinfos/crossrefs I should be doing to make this more comprehensive. [ghstack-poisoned]
|
@pytorchbot merge |
|
@pytorchbot successfully started a merge job. Check the current status here |
|
Hey @eellison. |
Summary: Copy over the grad attribute... let me any suggestions of other tests/opinfos/crossrefs I should be doing to make this more comprehensive. Pull Request resolved: #82593 Approved by: https://github.com/ezyang Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/09a6d0b5bb6554926a4712c823e2da17bb7bd5b3 Reviewed By: kit1980 Differential Revision: D38359458 Pulled By: eellison fbshipit-source-id: 4a5d2e6bf18eb69c205c80513be000ec77820167
Stack from ghstack (oldest at bottom):
Copy over the grad attribute... let me any suggestions of other tests/opinfos/crossrefs I should be doing to make this more comprehensive.