Sampling from multinomial with extremely high values

Hello!

Is there a way to sample efficiently from a large collection of indexes (1M~) without repetition? I was using the function multinomial(torch.ones(length), num_samples, replacement=False) but it is taking too much time to generate the samples.

Thanks!

This PR implements torch.choice, it accelerates sampling from multinomial distributions.

As a second option, this repo does basically the same thing, but it is older than the PR.

1 Like