To narrow this down:
Replacing the pdf-assignment with the following (nonsensical, but resulting in the same output shape and connecting the backward graph - the shapes for mu, sigma, x_repeat, pdf are (8,), (6, 1, 8, 8), (6, 8000, 8), (8000, 6) respectively):
pdf = torch.einsum('i,jxii,jni->nj',mu, sigma, x_repeat)

gets rid of the slow part. I think there are some known (and possibly some not known) performance issues with distributions.
Best regards
Thomas
P.S.: Minimal example:
mu = torch.randn(8)
sigma = torch.eye(8).expand(6, 1, 8, 8).contiguous().requires_grad_()
x_repeat = torch.randn(6,8000,8)
pdf = MultivariateNormal(mu, sigma).log_prob(x_repeat).t()
pdf.sum().backward()