Thank you for the new word! I’ll be sure to use it next time I need it (and around computers, that will be soon…).
The obvious solution is to fix PyTorch to not do that.  But can you give us some more idea about topic_weights (is it cuda, what shape, something unusual about the values)? The perfect reproducing example would allow us to generate the NaNs (by giving the weights and a random seed/rng state that hits the problem). A bug report with a reproducing case would be great help! (Or just paste it here and we can forward it.)
There have been issues with very large/small parameters for some distributions, but a very quick search doesn’t scream the Dirichlet issue is known.
Best regards
Thomas