Skip to content

Add support for full uint64 range + tensor data to fold_in() - #189767

Closed
jbschlosser wants to merge 4 commits into
gh/jbschlosser/283/basefrom
gh/jbschlosser/283/head
Closed

jbschlosser wants to merge 4 commits into
gh/jbschlosser/283/basefrom
gh/jbschlosser/283/head

Conversation

@jbschlosser

@jbschlosser jbschlosser commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

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(). 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.

[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/189767

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit a0f6a7e with merge base 20aa640 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@pytorch-bot

pytorch-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

Attention! native_functions.yaml was changed

If 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.

[ghstack-poisoned]
@jbschlosser jbschlosser added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 14, 2026
auto key_contig = key.contiguous();

constexpr int block_size = 256;
int num_blocks = std::min(

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.

ooc, why grid-stride loop here? You can just launch as many blocks as you need?

@jbschlosser jbschlosser Jul 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah good point, I moved over to this paradigm already for the generation kernels. I think I'll do the same here (in a follow-up PR if that's okay)

Comment thread torch/func/_random.py Resolved
[ghstack-poisoned]
@jbschlosser

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@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

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10-mi350 / test (distributed, 1, 3, linux.rocm.gpu.gfx950.2)

Details for Dev Infra team Raised by workflow job

@albanD
albanD removed their request for review July 15, 2026 15:56
[ghstack-poisoned]
@jbschlosser

jbschlosser commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor Author

AFAICT the revert was spurious so I'm relanding after a rebase

@jbschlosser

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@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 #189735

pytorchmergebot pushed a commit that referenced this pull request Jul 16, 2026
…kernels (#189735)

Original repro in P2415048693.

Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of #188495.

`FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results.

This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live.

Pull Request resolved: #189735
Approved by: https://github.com/eellison
ghstack dependencies: #189767
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
- func: _philox_key_fold_in.Tensor(Tensor key, Tensor data) -> Tensor
variants: function
dispatch:
CUDA: _philox_key_fold_in_tensor_cuda

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.

@CuiYifeng @orrangetabby17 please be aware.

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
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
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
…kernels (pytorch#189735)

Original repro in P2415048693.

Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of pytorch#188495.

`FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results.

This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live.

Pull Request resolved: pytorch#189735
Approved by: https://github.com/eellison
ghstack dependencies: pytorch#189767
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
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
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
…kernels (pytorch#189735)

Original repro in P2415048693.

Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of pytorch#188495.

`FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results.

This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live.

Pull Request resolved: pytorch#189735
Approved by: https://github.com/eellison
ghstack dependencies: pytorch#189767
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
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
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
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…kernels (pytorch#189735)

Original repro in P2415048693.

Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of pytorch#188495.

`FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results.

This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live.

Pull Request resolved: pytorch#189735
Approved by: https://github.com/eellison
ghstack dependencies: pytorch#189767
MelindaTan pushed a commit to MelindaTan/pytorch that referenced this pull request Jul 31, 2026
…kernels (pytorch#189735)

Original repro in P2415048693.

Found to affect the `_philox_uniform` / `_philox_normal` ops in practice, which currently utilize `FallbackKernel` and are re-inplaced as of pytorch#188495.

`FallbackKernel` previously did not record that the returned buffer aliases the input for re-inplaced ops. As a result, memory planning treated the input buffer as dead after the op and wrongly reused its storage while the aliasing output was still live, corrupting results.

This PR fixes this by recording the output <-> first-arg alias in `FallbackKernel` so memory planning keeps the buffer live.

Pull Request resolved: pytorch#189735
Approved by: https://github.com/eellison
ghstack dependencies: pytorch#189767
@github-actions
github-actions Bot deleted the gh/jbschlosser/283/head branch August 17, 2026 02:08
pytorchmergebot pushed a commit that referenced this pull request Aug 25, 2026
…e loop (#190036)

Follow-up from #189767 to reduce complexity of `split()` / `fold_in()` kernels. On an H100, this generally results in neutral perf or speedups, with some exceptions:

```
  split()

  ┌─────┬────────────┬─────────────┬────────────┬─────────┐
  │ num │     n      │ before (µs) │ after (µs) │ speedup │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │          1 │        6.63 │       6.51 │  1.02x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │      1,024 │        6.49 │       6.58 │  0.99x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │     16,384 │        6.51 │       6.60 │  0.99x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │     65,536 │        6.50 │       6.68 │  0.97x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │    262,144 │        6.49 │       6.64 │  0.98x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │  1,048,576 │       21.55 │      21.19 │  1.02x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │  4,194,304 │      140.07 │     127.49 │  1.10x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │ 16,777,216 │      533.07 │     492.19 │  1.08x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │          1 │        6.50 │       6.43 │  1.01x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │      1,024 │        6.47 │       6.60 │  0.98x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │     16,384 │        6.55 │       6.52 │  1.00x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │     65,536 │        8.89 │       8.14 │  1.09x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │    262,144 │       40.50 │      33.04 │  1.23x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │  1,048,576 │      183.46 │     182.13 │  1.01x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │  4,194,304 │      953.47 │     975.40 │  0.98x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │          1 │        6.38 │       6.51 │  0.98x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │      1,024 │        6.43 │       6.61 │  0.97x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │     16,384 │       14.32 │      13.95 │  1.03x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │     65,536 │       70.55 │      58.48 │  1.21x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │    262,144 │      299.95 │     241.81 │  1.24x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │  1,048,576 │     1312.20 │    1419.08 │  0.92x  │
  └─────┴────────────┴─────────────┴────────────┴─────────┘

  fold_in()

  ┌─────────┬────────────┬─────────────┬────────────┬─────────┐
  │ variant │     n      │ before (µs) │ after (µs) │ speedup │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │          1 │        7.22 │       6.96 │  1.04x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │      1,024 │        6.93 │       6.91 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │     16,384 │        7.01 │       6.99 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │     65,536 │        6.93 │       6.96 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │    262,144 │        6.93 │       7.02 │  0.99x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │  1,048,576 │        7.63 │       7.04 │  1.09x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │  4,194,304 │       70.33 │      66.66 │  1.06x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │ 16,777,216 │      272.30 │     249.00 │  1.09x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │          1 │        6.98 │       6.58 │  1.06x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │      1,024 │        6.74 │       6.74 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │     16,384 │        6.79 │       6.64 │  1.02x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │     65,536 │        6.68 │       6.61 │  1.01x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │    262,144 │        6.70 │       6.70 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │  1,048,576 │        7.12 │       6.77 │  1.05x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │  4,194,304 │       70.29 │      66.66 │  1.06x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │ 16,777,216 │      272.57 │     248.86 │  1.10x  │
  └─────────┴────────────┴─────────────┴────────────┴─────────┘
```
Pull Request resolved: #190036
Approved by: https://github.com/ngimel
ghstack dependencies: #190253
orrangetabby17 pushed a commit to orrangetabby17/pytorch that referenced this pull request Sep 2, 2026
…e loop (pytorch#190036)

Follow-up from pytorch#189767 to reduce complexity of `split()` / `fold_in()` kernels. On an H100, this generally results in neutral perf or speedups, with some exceptions:

```
  split()

  ┌─────┬────────────┬─────────────┬────────────┬─────────┐
  │ num │     n      │ before (µs) │ after (µs) │ speedup │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │          1 │        6.63 │       6.51 │  1.02x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │      1,024 │        6.49 │       6.58 │  0.99x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │     16,384 │        6.51 │       6.60 │  0.99x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │     65,536 │        6.50 │       6.68 │  0.97x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │    262,144 │        6.49 │       6.64 │  0.98x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │  1,048,576 │       21.55 │      21.19 │  1.02x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │  4,194,304 │      140.07 │     127.49 │  1.10x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 2   │ 16,777,216 │      533.07 │     492.19 │  1.08x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │          1 │        6.50 │       6.43 │  1.01x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │      1,024 │        6.47 │       6.60 │  0.98x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │     16,384 │        6.55 │       6.52 │  1.00x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │     65,536 │        8.89 │       8.14 │  1.09x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │    262,144 │       40.50 │      33.04 │  1.23x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │  1,048,576 │      183.46 │     182.13 │  1.01x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 16  │  4,194,304 │      953.47 │     975.40 │  0.98x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │          1 │        6.38 │       6.51 │  0.98x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │      1,024 │        6.43 │       6.61 │  0.97x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │     16,384 │       14.32 │      13.95 │  1.03x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │     65,536 │       70.55 │      58.48 │  1.21x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │    262,144 │      299.95 │     241.81 │  1.24x  │
  ├─────┼────────────┼─────────────┼────────────┼─────────┤
  │ 128 │  1,048,576 │     1312.20 │    1419.08 │  0.92x  │
  └─────┴────────────┴─────────────┴────────────┴─────────┘

  fold_in()

  ┌─────────┬────────────┬─────────────┬────────────┬─────────┐
  │ variant │     n      │ before (µs) │ after (µs) │ speedup │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │          1 │        7.22 │       6.96 │  1.04x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │      1,024 │        6.93 │       6.91 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │     16,384 │        7.01 │       6.99 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │     65,536 │        6.93 │       6.96 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │    262,144 │        6.93 │       7.02 │  0.99x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │  1,048,576 │        7.63 │       7.04 │  1.09x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │  4,194,304 │       70.33 │      66.66 │  1.06x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ int     │ 16,777,216 │      272.30 │     249.00 │  1.09x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │          1 │        6.98 │       6.58 │  1.06x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │      1,024 │        6.74 │       6.74 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │     16,384 │        6.79 │       6.64 │  1.02x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │     65,536 │        6.68 │       6.61 │  1.01x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │    262,144 │        6.70 │       6.70 │  1.00x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │  1,048,576 │        7.12 │       6.77 │  1.05x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │  4,194,304 │       70.29 │      66.66 │  1.06x  │
  ├─────────┼────────────┼─────────────┼────────────┼─────────┤
  │ tensor  │ 16,777,216 │      272.57 │     248.86 │  1.10x  │
  └─────────┴────────────┴─────────────┴────────────┴─────────┘
```
Pull Request resolved: pytorch#190036
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#190253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request Merged Reverted topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants