Skip to content

Overload _get_operation_for_overload_or_packet & friends to accept ArrayRef#162219

Closed
swolchok wants to merge 4 commits intogh/swolchok/827/basefrom
gh/swolchok/827/head
Closed

Overload _get_operation_for_overload_or_packet & friends to accept ArrayRef#162219
swolchok wants to merge 4 commits intogh/swolchok/827/basefrom
gh/swolchok/827/head

Conversation

…rayRef

Avoids requiring vector allocation to call this.

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Sep 4, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit d5990af with merge base 2b8a839 (image):
💚 Looks good so far! There are no failures yet. 💚

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

op, symbol, args, kwargs, /*is_overload*/ true, dk_);
});
return py::make_tuple(
func, func_dk, py::cast(op->getTags().vec()));
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.

These values should be std::move to prevent ref count increases

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.

I don't see anything movable here; if we move op from the lambda capture then the lambda won't work if called a second time.

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.

This just moves the Python reference to the cpp_function pybind11 object. Isn't that reference created every time?

This just avoid a pointer inc / decrease of the Python reference counter, it shouldn't move the function inside of the Python function since it's effectively a shared ptr, right?

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.

To clarify, suggesting moving func and func_dk

…o accept ArrayRef"

Avoids requiring vector allocation to call this.

cc EikanWang jgong5 wenzhe-nrv sanchitintel

[ghstack-poisoned]
…o accept ArrayRef"

Avoids requiring vector allocation to call this.

cc EikanWang jgong5 wenzhe-nrv sanchitintel

[ghstack-poisoned]
…o accept ArrayRef"

Avoids requiring vector allocation to call this.

cc EikanWang jgong5 wenzhe-nrv sanchitintel

[ghstack-poisoned]
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #162220

swolchok added a commit that referenced this pull request Sep 8, 2025
Per Skylion007 on #162219


ghstack-source-id: 00ea4c1
Pull-Request: #162428
swolchok added a commit that referenced this pull request Sep 8, 2025
Per Skylion007 on #162219

ghstack-source-id: de3fd28
Pull-Request: #162428
pytorchmergebot pushed a commit that referenced this pull request Sep 9, 2025
pytorchmergebot pushed a commit that referenced this pull request Sep 10, 2025
…2218)

It returns a const reference to a vector.

Pull Request resolved: #162218
Approved by: https://github.com/Skylion007
ghstack dependencies: #161591, #161595, #161633, #161634, #161692, #162219, #162220
pytorchmergebot pushed a commit that referenced this pull request Sep 11, 2025
These seem to have been costing us 5-10 usec per detach (out of ~~95 usec total).  If they need to ship let's talk about requirements and how we can make this more efficient given that we would prefer if an entire DTensor op could finish in 10 usec.

Differential Revision: [D81530106](https://our.internmc.facebook.com/intern/diff/D81530106)
Pull Request resolved: #161596
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: #161591, #161595, #161633, #161634, #161692, #162219, #162220, #162218
pytorchmergebot pushed a commit that referenced this pull request Sep 11, 2025
We control DTensor, so we can just guarantee there isn't a programming error with __torch_dispatch__. (The guard is already less-than-perfect; see the note that the deleted comment refers to.)
Pull Request resolved: #162337
Approved by: https://github.com/Skylion007
ghstack dependencies: #161591, #161595, #161633, #161634, #161692, #162219, #162220, #162218, #161596
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
Optimize for common case and remove a pair of refcount operations (see new comments.)

Pull Request resolved: pytorch#162220
Approved by: https://github.com/jansel, https://github.com/williamwen42
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
These seem to have been costing us 5-10 usec per detach (out of ~~95 usec total).  If they need to ship let's talk about requirements and how we can make this more efficient given that we would prefer if an entire DTensor op could finish in 10 usec.

Differential Revision: [D81530106](https://our.internmc.facebook.com/intern/diff/D81530106)
Pull Request resolved: pytorch#161596
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219, pytorch#162220, pytorch#162218
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
…162337)

We control DTensor, so we can just guarantee there isn't a programming error with __torch_dispatch__. (The guard is already less-than-perfect; see the note that the deleted comment refers to.)
Pull Request resolved: pytorch#162337
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219, pytorch#162220, pytorch#162218, pytorch#161596
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
Optimize for common case and remove a pair of refcount operations (see new comments.)

Pull Request resolved: pytorch#162220
Approved by: https://github.com/jansel, https://github.com/williamwen42
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
These seem to have been costing us 5-10 usec per detach (out of ~~95 usec total).  If they need to ship let's talk about requirements and how we can make this more efficient given that we would prefer if an entire DTensor op could finish in 10 usec.

Differential Revision: [D81530106](https://our.internmc.facebook.com/intern/diff/D81530106)
Pull Request resolved: pytorch#161596
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219, pytorch#162220, pytorch#162218
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
…162337)

We control DTensor, so we can just guarantee there isn't a programming error with __torch_dispatch__. (The guard is already less-than-perfect; see the note that the deleted comment refers to.)
Pull Request resolved: pytorch#162337
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219, pytorch#162220, pytorch#162218, pytorch#161596
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
Optimize for common case and remove a pair of refcount operations (see new comments.)

Pull Request resolved: pytorch#162220
Approved by: https://github.com/jansel, https://github.com/williamwen42
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
These seem to have been costing us 5-10 usec per detach (out of ~~95 usec total).  If they need to ship let's talk about requirements and how we can make this more efficient given that we would prefer if an entire DTensor op could finish in 10 usec.

Differential Revision: [D81530106](https://our.internmc.facebook.com/intern/diff/D81530106)
Pull Request resolved: pytorch#161596
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219, pytorch#162220, pytorch#162218
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
…162337)

We control DTensor, so we can just guarantee there isn't a programming error with __torch_dispatch__. (The guard is already less-than-perfect; see the note that the deleted comment refers to.)
Pull Request resolved: pytorch#162337
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219, pytorch#162220, pytorch#162218, pytorch#161596
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
Optimize for common case and remove a pair of refcount operations (see new comments.)

Pull Request resolved: pytorch#162220
Approved by: https://github.com/jansel, https://github.com/williamwen42
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
These seem to have been costing us 5-10 usec per detach (out of ~~95 usec total).  If they need to ship let's talk about requirements and how we can make this more efficient given that we would prefer if an entire DTensor op could finish in 10 usec.

Differential Revision: [D81530106](https://our.internmc.facebook.com/intern/diff/D81530106)
Pull Request resolved: pytorch#161596
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219, pytorch#162220, pytorch#162218
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
…162337)

We control DTensor, so we can just guarantee there isn't a programming error with __torch_dispatch__. (The guard is already less-than-perfect; see the note that the deleted comment refers to.)
Pull Request resolved: pytorch#162337
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#161591, pytorch#161595, pytorch#161633, pytorch#161634, pytorch#161692, pytorch#162219, pytorch#162220, pytorch#162218, pytorch#161596
@github-actions github-actions Bot deleted the gh/swolchok/827/head branch October 9, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue release notes: jit release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants