Hi,
What is most likely happening is that your first optimizer step is actually changing some of the weights inplace. And so the second backward cannot run because it needs the original value of these weights.
You should either delay the first step after all the backward have been done. Or re-do the forward for the weights that have been changed before doing the second backward.