Skip to content
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

The interval for torch::jit::fuser::cuda::randlike is not the same as for torch.rand_like #1807

Closed
IvanYashchuk opened this issue Jul 6, 2022 · 2 comments

Comments

@IvanYashchuk
Copy link
Collaborator

🐛 Describe the bug

See the discussion here #1799 (comment).

Turns out nvfuser's randlike function generates "1.0" in uniform samples while in PyTorch uniform distribution is sampled on the interval [0.0, 1.0), "0.0" is included, "1.0" is excluded.

I think nvfuser's random numbers should be changed to sample on [0.0, 1.0) interval. uniform and uniformf functions are implemented here, and used for randLike device functions: https://github.com/csarofeen/pytorch/blob/fa4e6a4739a9daaa0e4111fb4730704d79c91010/torch/csrc/jit/codegen/cuda/runtime/helpers.cu#L302-L308
We could replace generated samples of 1.0 with 0.0:

 __device__ float randLikef(Philox& rnd) { 
   float sample = uniformf(rnd());
   return sample == 1.0 ? 0.0 : sample;
 } 

Versions

devel branch

@jjsjann123
Copy link
Collaborator

I guess with #1804 this is considered as fixed?

@IvanYashchuk
Copy link
Collaborator Author

Yes, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants