Skip to content

[aot] add format_consts_to_cpp function for further development.#157608

Closed
xuhancn wants to merge 12 commits intopytorch:mainfrom
xuhancn:xu_consts_2_cpp
Closed

[aot] add format_consts_to_cpp function for further development.#157608
xuhancn wants to merge 12 commits intopytorch:mainfrom
xuhancn:xu_consts_2_cpp

Conversation

@xuhancn
Copy link
Collaborator

@xuhancn xuhancn commented Jul 4, 2025

Changes:

  1. Split format_consts_to_asm function, which is current way to convert consts to object.
  2. Add format_consts_to_cpp function, which would support for more compiler support, such as msvc and icx.
  3. Add config.aot_inductor.use_consts_asm_build for format_consts_to_asm and format_consts_to_cpp control.
  4. Add UT for format_consts_to_cpp.

For format_consts_to_cpp, I have local tested it:
Case: https://docs.pytorch.org/docs/main/torch.compiler_aot_inductor.html
Run it and cat cpp code:
image

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @voznesenskym @penguinwu @EikanWang @Guobing-Chen @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov

@pytorch-bot
Copy link

pytorch-bot bot commented Jul 4, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit c85dd9a with merge base 64f2ec7 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@xuhancn xuhancn added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category and removed open source labels Jul 4, 2025
@xuhancn xuhancn added the intel This tag is for PR from Intel label Jul 4, 2025
@xuhancn xuhancn changed the title split format_consts_to_asm function. [aot] add format_consts_to_cpp function for further development. Jul 4, 2025
@xuhancn xuhancn marked this pull request as ready for review July 4, 2025 11:05
@xuhancn xuhancn requested a review from desertfire July 4, 2025 11:05
@xuhancn
Copy link
Collaborator Author

xuhancn commented Jul 4, 2025

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased xu_consts_2_cpp onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout xu_consts_2_cpp && git pull --rebase)

@soulitzer soulitzer added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 7, 2025
@xuhancn xuhancn requested a review from jansel July 8, 2025 01:47
Copy link
Contributor

@jansel jansel left a comment

Choose a reason for hiding this comment

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

@desertfire should review this one, but do we need to add a test for this? Or is there an existing test that covers this?

@xuhancn
Copy link
Collaborator Author

xuhancn commented Jul 8, 2025

Thanks for @jansel ‘s comments.
I just add format_consts_to_cpp function but not make it take effect.
I plan to still use format_consts_to_asm as default path, as it is stabled for long time. For format_consts_to_cpp would be a backup path for MSVC and Intel compiler.

Copy link
Contributor

@desertfire desertfire left a comment

Choose a reason for hiding this comment

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

Similar to @jansel 's comment, let's add an aoti_inductor config for this and make sure the new opt-in path is also tested.

@xuhancn
Copy link
Collaborator Author

xuhancn commented Jul 10, 2025

Hi @jansel and @desertfire

I have added aot_config to control asm and cpp build, besides that, I added UT also: 57b6378
Please take a look again.

@xuhancn xuhancn requested review from desertfire and jansel July 10, 2025 06:28
Copy link
Contributor

@desertfire desertfire left a comment

Choose a reason for hiding this comment

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

Please also add a test to test_aot_inductor.py.

@xuhancn
Copy link
Collaborator Author

xuhancn commented Jul 11, 2025

@pytorchmergebot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@xuhancn xuhancn deleted the xu_consts_2_cpp branch July 11, 2025 17:10
pytorchmergebot pushed a commit that referenced this pull request Jul 12, 2025
From the perivous PR: #157608 , I added `format_consts_to_cpp` to build consts bytes.

But it still raise clang ASAN `stack alloction`, when build large size consts.

This PR:
1. add `test_aot_inductor_consts_cpp_build` to stack allocation skip list.
2. add ATTRIBUTE_NO_SANITIZE_ADDRESS to skip ASAN check, because consts array is locate in global area.

Pull Request resolved: #158175
Approved by: https://github.com/jansel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request intel This tag is for PR from Intel Merged module: inductor open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants