ok that’s in line with the student grads being all zero, if it wasn’t i’d be confused. Now all we have to see is why the student grad is 0.
try making a fake loss like loss_fake = emb_student.sum(). Doing backward on with this simple loss, you should expect non-zero gradients to propagate to emb_student .If it doesn’t then there is a snag some-place
Also i found out from here 19 that you don’t need to do register_backward_hook, you can just do emb_student.retain_grad() to see if it is getting a gradient. try out this method as well to cross check once.