Thanks for the quick response. Maybe I’m missing something, but I guess I assumed that, since the loss Tensor apparently carries gradient information usable by the optimizer (populated by .backward()), that this automatically populates the .grad() attribute. I also assumed that since the loss is the output of a full .forward() operation, that it was a leaf–but that could easily be because I’m not completely grasping the leaf concept.
In case any of the above assumptions are invalid, I can certainly use .retain_grad() on the loss before .backward(). I guess I also (perhaps naively) assumed that .retain_grad follows if .requires_grad tests true. I generally dig through the library source to try to clarify some of these things, but the autograd facility is a bit complex.