Skip to content

Conversation

@mikaylagawarecki
Copy link
Contributor

@mikaylagawarecki mikaylagawarecki commented Oct 28, 2025

Move from_ivalue and to_ivalue and their dependents StableIValueBoxedKernel, aoti_torch_library_impl aoti_torch_call_dispatcher into new (non-aoti shim_common.cpp)

This is in prep for the above PRs where I add v2s (torch_call_dispatcher and torch_library_impl) that are versioning aware

Stack from ghstack (oldest at bottom):

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 28, 2025

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit 3541c2f with merge base 4295a9a (image):
💚 Looks good so far! There are no failures yet. 💚

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

@mikaylagawarecki mikaylagawarecki marked this pull request as ready for review October 28, 2025 17:40
"torch/csrc/inductor/aoti_torch/oss_proxy_executor.cpp",
"torch/csrc/inductor/inductor_ops.cpp",
"torch/csrc/jit/serialization/pickle.cpp",
"torch/csrc/shim_common.cpp",
Copy link
Contributor

Choose a reason for hiding this comment

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

should this actually go in core_sources_common? or core_sources_full instead? since this doesn't have to do with inductor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had put it in core_sources_common previously and imported, but that caused all the mobile builds to fail

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmmmmmmmmmmmmmmmmmmmmmmm.

i think it may be important to figure out why that is 😛 otherwise this is a bit weird why it needs to be in inductor.

Copy link
Contributor Author

@mikaylagawarecki mikaylagawarecki Oct 28, 2025

Choose a reason for hiding this comment

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

I think the reason why is that this file includes the aoti shim (whose cpp file is only in the inductor sources)

So if we put this in core_sources_common, it would be included by the mobile builds (specifically this line), but then the aoti shim would be excluded

Separately, this new shim_common.cpp now implements some of aoti's shim.h, so I believe it's needed here

if(USE_LITE_AOTI)
append_filelist("inductor_core_resources" LIBTORCH_CMAKE_SRCS)
endif()

Copy link
Contributor

Choose a reason for hiding this comment

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

Still not sure I fully understand if this is the right move, but given that it seems ok + that this is undoable, I am approving.

Copy link
Contributor

@janeyx99 janeyx99 left a comment

Choose a reason for hiding this comment

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

looks fine to me, barring two questions

Move `from_ivalue` and `to_ivalue` and their dependents `StableIValueBoxedKernel`, `aoti_torch_library_impl` `aoti_torch_call_dispatcher` into new (non-aoti shim_common.cpp)

This is in prep for the above PRs where I add v2s (`torch_call_dispatcher` and `torch_library_impl`) that are versioning aware




[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #164332

pytorchmergebot pushed a commit that referenced this pull request Oct 29, 2025
…63683)

Part 1 of plan in https://docs.google.com/document/d/1MaX51H5aEQE5XnOlnZIpf9oCYwzGrTWkgBACxNzsmWE/edit?usp=sharing

- Upgrade `aoti_torch_call_dispatcher` to v2 with an `extension_build_version`
- Allow registration of StableIValue stack  --> IValue stack adapters for schema changes

#### Note: This PR does not include a linter that tells the user to add the upgrader if the schema changes, which is an important piece that will be added in a separate PR

Pull Request resolved: #163683
Approved by: https://github.com/janeyx99
ghstack dependencies: #164356, #166373
pytorchmergebot pushed a commit that referenced this pull request Oct 29, 2025
1. Add `extension_build_version` and `is_internal` to `FromImpl`/`ToImpl` (this will be useful for future if we need to break the BC of any type) #163832 has the PoC of how we would actually use this system
2. Add `aoti_torch_library_impl_v2` that takes in an additional `extension_build_version` argument, updates callsite in `torch/csrc/stable/library.h` to always pass `TORCH_ABI_VERSION` for this argument
3. Add `extension_build_version` to `from_ivalue` and `to_ivalue` and update all callsites
4. Add a private `_from` and `_to` that pass `is_internal=True` to `FromImpl`/`ToImpl`, making it easier to reason about what is being called from libtorch-land / extension-land

**Note: This PR does not include a linter that tells the user to update from/to if changing the ABI of a type in headeronly, which I intend to do in #163998

Pull Request resolved: #164332
Approved by: https://github.com/janeyx99
ghstack dependencies: #164356, #166373, #163683
mikaylagawarecki added a commit to mikaylagawarecki/pytorch that referenced this pull request Oct 29, 2025
BoyuanFeng pushed a commit that referenced this pull request Oct 31, 2025
Move `from_ivalue` and `to_ivalue` and their dependents `StableIValueBoxedKernel`, `aoti_torch_library_impl` `aoti_torch_call_dispatcher` into new (non-aoti shim_common.cpp)

This is in prep for the above PRs where I add v2s (`torch_call_dispatcher` and `torch_library_impl`) that are versioning aware

Pull Request resolved: #166373
Approved by: https://github.com/janeyx99
ghstack dependencies: #164356
BoyuanFeng pushed a commit that referenced this pull request Oct 31, 2025
…63683)

Part 1 of plan in https://docs.google.com/document/d/1MaX51H5aEQE5XnOlnZIpf9oCYwzGrTWkgBACxNzsmWE/edit?usp=sharing

- Upgrade `aoti_torch_call_dispatcher` to v2 with an `extension_build_version`
- Allow registration of StableIValue stack  --> IValue stack adapters for schema changes

#### Note: This PR does not include a linter that tells the user to add the upgrader if the schema changes, which is an important piece that will be added in a separate PR

Pull Request resolved: #163683
Approved by: https://github.com/janeyx99
ghstack dependencies: #164356, #166373
BoyuanFeng pushed a commit that referenced this pull request Oct 31, 2025
1. Add `extension_build_version` and `is_internal` to `FromImpl`/`ToImpl` (this will be useful for future if we need to break the BC of any type) #163832 has the PoC of how we would actually use this system
2. Add `aoti_torch_library_impl_v2` that takes in an additional `extension_build_version` argument, updates callsite in `torch/csrc/stable/library.h` to always pass `TORCH_ABI_VERSION` for this argument
3. Add `extension_build_version` to `from_ivalue` and `to_ivalue` and update all callsites
4. Add a private `_from` and `_to` that pass `is_internal=True` to `FromImpl`/`ToImpl`, making it easier to reason about what is being called from libtorch-land / extension-land

**Note: This PR does not include a linter that tells the user to update from/to if changing the ABI of a type in headeronly, which I intend to do in #163998

Pull Request resolved: #164332
Approved by: https://github.com/janeyx99
ghstack dependencies: #164356, #166373, #163683
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants