Skip to content
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

Debug TorchScript error for Slomo #95

Closed
anijain2305 opened this issue Mar 23, 2022 · 0 comments
Closed

Debug TorchScript error for Slomo #95

anijain2305 opened this issue Mar 23, 2022 · 0 comments
Assignees

Comments

@anijain2305
Copy link
Contributor

anijain2305 commented Mar 23, 2022

cc @eellison Repro for the bug while running TorchDynamo + AOTAutograd with Torchscript

It seems like, torchscript expects the default values for torch.ops.aten.avg_pool2d_backward to be present.

The error can be repro by - python torchbench.py --training --devices=cuda --accuracy-aot-ts --only=Super_SloMo

RuntimeError:
Arguments for call are not valid.
The following variants are available:

  aten::avg_pool2d_backward(Tensor grad_output, Tensor self, int[2] kernel_size, int[2] stride, int[2] padding, bool ceil_mode, bool count_include_pad, int? divisor_override) -> (Tensor):
  Expected a value of type 'List[int]' for argument 'stride' but instead found type 'List[Tensor]'.
  Empty lists default to List[Tensor]. Add a variable annotation to the assignment to create an empty list of another type (torch.jit.annotate(List[T, []]) where T is the type of elements in the list for Python 2)

  aten::avg_pool2d_backward.grad_input(Tensor grad_output, Tensor self, int[2] kernel_size, int[2] stride, int[2] padding, bool ceil_mode, bool count_include_pad, int? divisor_override, *, Tensor(a!) grad_input) -> (Tensor(a!)):
  Expected a value of type 'List[int]' for argument 'stride' but instead found type 'List[Tensor]'.
  Empty lists default to List[Tensor]. Add a variable annotation to the assignment to create an empty list of another type (torch.jit.annotate(List[T, []]) where T is the type of elements in the list for Python 2)

The original call is:
  File "<eval_with_key>.12", line 362
    getitem_95 = convolution_backward_22[1]
    getitem_96 = convolution_backward_22[2];  convolution_backward_22 = None
    avg_pool2d_backward = torch.ops.aten.avg_pool2d_backward(getitem_94, leaky_relu_32, [2, 2], [], [0, 0], False, True, None);  getitem_94 = leaky_relu_32 = None
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    add_46 = torch.ops.aten.add(detach_195, avg_pool2d_backward);  detach_195 = avg_pool2d_backward = None
    leaky_relu_backward_13 = torch.ops.aten.leaky_relu_backward(add_46, convolution_32, 0.1, False);  add_46 = convolution_32 = None

ERROR
@anijain2305 anijain2305 reopened this Mar 23, 2022
@eellison eellison self-assigned this Mar 24, 2022
eellison pushed a commit to pytorch/pytorch that referenced this issue Mar 25, 2022
… arbitrary types"


As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

[ghstack-poisoned]
eellison pushed a commit to pytorch/pytorch that referenced this issue Mar 25, 2022
… arbitrary types"


As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

[ghstack-poisoned]
eellison pushed a commit to pytorch/pytorch that referenced this issue Mar 25, 2022
… arbitrary types"


As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

[ghstack-poisoned]
eellison pushed a commit to pytorch/pytorch that referenced this issue Mar 28, 2022
…to be matched to arbitrary types"


As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

[ghstack-poisoned]
eellison pushed a commit to pytorch/pytorch that referenced this issue Mar 28, 2022
… arbitrary types"


As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

[ghstack-poisoned]
eellison pushed a commit to pytorch/pytorch that referenced this issue Apr 5, 2022
…to be matched to arbitrary types"


As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

Differential Revision: [D35362760](https://our.internmc.facebook.com/intern/diff/D35362760)

[ghstack-poisoned]
eellison pushed a commit to pytorch/pytorch that referenced this issue Apr 5, 2022
… arbitrary types"


As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

Differential Revision: [D35362760](https://our.internmc.facebook.com/intern/diff/D35362760)

[ghstack-poisoned]
facebook-github-bot pushed a commit to pytorch/pytorch that referenced this issue Apr 6, 2022
…types (#74768)

Summary:
Pull Request resolved: #74768

As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

Test Plan: Imported from OSS

Reviewed By: ejguan

Differential Revision: D35362760

Pulled By: eellison

fbshipit-source-id: da23e8889312001b60d64a1758da5c578b6fe5ea
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this issue Apr 6, 2022
…types (#74768)

Summary:
Pull Request resolved: #74768

As commented in code:
```
    // Empty List Literals that are not assigned to variables
    // may match to any list type in schema matching,
    // but still default to List[Tensor] if assigned to a variable
    // or returned from a function
    // Restricting empty list matching to temporary values
    // avoids difficult to handle cases such as
    // a = []
    // b = a
    // if cond:
    //    b.append(2)
    // else:
    //    a.append("hi")
    // This is also the same behavior that C++ allows with {}
    // (cannot assign to a variable typed as auto)
```

Fix for pytorch/torchdynamo#95

Test Plan: Imported from OSS

Reviewed By: ejguan

Differential Revision: D35362760

Pulled By: eellison

fbshipit-source-id: da23e8889312001b60d64a1758da5c578b6fe5ea
(cherry picked from commit 75682f1)
@eellison eellison closed this as completed Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants