I’m not sure what is going wrong, but you should only get the second error if there are really no graph nodes requiring a gradient, which should not be the case if you use the hidden states as input to an LSTM and then backpropagate on the output since the LSTM parameters will require gradients.