Skip to content

Conversation

@larryliu0820
Copy link
Contributor

This pull request refactors how function pointers for AOTI model container operations are managed and loaded in the CUDA backend. Instead of relying on global/static function pointers, function pointers are now stored per-instance in the AOTIDelegateHandle structure. This change enables safe handling of multiple shared libraries within the same process and improves encapsulation and maintainability.

Refactoring function pointer management:

  • Removed global function pointers for AOTI model container operations from aoti_model_container.cpp and aoti_model_container.h, and moved them into the AOTIDelegateHandle struct as per-instance members. [1] [2] [3]

CUDA backend updates:

  • Updated the CUDA backend (cuda_backend.cpp) to load function pointers into each AOTIDelegateHandle instance using a new load_function_pointers_into_handle method, replacing the previous global symbol registration logic. All calls to model container functions now use the handle's member function pointers. [1] [2] [3] [4] [5]

Build system adjustments:

  • Removed aoti_model_container.cpp from the build targets and library sources, as global function pointer definitions are no longer needed. [1] [2]

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 15, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 6 Pending

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

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

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 15, 2025
@larryliu0820 larryliu0820 marked this pull request as ready for review October 15, 2025 22:02
@larryliu0820 larryliu0820 added the release notes: desktop for desktop/laptop workstream label Oct 15, 2025
Copy link
Contributor

@Gasoonjia Gasoonjia left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for making the container functions nice, safe and clean!

@larryliu0820 larryliu0820 merged commit 2bea318 into main Oct 15, 2025
138 checks passed
@larryliu0820 larryliu0820 deleted the option_2 branch October 15, 2025 23:54
using AOTInductorModelContainerGetInputNameFunc = AOTIRuntimeError (*)(
AOTInductorModelContainerHandle container_handle,
size_t input_idx,
const char** input_name);

// Retrieves the number of constants from the AOTI model container.
// Needed by Metal backend
Copy link
Contributor

Choose a reason for hiding this comment

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

@manuelcandales see if Metal should also save this inside the handle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: desktop for desktop/laptop workstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants