fix jit List[Optional[Tensor]] type singleton bug#77846
fix jit List[Optional[Tensor]] type singleton bug#77846bdhirsh wants to merge 2 commits intogh/bdhirsh/239/basefrom
Conversation
[ghstack-poisoned]
🔗 Helpful links
❌ 2 New Failures, 1 PendingAs of commit 8716053 (more details on the Dr. CI page): Expand to see more
🕵️ 2 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages
|
This should fix the remaining dynamo <> functionalization integration issue. I had a fix earlier for JIT containers not correctly having singleton instances [here](#76085), which fixed a bug in this code for functionalization: ``` def f(a, b): return a[b] functionalize(foo)(torch.arange(3), torch.ones(2, dtype=torch.long)) ``` But apparently the following code is still broken: ``` def f(a, b): return torch.ops.aten.index(a, b) functionalize(foo)(torch.arange(3), torch.ones(2, dtype=torch.long)) ``` Why? we have separate schema parsing logic for the ops in `torch.ops.aten`, and that logic circumvented my fix, creating its own singleton instance for Optional[Tensor]. We can't test this in core for the same reason as the last fix, so companion functorch tests here: pytorch/functorch#820 [ghstack-poisoned]
| fake_value = c10::TypeFactory::create<c10::OptionalType>(fake_value); | ||
| real_value = c10::TypeFactory::create<c10::OptionalType>(real_value); | ||
| fake_value = c10::OptionalType::get(fake_value); | ||
| real_value = c10::OptionalType::get(real_value); |
There was a problem hiding this comment.
There is probably a more general fix to this problem, but I just wanted to do something simple that would fix dynamo
For example, code that calls TypeFactory::create<ListType> would probably end up creating multiple "singleton" instances of a given ListType, but that doesn't matter in practice because the logic for checking if two list types are the same in IValue.h basically just checks if both types are list-like, and then pointer-compares their inner types.
|
@pytorchbot merge this please |
|
Hey @bdhirsh. |
Summary: Pull Request resolved: #77846 Approved by: https://github.com/ezyang Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/de646c06d457277f24d790eb41545e72f2d76f66 Reviewed By: seemethere Differential Revision: D36537747 Pulled By: bdhirsh fbshipit-source-id: e5f8a544f2275301f6229ea57fbfb8266d959819
This should fix the remaining dynamo <> functionalization integration issue.
I had a fix earlier for JIT containers not correctly having singleton instances here, which fixed a bug in this code for functionalization:
But apparently the following code is still broken:
Why? we have separate schema parsing logic for the ops in
torch.ops.aten, and that logic circumvented my fix, creating its own singleton instance for Optional[Tensor].We can't test this in core for the same reason as the last fix, so companion functorch tests here: pytorch/functorch#820
Stack from ghstack: