Skip to content

Conversation

@desertfire
Copy link
Contributor

@desertfire desertfire commented Sep 27, 2024

Stack from ghstack (oldest at bottom):

Summary: In the standalone mode, TORCH_CHECK throws std::runtime_error, instead of c10::Error. The goal is to cut dependency on libtorch. Specifically, AOTI generates CPU code which may call ATen vectorization ops and we need to make sure those ops are self-contained.

Differential Revision: D63911928

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

Summary: Use TORCH_CHECK_STD_ERROR which throws std::runtime_error, instead of using TORCH_CHECK which throws c10::Error, to cut dependency on libtorch. Specifically, Inductor CPU backend may generate cpp code that calls ATen vectorization ops and we need to make sure those ops don't call TORCH_CHECK.

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Sep 27, 2024

🔗 Helpful Links

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

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

✅ No Failures

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

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

@pytorch-bot pytorch-bot bot added the module: cpu CPU specific problem (e.g., perf, algorithm) label Sep 27, 2024
@desertfire desertfire added the topic: not user facing topic category label Sep 27, 2024
Summary: Use TORCH_CHECK_STD_ERROR which throws std::runtime_error, instead of using TORCH_CHECK which throws c10::Error, to cut dependency on libtorch. Specifically, Inductor CPU backend may generate cpp code that calls ATen vectorization ops and we need to make sure those ops don't call TORCH_CHECK.

cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
Summary: Use TORCH_CHECK_STD_ERROR which throws std::runtime_error, instead of using TORCH_CHECK which throws c10::Error, to cut dependency on libtorch. Specifically, Inductor CPU backend may generate cpp code that calls ATen vectorization ops and we need to make sure those ops don't call TORCH_CHECK.

cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
Summary: Use TORCH_CHECK_STD_ERROR which throws std::runtime_error, instead of using TORCH_CHECK which throws c10::Error, to cut dependency on libtorch. Specifically, Inductor CPU backend may generate cpp code that calls ATen vectorization ops and we need to make sure those ops don't call TORCH_CHECK.

cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
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.

I'm a bit surprised by this change. c10::Error gives a lot of niceties like stack traces tracking, internal logging, TORCH_SHOW_CPP_STACKTRACES, etc
Also this is going to change the error we give to the python users?

@desertfire
Copy link
Contributor Author

I'm a bit surprised by this change. c10::Error gives a lot of niceties like stack traces tracking, internal logging, TORCH_SHOW_CPP_STACKTRACES, etc Also this is going to change the error we give to the python users?

I think we have to give up some properties if we want to make Vectorized ABI-compatible. The first attempt I made was to make c10::Error header-only, but it is not easy with something like

// PyTorch-style Error constructor. NB: the implementation of this
// is actually in Logging.cpp
Error(SourceLocation source_location, std::string msg);
. I am open to other suggestion if you have a better idea.

@albanD
Copy link
Collaborator

albanD commented Oct 2, 2024

Making this particular call go through the capi shim should be relatively simple though given the types involved right?

@desertfire
Copy link
Contributor Author

Making this particular call go through the capi shim should be relatively simple though given the types involved right?

If we give up on supporting varargs for this one, then yes.

@albanD
Copy link
Collaborator

albanD commented Oct 2, 2024

Ho we were actually chatting about this one with Jane earlier, wouldn't we be able to do the conversion vararg -> string in a header-only c++ layer and make the raw c api take a single raw string?

@desertfire
Copy link
Contributor Author

AOTI_TORCH_CHECK already does that. I could use that for now, but there will still be a need to make these utility Vectorized implementation self-contained, i.e. libtorch independent.

What about if I define TORCH_CHECK based on a macro, e.g. ABI_COMPATIBLE or LIBTORCH_INDEPENDENT, and only define that macro when Inductor compiles the generated cpp code. That way, the default python build will still use the current TORCH_CHECK, and AOTI still sees those headers as libtorch independent.

Summary: Use TORCH_CHECK_STD_ERROR which throws std::runtime_error, instead of using TORCH_CHECK which throws c10::Error, to cut dependency on libtorch. Specifically, Inductor CPU backend may generate cpp code that calls ATen vectorization ops and we need to make sure those ops don't call TORCH_CHECK.

cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10

[ghstack-poisoned]
Summary: In the standalone mode, TORCH_CHECK throws std::runtime_error, instead of c10::Error. The goal is to cut dependency on libtorch. Specifically, AOTI generates CPU code which may call ATen vectorization ops and we need to make sure those ops are self-contained.

[ghstack-poisoned]
@desertfire desertfire changed the title [AOTI] Add TORCH_CHECK_STD_ERROR [AOTI] Add standalone version of TORCH_CHECK Oct 4, 2024
desertfire added a commit that referenced this pull request Oct 4, 2024
Summary: In the standalone mode, TORCH_CHECK throws std::runtime_error, instead of c10::Error. The goal is to cut dependency on libtorch. Specifically, AOTI generates CPU code which may call ATen vectorization ops and we need to make sure those ops are self-contained.

ghstack-source-id: 5707c8a
Pull Request resolved: #136873
@desertfire desertfire requested a review from albanD October 4, 2024 17:13
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.

Sounds ok as a temporary unblock, let's discuss offline for broader plan and how to ensure this is preserved.

@desertfire
Copy link
Contributor Author

@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@desertfire desertfire requested a review from chenyang78 October 5, 2024 12:46
@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 6, 2024
Summary: In the standalone mode, TORCH_CHECK throws std::runtime_error, instead of c10::Error. The goal is to cut dependency on libtorch. Specifically, AOTI generates CPU code which may call ATen vectorization ops and we need to make sure those ops are self-contained.

Differential Revision: [D63911928](https://our.internmc.facebook.com/intern/diff/D63911928)

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

[ghstack-poisoned]
desertfire added a commit that referenced this pull request Oct 6, 2024
Summary: In the standalone mode, TORCH_CHECK throws std::runtime_error, instead of c10::Error. The goal is to cut dependency on libtorch. Specifically, AOTI generates CPU code which may call ATen vectorization ops and we need to make sure those ops are self-contained.

ghstack-source-id: 91649dd
Pull Request resolved: #136873
@desertfire
Copy link
Contributor Author

@desertfire has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge -f 'Landed internally'

(Initiating merge automatically since Phabricator Diff has merged, using force because this PR might not pass merge_rules.json but landed internally)

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

KnAwnime pushed a commit to KnAwnime/Biblioteka that referenced this pull request Oct 16, 2024
Summary: In the standalone mode, TORCH_CHECK throws std::runtime_error, instead of c10::Error. The goal is to cut dependency on libtorch. Specifically, AOTI generates CPU code which may call ATen vectorization ops and we need to make sure those ops are self-contained.

ghstack-source-id: 6dab1f7
Pull Request resolved: pytorch/pytorch#136873
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 Merged module: cpu CPU specific problem (e.g., perf, algorithm) module: inductor topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants