RuntimeError: vector::_M_range_check

Hi all,
I have been running into the following error with my torch model and have been struggling to debug it:

RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: vector::_M_range_check: __n (which is 18446744073709551615) >= this->size() (which is 2)

The crux of the issue is that I have a decently complex torch.nn model class, that I have successfully been able to jit.script. The forward pass has a direct prediction from several nn submodules and then another prediction that is computed using autograd w.t.r. to the input. Everything works fine when I run my model on a cpu, but when I map it to cuda I get the M_range error.

Any help for teasing out why this error is happening would be greatly appreciated, or even some information on what causes this error.