quornmd:

Dirichlet distribution sampling


derivative issue aside, it is odd that you need the gamma function for that, it should be enough to calculate fractions of GammaDistribution(a,1) samples. torch._standard_gamma(a) sampling is differentiable (by using reparameterisation I assume).