8000 TorchScript doesn't support `input` keyword argument · Issue #71994 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

TorchScript doesn't support input keyword argument #71994

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

Closed
peterbell10 opened this issue Jan 28, 2022 · 5 comments
Closed

TorchScript doesn't support input keyword argument #71994

peterbell10 opened this issue Jan 28, 2022 · 5 comments
Assignees
Labels
high priority oncall: jit Add this issue/PR to JIT oncall triage queue triage review

Comments

@peterbell10
Copy link
Collaborator
peterbell10 commented Jan 28, 2022

🐛 Describe the bug

TorchScript doesn't understand that the self argument in function schemas is renamed to input for the functional variant. So will fail when input is passed as a keyword argument. For example:

import torch
def f(x):
    return torch.ceil(input=x)

# Calling f directly work fine
a = torch.randn(10)
f(a)

# But TorchScipt fails
torch.jit.script(f)

Which returns the following error:

RuntimeError: 
Arguments for call are not valid.
The following variants are available:
  
  aten::ceil(Tensor self) -> (Tensor):
  Argument self not provided.
  
  aten::ceil.out(Tensor self, *, Tensor(a!) out) -> (Tensor(a!)):
  Argument self not provided.
  
  aten::ceil.int(int a) -> (int):
  Argument a not provided.
  
  aten::ceil.float(float a) -> (int):
  Argument a not provided.
  
  aten::ceil.Scalar(Scalar a) -> (Scalar):
  Argument a not provided.

Versions

PyTorch version: 1.11.0a0+git12e01f7
Is debug build: False
CUDA used to build PyTorch: 11.2
ROCM used to build PyTorch: N/A

OS: Pop!_OS 21.10 (x86_64)
GCC version: (Ubuntu 11.2.0-7ubuntu2) 11.2.0
Clang version: 13.0.0-2
CMake version: version 3.21.3
Libc version: glibc-2.34

Python version: 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:22:27)  [GCC 9.3.0] (64-bit runtime)
Python platform: Linux-5.15.8-76051508-generic-x86_64-with-glibc2.10
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 2060 SUPER
Nvidia driver version: 470.86
cuDNN version: Probably one of the following:
/usr/lib/cuda-11.1/targets/x86_64-linux/lib/libcudnn.so.8.0.4
/usr/lib/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.0.4
/usr/lib/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.0.4
/usr/lib/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.0.4
/usr/lib/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.0.4
/usr/lib/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.0.4
/usr/lib/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.0.4
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] bert-pytorch==0.0.1a4
[pip3] mypy==0.812
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.20.2
[pip3] pytorch-sphinx-theme==0.0.24
[pip3] torch==1.11.0a0+gitc37219a
[pip3] torch-struct==0.4
[pip3] torchfile==0.1.0
[pip3] torchmetrics==0.5.1
[pip3] torchtext==0.10.0a0+ba0bf52
[pip3] torchvision==0.12.0a0+bf073e7
[pip3] torchviz==0.0.2
[conda] bert-pytorch              0.0.1a4                   dev_0    <develop>
[conda] cudatoolkit               11.2.2               he111cf0_8    conda-forge
[conda] magma-cuda111             2.5.2                         1    pytorch
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-include               2021.4.0           h8d4b97c_729    conda-forge
[conda] mypy                      0.812              pyhd8ed1ab_0    conda-forge
[conda] mypy_extensions           0.4.3            py38h578d9bd_4    conda-forge
[conda] numpy                     1.17.5                   pypi_0    pypi
[conda] pytorch-sphinx-theme      0.0.24                    dev_0    <develop>
[conda] torch                     1.11.0a0+gitc37219a           dev_0    <develop>
[conda] torch-struct              0.4                       dev_0    <develop>
[conda] torchfile                 0.1.0                    pypi_0    pypi
[conda] torchmetrics              0.5.1                    pypi_0    pypi
[conda] torchtext                 0.10.0a0+ba0bf52          pypi_0    pypi
[conda] torchvision               0.12.0a0+bf073e7          pypi_0    pypi
[conda] torchviz                  0.0.2                    pypi_0    pypi

cc @ezyang @gchanan @zou3519

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jan 28, 2022
@albanD
Copy link
Collaborator
albanD commented Jan 31, 2022

Tentative high priority as this is blocking unnecessary code removal.

@eellison
Copy link
Contributor
eellison commented Feb 2, 2022

Where is the equivalent python logic that allows both self and input ?

@peterbell10
Copy link
Collaborator Author

# s/self/input/ outside method bindings
# [old codegen] TODO: remove this? doesn't rename in codegen, it's just
# for the parse string
if name == 'self' and type_str == 'Tensor' and not method:
name = 'input'

Note it doesn't allow both. The argument is only callable as input and never self.

@eellison
Copy link
Contributor
eellison commented Feb 7, 2022

Hmm, I mean the ideal state would would be to update the native_functions.yaml schemas so that they accurate reflect their behavior in python. But that is probably too much churn for what is a small change here. I think we want to update https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/frontend/schema_matching.cpp to include a boolean if we're matching against a schema from aten (or better yet native_functions.yaml, though i don't know how easily accessable that information is) and if so allow self arg to be matched against input

@anjali411
Copy link
Contributor

@eellison is there a PR fixing this? This is blocking multiple PRs #71993 #72882

@tugsbayasgalan tugsbayasgalan self-assigned this Feb 18, 2022
tugsbayasgalan added a commit that referenced this issue Feb 22, 2022
tugsbayasgalan added a commit that referenced this issue Feb 23, 2022
This PR allows TS schema_matching to match input arg with self for aten operators. This is because, operators in their functional form have input as paremeter instead of self. 

fixes: #71994

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

[ghstack-poisoned]
tugsbayasgalan added a commit that referenced this issue Feb 23, 2022
This PR allows TS schema_matching to match input arg with self for aten operators. This is because, operators in their functional form have input as paremeter instead of self. 

fixes: #71994

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

[ghstack-poisoned]
facebook-github-bot pushed a commit that referenced this issue Feb 24, 2022
Summary:
Pull Request resolved: #73253

This PR allows TS schema_matching to match input arg with self for aten operators. This is because, operators in their functional form have input as paremeter instead of self.

fixes: #71994

Test Plan: Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D34427556

Pulled By: tugsbayasgalan

fbshipit-source-id: 96c2340d605c59634bf6e37db1db6025d93a933a
cyyever pushed a commit to cyyever/pytorch_private that referenced this issue Mar 3, 2022
Summary:
Pull Request resolved: pytorch/pytorch#73253

This PR allows TS schema_matching to match input arg with self for aten operators. This is because, operators in their functional form have input as paremeter instead of self.

fixes: pytorch/pytorch#71994

Test Plan: Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D34427556

Pulled By: tugsbayasgalan

fbshipit-source-id: 96c2340d605c59634bf6e37db1db6025d93a933a
(cherry picked from commit 45a593d73bc5e6308dd80a4a29afed8e318a0a1c)
cyyever pushed a commit to cyyever/pytorch_private that referenced this issue Mar 3, 2022
Summary:
Pull Request resolved: pytorch/pytorch#73253

This PR allows TS schema_matching to match input arg with self for aten operators. This is because, operators in their functional form have input as paremeter instead of self.

fixes: pytorch/pytorch#71994

Test Plan: Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D34427556

Pulled By: tugsbayasgalan

fbshipit-source-id: 96c2340d605c59634bf6e37db1db6025d93a933a
(cherry picked from commit 45a593d73bc5e6308dd80a4a29afed8e318a0a1c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority oncall: jit Add this issue/PR to JIT oncall triage queue triage review
Projects
None yet
Development

No branches or pull requests

6 participants
0