Repository navigation
Add tensor bounds support to stateless normal API - #204472
jbschlosser wants to merge 8 commits into
Conversation
[ghstack-poisoned]
Attention! native_functions.yaml was changedIf you are adding a new function or defaulted argument to native_functions.yaml, you cannot use it from pre-existing Python frontend code until our FC window passes (two weeks). Split your PR into two PRs, one which adds the new C++ functionality, and one that makes use of it from Python, and land them two weeks apart. See https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy#forwards-compatibility-fc for more info. |
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:
Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/204472
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (3 Unrelated Failures)As of commit 91e5229 with merge base bcff2f4 ( 🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:
reason: NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following job failed, but the AI CI Advisor judged the failure not to be evidence against this change:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Merge startedYour 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 |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / win-vs2022-cpu-py3 / test (default, 9, 12, windows.4xlarge.nonephemeral). Blocking jobs that the merge waited on for a Dr.CI or AI CI Advisor classification: 1. Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge |
Merge startedYour 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 |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / win-vs2022-cpu-py3 / test (default, 9, 12, windows.4xlarge.nonephemeral) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge failedReason: 1 jobs have failed, first few of them are: .github/workflows/trunk.yml / win-vs2022-cpu-py3 / test (default, 9, 12, windows.4xlarge.nonephemeral) Details for Dev Infra teamRaised by workflow job |
|
@claude why can't I merge and what should I do to fix it? |
|
Claude finished @jbschlosser's task in 37s —— View job The merge is blocked by a redis release on PyPI, not by your code. Your stack's merge base (Nov 19) predates the redis pin on main, so rebasing onto current main should fix it. DetailsWhy it fails
What to doRebase the stack onto current main so it picks up the pin, let CI re-run, then merge: Locally, If you'd rather not wait for CI, |
[ghstack-poisoned]
|
@pytorchbot merge |
Merge startedYour 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 |
|
The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command |
|
@pytorchbot merge |
Merge startedYour 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 |
In preparation for a move to make the stateless RNG APIs public, this PR addresses a few minor issues: - CUDA: read a batched key with a non-unit last-dim stride correctly (previously gave wrong values), and copy an 8-byte-aligned single key to aligned memory before the 16-byte vector load (previously crashed). Batched keys with a unit last-dim stride are read in place instead of copied. - Reject an output whose elements share memory, or that overlaps a dense key, before doing any work. Previously internal overlap errored only in eager, after the compute, from copy_, and key aliasing wasn't caught at all. Meta checks internal overlap too. `assert_no_overlap` can't see overlap with a non-dense key, so CUDA copies a key that shares storage with the output instead of reading it while it's overwritten. - Write non-contiguous or misaligned outputs to a fresh buffer instead of a copy of the old values. - Make eager and meta validation agree: CPU and CUDA share one key/output check, so errors come in the same order on every path; meta checks tensor bounds before the key, like eager; CPU `uniform_`/`normal_` reject integer outputs with a clear error; and meta `randint_` rejects an empty range. Test Plan: ``` python test/test_stateless_rng.py -k test_noncontig_key -k test_overlapping_output -k test_tensor_bounds_errors -k test_error_wrong_self_dtype -k test_error_op_empty_range python test/test_stateless_rng.py ``` Authored with the assistance of an AI coding assistant (Claude). Pull Request resolved: #206328 Approved by: https://github.com/pytorchgreenlight, https://github.com/albanD ghstack dependencies: #204472
Expands `fold_in()` to support int64 scalar tensor data. This is useful because uint64 has limited support within PyTorch, and requiring it as the dtype for data makes doing math on such data annoying: ```python import torch import torch.func._random as random key = random.key(42, device="cuda") step = torch.tensor(0, device="cuda") # int64, e.g. a training-step counter # New: int64 data is accepted directly. k = random.fold_in(key, step) # Old (uint64 only): reinterpret the bits first. view() is zero-copy and # matches the int overload for negatives; .to(torch.uint64) would add a copy. k_old = random.fold_in(key, step.view(torch.uint64)) ``` Pull Request resolved: #206339 Approved by: https://github.com/albanD ghstack dependencies: #204472, #206328
Stack from ghstack (oldest at bottom):
Follow-up from #199790, applying the analogous extension to support tensor bounds for
normal().This PR also addresses a few leftover issues for
uniform()that came up during review:cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo