Skip to content

[TensorExpr] Add IRVerifier. #52901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

ZolotukhinM
Copy link

@ZolotukhinM ZolotukhinM commented Feb 26, 2021

Stack from ghstack:

This PR implements IR Verifier and adds a call to it in LoopNest
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding ::make functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the fact our memory
management works (object was not fully created but was registered in the
kernel arena for destruction anyway).

Fixes #52778.

Differential Revision: D26682928

This PR implements IR Verifier and adds a call to it in `LoopNest`
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding `::make` functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the fact our memory
management works (object was not fully created but was registered in the
kernel arena for destruction anyway).

Fixes #52778.

[ghstack-poisoned]
ZolotukhinM pushed a commit that referenced this pull request Feb 26, 2021
This PR implements IR Verifier and adds a call to it in `LoopNest`
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding `::make` functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the fact our memory
management works (object was not fully created but was registered in the
kernel arena for destruction anyway).

Fixes #52778.

ghstack-source-id: fca2186
Pull Request resolved: #52901
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Feb 26, 2021

💊 CI failures summary and remediations

As of commit 85d3df6 (more details on the Dr. CI page):


  • 2/2 failures possibly* introduced in this PR
    • 1/2 non-scanned failure(s)

🕵️ 1 new failure recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See GitHub Actions build clang-tidy (1/1)

Step: "Add annotations" (full log | diagnosis details | 🔁 rerun)

2021-03-01T22:17:11.0559254Z update-alternatives: error: no alternatives for nsight-sys
2021-03-01T22:17:11.0049154Z Setting up x11proto-damage-dev (1:2018.4-4) ...
2021-03-01T22:17:11.0080299Z Setting up cuda-nvjpeg-10-2 (10.2.89-1) ...
2021-03-01T22:17:11.0150414Z Setting up libxcb-dri3-dev:amd64 (1.13-2~ubuntu18.04) ...
2021-03-01T22:17:11.0184105Z Setting up libcublas10 (10.2.3.254-1) ...
2021-03-01T22:17:11.0218987Z Setting up libcublas-dev (10.2.3.254-1) ...
2021-03-01T22:17:11.0250391Z Setting up cuda-cufft-10-2 (10.2.89-1) ...
2021-03-01T22:17:11.0329547Z Setting up cuda-nsight-compute-10-2 (10.2.89-1) ...
2021-03-01T22:17:11.0361174Z Setting up nsight-systems-2020.4.3 (2020.4.3.7-10543b6) ...
2021-03-01T22:17:11.0466036Z update-alternatives: using /opt/nvidia/nsight-systems/2020.4.3/target-linux-x64/nsys to provide /usr/local/bin/nsys (nsys) in auto mode
2021-03-01T22:17:11.0548645Z update-alternatives: error: alternative path /opt/nvidia/nsight-systems/2020.4.3/host-linux-x64/nsight-sys doesn't exist
2021-03-01T22:17:11.0559254Z update-alternatives: error: no alternatives for nsight-sys
2021-03-01T22:17:11.0613492Z update-alternatives: using /opt/nvidia/nsight-systems/2020.4.3/host-linux-x64/nsys-ui to provide /usr/local/bin/nsys-ui (nsys-ui) in auto mode
2021-03-01T22:17:11.0672646Z Setting up libxcb-shape0-dev:amd64 (1.13-2~ubuntu18.04) ...
2021-03-01T22:17:11.0710122Z Setting up cuda-cusparse-10-2 (10.2.89-1) ...
2021-03-01T22:17:11.0802523Z Setting up cuda-cuobjdump-10-2 (10.2.89-1) ...
2021-03-01T22:17:11.0841349Z Setting up libxcb-glx0-dev:amd64 (1.13-2~ubuntu18.04) ...
2021-03-01T22:17:11.0878132Z Setting up libgles2:amd64 (1.0.0-2ubuntu2.3) ...
2021-03-01T22:17:11.0918209Z Setting up libglu1-mesa:amd64 (9.0.0-2.1build1) ...
2021-03-01T22:17:11.0960774Z Setting up libegl-mesa0:amd64 (20.0.8-0ubuntu1~18.04.1) ...
2021-03-01T22:17:11.1059610Z Setting up cuda-sanitizer-api-10-2 (10.2.89-1) ...
2021-03-01T22:17:11.1148096Z Setting up cuda-nvjpeg-dev-10-2 (10.2.89-1) ...

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Feb 26, 2021
@codecov
Copy link

