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

Reland of "Python binding to set/get CUDA rng state offset" (#99565) #139

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

malfet
Copy link
Contributor

@malfet malfet commented Apr 20, 2023

Summary:
Why?

Concern - I had to add set_offset in all instances of GeneratorImpl. I don't know if there is a better way.

import torch
torch.cuda.manual_seed(123)
print(torch.cuda.get_rng_state())
torch.cuda.set_rng_state_offset(40)
print(torch.cuda.get_rng_state())

tensor([123,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
          0,   0], dtype=torch.uint8)
tensor([123,   0,   0,   0,   0,   0,   0,   0,  40,   0,   0,   0,   0,   0,
          0,   0], dtype=torch.uint8)

Reland of pytorch/pytorch#98965

(cherry picked from commit 8214fe07e8a200e0fe9ca4264bb6fca985c4911e)

X-link: pytorch/pytorch#99565

Reviewed By: anijain2305

Differential Revision: D45130271

Pulled By: malfet

Summary:
Why?
* To reduce the latency of hot path in pytorch/pytorch#97377

Concern - I had to add `set_offset` in all instances of `GeneratorImpl`. I don't know if there is a better way.

~~~~
import torch
torch.cuda.manual_seed(123)
print(torch.cuda.get_rng_state())
torch.cuda.set_rng_state_offset(40)
print(torch.cuda.get_rng_state())

tensor([123,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
          0,   0], dtype=torch.uint8)
tensor([123,   0,   0,   0,   0,   0,   0,   0,  40,   0,   0,   0,   0,   0,
          0,   0], dtype=torch.uint8)
~~~~

Reland of pytorch/pytorch#98965

(cherry picked from commit 8214fe07e8a200e0fe9ca4264bb6fca985c4911e)

X-link: pytorch/pytorch#99565

Reviewed By: anijain2305

Differential Revision: D45130271

Pulled By: malfet

fbshipit-source-id: a31caebf1cecd6a6f9d4552d98a2b9a6eb7690e5
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D45130271

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

Successfully merging this pull request may close these issues.

3 participants