Issue 1:
To Reproduce

import torch

class Model(torch.jit.ScriptModule):
@torch.jit.script_method
def forward(self, input):
# type: (Tensor) -> Tensor
return input

class TupleModel(Model):
@torch.jit.script_method
def forward(self, input):
# type: (Tuple[Tensor, Tensor]) -> Tuple[Tensor, Tensor]
return input

m1 = Model()
m2 = TupleModel()
x = torch.randn(3, 3)
m1(x)
m2((x, x))

RuntimeError: Method 'forward' already defined (insert at ../torch/csrc/api/include/torch/ordered_dict.h:359)

I've seen one case where this errors out silently and I get incorrect behavior. I am not putting it here because it is a really big case, I will try to shorten it if it is of interest.

Expected behavior

No crash

Issue 2:
Code example:

import torch

class Base(torch.jit.ScriptModule):
def __init__(self):
super().__init__()

@torch.jit.script_method
def forward(self, x):
for i in range(x.size(0)):
x += x[i].sum()
return x

class Derived(Base):
def __init__(self):
super().__init__()

@torch.jit.script_method
def forward(self, x):
for i in range(x.size(0)):
x -= x[i].sum()
return x

d = Derived()
print(d(torch.rand(3, 4)))

Fails with:

Traceback (most recent call last):
File "subclass.py", line 24, in <module>
d = Derived()
File "/Users/jamesreed/onnx-fairseq/pytorch/torch/jit/__init__.py", line 591, in init_then_register
self._create_methods(defs, rcbs)
RuntimeError: Method 'forward' already defined (insert at ../torch/csrc/api/include/torch/detail/ordered_dict.h:140)
frame #0: torch::jit::script::Module::create_method(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::function<void (torch::jit::script::Method&)>) + 428 (0x112cceaec in libtorch.dylib)
frame #1: torch::jit::script::defineMethodsInModule(torch::jit::script::Module&, std::__1::vector<torch::jit::script::Def, std::__1::allocator<torch::jit::script::Def> > const&, std::__1::vector<std::__1::function<std::__1::shared_ptr<torch::jit::script::SugaredValue> (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, torch::jit::script::Method&, torch::jit::SourceRange const&)>, std::__1::allocator<std::__1::function<std::__1::shared_ptr<torch::jit::script::SugaredValue> (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, torch::jit::script::Method&, torch::jit::SourceRange const&)> > > const&, std::__1::shared_ptr<torch::jit::script::SugaredValue>) + 947 (0x112ccd9b3 in libtorch.dylib)
frame #2: torch::jit::script::initJitScriptBindings(_object*)::$_3::operator()(std::__1::shared_ptr<torch::jit::script::Module>, std::__1::vector<torch::jit::script::Def, std::__1::allocator<torch::jit::script::Def> > const&, std::__1::vector<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>, std::__1::allocator<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)> > > const&) const + 1702 (0x110668906 in _C.cpython-36m-darwin.so)
frame #3: void pybind11::detail::argument_loader<std::__1::shared_ptr<torch::jit::script::Module>, std::__1::vector<torch::jit::script::Def, std::__1::allocator<torch::jit::script::Def> > const&, std::__1::vector<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>, std::__1::allocator<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)> > > const&>::call_impl<void, torch::jit::script::initJitScriptBindings(_object*)::$_3&, 0ul, 1ul, 2ul, pybind11::detail::void_type>(torch::jit::script::initJitScriptBindings(_object*)::$_3&&&, pybind11::detail::index_sequence<0ul, 1ul, 2ul>, pybind11::detail::void_type&&) + 396 (0x11066821c in _C.cpython-36m-darwin.so)
frame #4: std::__1::enable_if<std::is_void<void>::value, pybind11::detail::void_type>::type pybind11::detail::argument_loader<std::__1::shared_ptr<torch::jit::script::Module>, std::__1::vector<torch::jit::script::Def, std::__1::allocator<torch::jit::script::Def> > const&, std::__1::vector<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>, std::__1::allocator<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)> > > const&>::call<void, pybind11::detail::void_type, torch::jit::script::initJitScriptBindings(_object*)::$_3&>(torch::jit::script::initJitScriptBindings(_object*)::$_3&&&) + 49 (0x110664071 in _C.cpython-36m-darwin.so)
frame #5: void pybind11::cpp_function::initialize<torch::jit::script::initJitScriptBindings(_object*)::$_3, void, std::__1::shared_ptr<torch::jit::script::Module>, std::__1::vector<torch::jit::script::Def, std::__1::allocator<torch::jit::script::Def> > const&, std::__1::vector<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>, std::__1::allocator<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)> > > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(torch::jit::script::initJitScriptBindings(_object*)::$_3&&, void (*)(std::__1::shared_ptr<torch::jit::script::Module>, std::__1::vector<torch::jit::script::Def, std::__1::allocator<torch::jit::script::Def> > const&, std::__1::vector<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>, std::__1::allocator<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)> > > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::'lambda'(pybind11::detail::function_call&)::operator()(pybind11::detail::function_call&) const + 251 (0x110663f4b in _C.cpython-36m-darwin.so)
frame #6: void pybind11::cpp_function::initialize<torch::jit::script::initJitScriptBindings(_object*)::$_3, void, std::__1::shared_ptr<torch::jit::script::Module>, std::__1::vector<torch::jit::script::Def, std::__1::allocator<torch::jit::script::Def> > const&, std::__1::vector<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>, std::__1::allocator<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)> > > const&, pybind11::name, pybind11::is_method, pybind11::sibling>(torch::jit::script::initJitScriptBindings(_object*)::$_3&&, void (*)(std::__1::shared_ptr<torch::jit::script::Module>, std::__1::vector<torch::jit::script::Def, std::__1::allocator<torch::jit::script::Def> > const&, std::__1::vector<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>, std::__1::allocator<std::__1::function<pybind11::function (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)> > > const&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&) + 24 (0x110663e38 in _C.cpython-36m-darwin.so)
frame #7: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 6919 (0x10ff05a57 in _C.cpython-36m-darwin.so)
<omitting python frames>
frame #27: start + 1 (0x7fff5ec53015 in libdyld.dylib)