-
Notifications
You must be signed in to change notification settings - Fork 27.7k
torch.multinomial behaves abnormally with CUDA tensor #37403
Copy link
Copy link
Closed
Labels
high prioritymodule: cudaRelated to torch.cuda, and CUDA support in generalRelated to torch.cuda, and CUDA support in generalmodule: randomRelated to random number generation in PyTorch (rng generator)Related to random number generation in PyTorch (rng generator)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Metadata
Metadata
Assignees
Labels
high prioritymodule: cudaRelated to torch.cuda, and CUDA support in generalRelated to torch.cuda, and CUDA support in generalmodule: randomRelated to random number generation in PyTorch (rng generator)Related to random number generation in PyTorch (rng generator)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
🐛 Bug
Seems 'torch.multinomial' can not handle high-precisionly drawing from multinomial distribution in CUDA.
To Reproduce
To sample from a large corpus with an uniform distribution in CPU and CUDA seperately:
output of the code above:
torch.multinomial in CUDA output abnormally especially in large corpus, when corpus size=10^6, many keys is not sampled at all while others are sampled 100 times equally. Change the multinomial distribution input tensor to 'float64' doesn't solve this problem.
Environment
PyTorch version: 1.5.0+cu92
Is debug build: No
CUDA used to build PyTorch: 9.2
OS: Alibaba Group Enterprise Linux Server 7.2 (Paladin)
GCC version: (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
CMake version: Could not collect
Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration:
GPU 0: Tesla V100-SXM2-16GB
GPU 1: Tesla V100-SXM2-16GB
GPU 2: Tesla V100-SXM2-16GB
GPU 3: Tesla V100-SXM2-16GB
GPU 4: Tesla V100-SXM2-16GB
GPU 5: Tesla V100-SXM2-16GB
GPU 6: Tesla V100-SXM2-16GB
GPU 7: Tesla V100-SXM2-16GB
Nvidia driver version: 396.82
cc @ezyang @gchanan @zou3519 @ngimel @pbelevich