Repository navigation
CPU support for stateless RNG APIs - #177692
jbschlosser wants to merge 35 commits into
Conversation
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. Caused by: |
lucasb-eyer
left a comment
There was a problem hiding this comment.
Looks good to me, BUT with the caveat that I don't actually feel skilled enough to correctly review the code :)
|
@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 |
…internal) (#192615) ✴️ iz2: (opened by Ivan's agent on his behalf) #177692 ("CPU support for stateless RNG APIs") added `aten/src/ATen/native/PhiloxStatelessRNG.cpp` but did not register it in `build_variables.bzl`. When that PR was imported internally, the entry was added to the internal copy of `build_variables.bzl` before it landed. The two copies of the file have been out of sync since. This adds the same single line to the OSS copy, so `build_variables.bzl` matches on both sides. The entry goes into `aten_native_source_non_codegen_list`, in sorted position between `PackedSequence.cpp` and `PixelShuffle.cpp`. ### Build impact No effect on the default CMake build. `aten/src/ATen/CMakeLists.txt` has an if/else on `BUILD_LITE_INTERPRETER`: the `append_filelist("aten_native_source_non_codegen_list" ...)` call is only in the `ON` branch, while the default `OFF` branch composes `all_cpu_cpp` from `file(GLOB native_cpp "native/*.cpp")`, which already picks this file up. The two branches are mutually exclusive, so there is no double-add. The change does add the file to the source list used by the `BUILD_LITE_INTERPRETER=ON` branch and by the buck path (`aten_native_source_list` → `buckbuild.bzl`, `pt_template_srcs.bzl`), where it is currently absent. That is a real change in source composition for those configurations rather than pure metadata, so it is worth calling out — though it is the composition the file's own `native_functions.yaml` CPU dispatch entries imply. The equivalent internal buck build already compiles this file from a list containing this exact line. ### Verification - `build_variables.bzl` on this branch is byte-identical to the internal copy as of internal master `63074c69e3aa` (both 79151 bytes, matching md5). Before this change the OSS copy was 79100 bytes and the only difference between the two files was this one line, in one direction — there were no OSS-only lines. - `lintrunner` is clean. Byte-identity is stated against that named internal snapshot; it is not a claim about future drift. Pull Request resolved: #192615 Approved by: https://github.com/pytorchgreenlight, https://github.com/Skylion007
…internal) (pytorch#192615) ✴️ iz2: (opened by Ivan's agent on his behalf) pytorch#177692 ("CPU support for stateless RNG APIs") added `aten/src/ATen/native/PhiloxStatelessRNG.cpp` but did not register it in `build_variables.bzl`. When that PR was imported internally, the entry was added to the internal copy of `build_variables.bzl` before it landed. The two copies of the file have been out of sync since. This adds the same single line to the OSS copy, so `build_variables.bzl` matches on both sides. The entry goes into `aten_native_source_non_codegen_list`, in sorted position between `PackedSequence.cpp` and `PixelShuffle.cpp`. ### Build impact No effect on the default CMake build. `aten/src/ATen/CMakeLists.txt` has an if/else on `BUILD_LITE_INTERPRETER`: the `append_filelist("aten_native_source_non_codegen_list" ...)` call is only in the `ON` branch, while the default `OFF` branch composes `all_cpu_cpp` from `file(GLOB native_cpp "native/*.cpp")`, which already picks this file up. The two branches are mutually exclusive, so there is no double-add. The change does add the file to the source list used by the `BUILD_LITE_INTERPRETER=ON` branch and by the buck path (`aten_native_source_list` → `buckbuild.bzl`, `pt_template_srcs.bzl`), where it is currently absent. That is a real change in source composition for those configurations rather than pure metadata, so it is worth calling out — though it is the composition the file's own `native_functions.yaml` CPU dispatch entries imply. The equivalent internal buck build already compiles this file from a list containing this exact line. ### Verification - `build_variables.bzl` on this branch is byte-identical to the internal copy as of internal master `63074c69e3aa` (both 79151 bytes, matching md5). Before this change the OSS copy was 79100 bytes and the only difference between the two files was this one line, in one direction — there were no OSS-only lines. - `lintrunner` is clean. Byte-identity is stated against that named internal snapshot; it is not a claim about future drift. Pull Request resolved: pytorch#192615 Approved by: https://github.com/pytorchgreenlight, https://github.com/Skylion007
Stack from ghstack (oldest at bottom):
CPU support for stateless RNG APIs in
torch/func/_random.py:key()split()fold_in()normal()uniform()For now, these kernels are not performance optimized (i.e. they don't use vectorization) but the semantics are guaranteed to match those of CUDA.
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01