codecov bot commented Feb 26, 2021

Codecov Report

Merging #52901 (85d3df6) into gh/ZolotukhinM/409/base (a06cf5d) will decrease coverage by 0.00%.
The diff coverage is 86.46%.

@@                     Coverage Diff                     @@
##           gh/ZolotukhinM/409/base   #52901      +/-   ##
===========================================================
- Coverage                    78.01%   78.01%   -0.01%     
===========================================================
  Files                         1848     1849       +1     
  Lines                       179696   179778      +82     
===========================================================
+ Hits                        140198   140255      +57     
- Misses                       39498    39523      +25     

Copy link
Contributor

@navahgar navahgar left a comment

Choose a reason for hiding this comment

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

Looks much better now. Thanks for moving them all together. It will be very useful to run this verifier pass wherever we need it.

How about explicit unit tests for the verifier? If that is going to be a lot of work, we can do that later.

throw unsupported_dtype();
}
if (t->dtype() != f->dtype()) {
if (t.dtype() != f.dtype()) {
throw malformed_input("Bad dtype in IfThenElse");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These have already been moved to the verifier, right? Why do we need them here as well?

Copy link
Author

Choose a reason for hiding this comment

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

I kept them in ::make methods whenever it was possible, since there they don't cause segfaults and will allow to catch the issue earlier.

@ZolotukhinM
Copy link
Author

It will be very useful to run this verifier pass wherever we need it.

Yeah, absolutely agree. In future we might have different verifiers as well (e.g. one that would check that all buffers has Allocate for them - but that could only be run after Allocates had been inserted). I listed some other ideas in #52583.

How about explicit unit tests for the verifier?

They might be useful, let me add some.

This PR implements IR Verifier and adds a call to it in `LoopNest`
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding `::make` functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the fact our memory
management works (object was not fully created but was registered in the
kernel arena for destruction anyway).

Fixes #52778.

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

[ghstack-poisoned]
ZolotukhinM pushed a commit that referenced this pull request Mar 1, 2021
This PR implements IR Verifier and adds a call to it in `LoopNest`
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding `::make` functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the way our memory management
works (object was not fully created but was registered in the kernel
arena for destruction anyway).

Fixes #52778.

ghstack-source-id: 755b513
Pull Request resolved: #52901
This PR implements IR Verifier and adds a call to it in `LoopNest`
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding `::make` functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the fact our memory
management works (object was not fully created but was registered in the
kernel arena for destruction anyway).

Fixes #52778.

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

[ghstack-poisoned]
ZolotukhinM pushed a commit that referenced this pull request Mar 1, 2021
This PR implements IR Verifier and adds a call to it in `LoopNest`
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding `::make` functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the way our memory management
works (object was not fully created but was registered in the kernel
arena for destruction anyway).

Fixes #52778.

ghstack-source-id: 8c99301
Pull Request resolved: #52901
@facebook-github-bot
Copy link
Contributor

@ZolotukhinM merged this pull request in e22da0a.

@facebook-github-bot facebook-github-bot deleted the gh/ZolotukhinM/409/head branch March 5, 2021 15:14
aocsa pushed a commit to Quansight/pytorch that referenced this pull request Mar 15, 2021
Summary:
Pull Request resolved: pytorch#52901

This PR implements IR Verifier and adds a call to it in `LoopNest`
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding `::make` functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the fact our memory
management works (object was not fully created but was registered in the
kernel arena for destruction anyway).

Fixes pytorch#52778.

Test Plan: Imported from OSS

Reviewed By: navahgar

Differential Revision: D26682928

Pulled By: ZolotukhinM

fbshipit-source-id: c56524015cdffb1ed8bce4394509961a4071dcfa
xsacha pushed a commit to xsacha/pytorch that referenced this pull request Mar 31, 2021
Summary:
Pull Request resolved: pytorch#52901

This PR implements IR Verifier and adds a call to it in `LoopNest`
constructors. Checks that were in expr/stmt constructors before are now
moved to the corresponding `::make` functions or to the verifier. They
didn't really help from the constructors anyway since an exception
thrown from there led to a segfault due to the fact our memory
management works (object was not fully created but was registered in the
kernel arena for destruction anyway).

Fixes pytorch#52778.

Test Plan: Imported from OSS

Reviewed By: navahgar

Differential Revision: D26682928

Pulled By: ZolotukhinM

fbshipit-source-id: c56524015cdffb1ed8bce4394509961a4071dcfa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants