We discovered that the reason why it seg faults is because next_fn->num_inputs is surprisingly zero, which leads to buffer having no elements in https://github.com/pytorch/pytorch/blob/master/torch/csrc/autograd/input_buffer.cpp#L16 15. This in turn leads to variable “item” pointing to some invalid memory, which triggers the segmentation fault once we try to access field “first”. Is this helpful to get a better idea about the issue? We are currently trying to debug the pytorch internals.