Skip to content

Reorder stateless RNG key() args + make them kw-only - #189768

Closed
jbschlosser wants to merge 3 commits into
gh/jbschlosser/284/basefrom
gh/jbschlosser/284/head
Closed

jbschlosser wants to merge 3 commits into
gh/jbschlosser/284/basefrom
gh/jbschlosser/284/head

Conversation

@jbschlosser

@jbschlosser jbschlosser commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/189768

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 79829c5 with merge base 186adfc (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

[ghstack-poisoned]
@jbschlosser

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 14, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #189767

1 similar comment
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #189767

pull Bot pushed a commit to sysfce2/pytorch that referenced this pull request Jul 14, 2026
…#189767)

This PR addresses beta user feedback on `fold_in(key, data)`:
* Tightens up the support regarding dtype for `data`; we now explicitly support ints in the range `[-2**63, 2**64 - 1]` (i.e. all signed int64 AND uint64 values) with negative values reinterpreted as two's complement of uint64 values, following the precedent set by [`manual_seed()`](https://docs.pytorch.org/docs/2.13/generated/torch.manual_seed.html). This requires some python-side gymnastics since we utilize the standard ATen op parsing logic that treats ints as int64. Docs were also updated to indicate this.
* Adds a Tensor `data` ATen op overload that can be used to avoid baking in `data` to captured CUDAGraphs. Note that, for simplicity, we only allow a single item Tensor `data` for now. In the future, if necessary, we can support folding broadcastable data across a batched set of keys.
Pull Request resolved: pytorch#189767
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#189768
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
Addresses beta user feedback by reordering `torch.func._random.key()`'s args in a more natural way and making them kw-only. It's technically BC-breaking for this private API but I don't expect it to be widely used yet so let's make this change while we can.
Pull Request resolved: pytorch#189768
Approved by: https://github.com/Skylion007, https://github.com/albanD
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
…#189767)

This PR addresses beta user feedback on `fold_in(key, data)`:
* Tightens up the support regarding dtype for `data`; we now explicitly support ints in the range `[-2**63, 2**64 - 1]` (i.e. all signed int64 AND uint64 values) with negative values reinterpreted as two's complement of uint64 values, following the precedent set by [`manual_seed()`](https://docs.pytorch.org/docs/2.13/generated/torch.manual_seed.html). This requires some python-side gymnastics since we utilize the standard ATen op parsing logic that treats ints as int64. Docs were also updated to indicate this.
* Adds a Tensor `data` ATen op overload that can be used to avoid baking in `data` to captured CUDAGraphs. Note that, for simplicity, we only allow a single item Tensor `data` for now. In the future, if necessary, we can support folding broadcastable data across a batched set of keys.
Pull Request resolved: pytorch#189767
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#189768
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
Addresses beta user feedback by reordering `torch.func._random.key()`'s args in a more natural way and making them kw-only. It's technically BC-breaking for this private API but I don't expect it to be widely used yet so let's make this change while we can.
Pull Request resolved: pytorch#189768
Approved by: https://github.com/Skylion007, https://github.com/albanD
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
…#189767)

This PR addresses beta user feedback on `fold_in(key, data)`:
* Tightens up the support regarding dtype for `data`; we now explicitly support ints in the range `[-2**63, 2**64 - 1]` (i.e. all signed int64 AND uint64 values) with negative values reinterpreted as two's complement of uint64 values, following the precedent set by [`manual_seed()`](https://docs.pytorch.org/docs/2.13/generated/torch.manual_seed.html). This requires some python-side gymnastics since we utilize the standard ATen op parsing logic that treats ints as int64. Docs were also updated to indicate this.
* Adds a Tensor `data` ATen op overload that can be used to avoid baking in `data` to captured CUDAGraphs. Note that, for simplicity, we only allow a single item Tensor `data` for now. In the future, if necessary, we can support folding broadcastable data across a batched set of keys.
Pull Request resolved: pytorch#189767
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#189768
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
Addresses beta user feedback by reordering `torch.func._random.key()`'s args in a more natural way and making them kw-only. It's technically BC-breaking for this private API but I don't expect it to be widely used yet so let's make this change while we can.
Pull Request resolved: pytorch#189768
Approved by: https://github.com/Skylion007, https://github.com/albanD
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
…#189767)

This PR addresses beta user feedback on `fold_in(key, data)`:
* Tightens up the support regarding dtype for `data`; we now explicitly support ints in the range `[-2**63, 2**64 - 1]` (i.e. all signed int64 AND uint64 values) with negative values reinterpreted as two's complement of uint64 values, following the precedent set by [`manual_seed()`](https://docs.pytorch.org/docs/2.13/generated/torch.manual_seed.html). This requires some python-side gymnastics since we utilize the standard ATen op parsing logic that treats ints as int64. Docs were also updated to indicate this.
* Adds a Tensor `data` ATen op overload that can be used to avoid baking in `data` to captured CUDAGraphs. Note that, for simplicity, we only allow a single item Tensor `data` for now. In the future, if necessary, we can support folding broadcastable data across a batched set of keys.
Pull Request resolved: pytorch#189767
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#189768
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
Addresses beta user feedback by reordering `torch.func._random.key()`'s args in a more natural way and making them kw-only. It's technically BC-breaking for this private API but I don't expect it to be widely used yet so let's make this change while we can.
Pull Request resolved: pytorch#189768
Approved by: https://github.com/Skylion007, https://github.com/albanD
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…#189767)

This PR addresses beta user feedback on `fold_in(key, data)`:
* Tightens up the support regarding dtype for `data`; we now explicitly support ints in the range `[-2**63, 2**64 - 1]` (i.e. all signed int64 AND uint64 values) with negative values reinterpreted as two's complement of uint64 values, following the precedent set by [`manual_seed()`](https://docs.pytorch.org/docs/2.13/generated/torch.manual_seed.html). This requires some python-side gymnastics since we utilize the standard ATen op parsing logic that treats ints as int64. Docs were also updated to indicate this.
* Adds a Tensor `data` ATen op overload that can be used to avoid baking in `data` to captured CUDAGraphs. Note that, for simplicity, we only allow a single item Tensor `data` for now. In the future, if necessary, we can support folding broadcastable data across a batched set of keys.
Pull Request resolved: pytorch#189767
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#189768
@github-actions
github-actions Bot deleted the gh/jbschlosser/284/head branch August 14, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants