No. in general, the two results can differ by floating-point round-off error,
so this is expected.
Try redoing your test using all torch.float64 tensors (double precision).
You should still see a discrepancy, but now in something like the 15th
significant (decimal) digit.
But, why am I wrong in assuming that if I pass in logits to torch.distributions.Categorical that no further computation needs to be done to extract the log probability?
I can see that if I passed in the output of a softmax then the distribution class needs to compute a log(), but in this case it’s already done.