Skip to content

torch.distributions.Normal cuda sampling broken #22529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pfrendl opened this issue Jul 4, 2019 · 1 comment
Closed

torch.distributions.Normal cuda sampling broken #22529

pfrendl opened this issue Jul 4, 2019 · 1 comment
Labels
module: distributions Related to torch.distributions module: random Related to random number generation in PyTorch (rng generator) triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@pfrendl
Copy link

pfrendl commented Jul 4, 2019

🐛 Bug

Normal distribution returns wrong samples if provided cuda tensors, and all the samples take the same value.

To Reproduce

>>> mean = torch.tensor([0.0, 2.0], device='cuda')
>>> std = torch.tensor([1.0, 2.0], device='cuda')
>>> dist = torch.distributions.Normal(mean, std)
>>> dist.sample((10,))
tensor([[0., 6.],
        [0., 6.],
        [0., 6.],
        [0., 6.],
        [0., 6.],
        [0., 6.],
        [0., 6.],
        [0., 6.],
        [0., 6.],
        [0., 6.]], device='cuda:0')

Environment

  • PyTorch Version (e.g., 1.0): 1.2.0.dev20190703 (nightly)
  • OS (e.g., Linux): Ubuntu 16.04
  • How you installed PyTorch (conda, pip, source): pip3
  • Python version: 3.5.2
  • CUDA/cuDNN version: 10.0/7
  • GPU models and configuration: 2 x GTX 1080 Ti
@vishwakftw vishwakftw added module: distributions Related to torch.distributions module: random Related to random number generation in PyTorch (rng generator) labels Jul 4, 2019
@vishwakftw
Copy link
Contributor

Thank you for the bug report. The fix is available in #22533.

@mrshenli mrshenli added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 5, 2019
zdevito pushed a commit to zdevito/ATen that referenced this issue Jul 8, 2019
Summary:
`addcmul_out` overwrote the samples, which led to constant values being output by `torch.normal`.

Changelog:
- Replace the `addcmul_out` calls with combo of inplace `mul` and `add` and justification for this change.
Pull Request resolved: pytorch/pytorch#22533

Test Plan:
- Enable tests for test_normal on all devices

Fixes pytorch/pytorch#22529

Differential Revision: D16141337

Pulled By: ezyang

fbshipit-source-id: 567a399042e0adcd154582f362318ce95a244c62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: distributions Related to torch.distributions module: random Related to random number generation in PyTorch (rng generator) triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants