Skip to content

Add to and contiguous to stable ops#169709

Closed
mikaylagawarecki wants to merge 4 commits intogh/mikaylagawarecki/396/basefrom
gh/mikaylagawarecki/396/head
Closed

Add to and contiguous to stable ops#169709
mikaylagawarecki wants to merge 4 commits intogh/mikaylagawarecki/396/basefrom
gh/mikaylagawarecki/396/head

Conversation

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 5, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 3c28de6 with merge base 5d1459a (image):
💚 Looks good so far! There are no failures yet. 💚

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

mikaylagawarecki added a commit that referenced this pull request Dec 5, 2025
ghstack-source-id: aee6e2e
Pull Request resolved: #169709
mikaylagawarecki added a commit that referenced this pull request Dec 5, 2025
ghstack-source-id: 5dccae7
Pull Request resolved: #169709
@mikaylagawarecki mikaylagawarecki added ciflow/trunk Trigger trunk jobs on your pull request release notes: cpp release notes category labels Dec 5, 2025
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

SGTM

contiguous is also a method on the non-stable Tensor, but we don't add it to stable::Tensor (yet)




[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #169711

contiguous is also a method on the non-stable Tensor, but we don't add it to stable::Tensor (yet)




[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #169711

@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #169711

pytorchmergebot pushed a commit that referenced this pull request Dec 8, 2025
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
contiguous is also a method on the non-stable Tensor, but we don't add it to stable::Tensor (yet)

Pull Request resolved: #169709
Approved by: https://github.com/albanD
ghstack dependencies: #169703
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
pytorchmergebot pushed a commit that referenced this pull request Dec 8, 2025
Pull Request resolved: #168062
Approved by: https://github.com/albanD
ghstack dependencies: #169703, #169709, #169711
pytorchmergebot pushed a commit that referenced this pull request Dec 9, 2025
…ch_call_dispatcher) (#169872)

Scalar's StableIValue conversion is not supported yet.

If we don't land this we can recommend `fill_(empty(...))` instead

Pull Request resolved: #169872
Approved by: https://github.com/albanD
ghstack dependencies: #169703, #169709, #169711, #168062
liangxs pushed a commit to liangxs/pytorch that referenced this pull request Dec 9, 2025
contiguous is also a method on the non-stable Tensor, but we don't add it to stable::Tensor (yet)

Pull Request resolved: pytorch#169709
Approved by: https://github.com/albanD
ghstack dependencies: pytorch#169703
liangxs pushed a commit to liangxs/pytorch that referenced this pull request Dec 9, 2025
liangxs pushed a commit to liangxs/pytorch that referenced this pull request Dec 9, 2025
liangxs pushed a commit to liangxs/pytorch that referenced this pull request Dec 9, 2025
…ch_call_dispatcher) (pytorch#169872)

Scalar's StableIValue conversion is not supported yet.

If we don't land this we can recommend `fill_(empty(...))` instead

Pull Request resolved: pytorch#169872
Approved by: https://github.com/albanD
ghstack dependencies: pytorch#169703, pytorch#169709, pytorch#169711, pytorch#168062
pytorchmergebot pushed a commit that referenced this pull request Dec 9, 2025
From https://github.com/pytorch/audio/blob/main/src/libtorchaudio/stable/ops.h

Technically it should have been ok not to port these but looking at these carefully I realized the subtract ported to audio ~would have undefined behavior :/~ is broken

```
inline Tensor subtract(const Tensor& self, const Tensor& other) {
  const auto num_args = 2;
  std::array<StableIValue, num_args> stack{
      torch::stable::detail::from(self), torch::stable::detail::from(other)};
  TORCH_ERROR_CODE_CHECK(torch_call_dispatcher(
      "aten::subtract", "Tensor", stack.data(), TORCH_ABI_VERSION));
  return torch::stable::detail::to<torch::stable::Tensor>(stack[0]);
}
```

as it missed `alpha` the signature for `subtract.Tensor` is  `func: subtract.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor`. ~This is also our bad as although out of bounds reads on the stableivalue stack would be caught by asan, without asan they are silent correctness issues (PR coming to fix).~

Use the old path to support this as we don't support stableivalue conversion for Scalar yet.

Pull Request resolved: #169880
Approved by: https://github.com/albanD
ghstack dependencies: #169703, #169709, #169711, #168062, #169872
tiendatngcs pushed a commit to tiendatngcs/pytorch-Dec25 that referenced this pull request Dec 9, 2025
ghstack-source-id: 028736d
Pull Request resolved: pytorch/pytorch#169709
skpark-rh pushed a commit to skpark-rh/pytorch that referenced this pull request Dec 10, 2025
contiguous is also a method on the non-stable Tensor, but we don't add it to stable::Tensor (yet)

Pull Request resolved: pytorch#169709
Approved by: https://github.com/albanD
ghstack dependencies: pytorch#169703
skpark-rh pushed a commit to skpark-rh/pytorch that referenced this pull request Dec 10, 2025
skpark-rh pushed a commit to skpark-rh/pytorch that referenced this pull request Dec 10, 2025
skpark-rh pushed a commit to skpark-rh/pytorch that referenced this pull request Dec 10, 2025
…ch_call_dispatcher) (pytorch#169872)

Scalar's StableIValue conversion is not supported yet.

If we don't land this we can recommend `fill_(empty(...))` instead

Pull Request resolved: pytorch#169872
Approved by: https://github.com/albanD
ghstack dependencies: pytorch#169703, pytorch#169709, pytorch#169711, pytorch#168062
skpark-rh pushed a commit to skpark-rh/pytorch that referenced this pull request Dec 10, 2025
…ch#169880)

From https://github.com/pytorch/audio/blob/main/src/libtorchaudio/stable/ops.h

Technically it should have been ok not to port these but looking at these carefully I realized the subtract ported to audio ~would have undefined behavior :/~ is broken

```
inline Tensor subtract(const Tensor& self, const Tensor& other) {
  const auto num_args = 2;
  std::array<StableIValue, num_args> stack{
      torch::stable::detail::from(self), torch::stable::detail::from(other)};
  TORCH_ERROR_CODE_CHECK(torch_call_dispatcher(
      "aten::subtract", "Tensor", stack.data(), TORCH_ABI_VERSION));
  return torch::stable::detail::to<torch::stable::Tensor>(stack[0]);
}
```

as it missed `alpha` the signature for `subtract.Tensor` is  `func: subtract.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor`. ~This is also our bad as although out of bounds reads on the stableivalue stack would be caught by asan, without asan they are silent correctness issues (PR coming to fix).~

Use the old path to support this as we don't support stableivalue conversion for Scalar yet.

Pull Request resolved: pytorch#169880
Approved by: https://github.com/albanD
ghstack dependencies: pytorch#169703, pytorch#169709, pytorch#169711, pytorch#168062, pytorch#169872
@github-actions github-actions bot deleted the gh/mikaylagawarecki/396/head branch January 8, 2026 02:21
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 release notes: cpp release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants