Hi, I think the reason why your algorithm is not converging is that you are calculating your gradient both when you calculate q_N and q_t, and that will cause gradient incorrectness. You can use q_t.detach() to remove q_t from the calculate chain. Hope it works!