There are a couple of caveats in the notes coming with the KLDivLoss documentation 29.
Once you have these taken care of and use the correct input conventions, you should get the same loss and gradients for the things that ought to be mathematically equivalent (up to numerical error, of course).