This is a bug, I’ve filed https://github.com/pytorch/pytorch/issues/29597 130 since this should be something that we can do automatically.
export is meant to be used as a decorator on functions that need to be compiled but are not called from forward or anything forward calls. So for your code you can just get rid of the call to torch.jit.export. See these docs 82 for details.