Skip to content

Add element_size, storage_offset and set_requires_grad to stable Tensor#169703

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

Add element_size, storage_offset and set_requires_grad to stable Tensor#169703
mikaylagawarecki wants to merge 4 commits intogh/mikaylagawarecki/395/basefrom
gh/mikaylagawarecki/395/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/169703

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

⏳ No Failures, 1 Pending

As of commit a0a2ea1 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
@mikaylagawarecki mikaylagawarecki added the ciflow/trunk Trigger trunk jobs on your pull request label Dec 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

Attention! PyTorch one of the C-stable API file was changed

You MUST NOT change existing function declarations in this, as this header defines a stable C ABI. If you need to change the signature for a function, introduce a new v2 version of the function and modify code generation to target the new version of the function.


Caused by:

@mikaylagawarecki mikaylagawarecki added release notes: cpp release notes category topic: new features topic category labels Dec 5, 2025
@mikaylagawarecki mikaylagawarecki marked this pull request as ready for review December 5, 2025 20:30
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

@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
Copy link
Collaborator

Starting merge as part of PR stack under #169711

pytorchmergebot 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
pytorchmergebot pushed a commit that referenced this pull request Dec 8, 2025
JacobSzwejbka 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
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
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
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/395/head branch January 8, 2026 02:20
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 topic: new features topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants