Skip to content

Make kernels methods#3012

Merged
JackCaoG merged 39 commits intomasterfrom
make_kernels_methods
Jul 9, 2021
Merged

Make kernels methods#3012
JackCaoG merged 39 commits intomasterfrom
make_kernels_methods

Conversation

@bdhirsh
Copy link
Copy Markdown
Contributor

@bdhirsh bdhirsh commented Jun 25, 2021

Accompanying pytorch change: pytorch/pytorch#59839

This PR provides better error messages when an XLA kernel has a schema mismatch (compiler error through class method), or is missing entirely (codegen will notice and provide an error).

It's also accompanied by a pytorch-side change that reads in the file containing kernel definitions (aten_xla_type.cpp) and figures out based on the names if any are missing. That way we fully avoid linker errors:

  • If you've implemented all of the right kernels (based on their names), but have incorrect schema, the compiler will give you a nice error message
  • If you've added a new entry in xla_native_functions.yaml, but you're just missing the definition entirely from aten_xla_type.cpp, the codegen can pick up on this and error out early.

Base automatically changed from boxed_cpu_fallback to master June 26, 2021 02:35
@bdhirsh bdhirsh force-pushed the make_kernels_methods branch from 5ba8665 to 288dd03 Compare June 29, 2021 22:28
PT_INC_DIR="$PTDIR/build/aten/src/ATen"
fi

set -e
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The new impl_path argument is to the codegen can read in the kernel signatures and figure out if any are missing.

I also had to add set -e to ensure that the build actually stops if codegen fails, instead of just continuing. Since that would obscure the codegen error and you'd end up with the same linker error. I'm not sure if the original xla codegen suffered from that same issue though.

Copy link
Copy Markdown
Collaborator

@JackCaoG JackCaoG left a comment

Choose a reason for hiding this comment

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

Thanks @bdhirsh , this is very helpful!

bdhirsh added a commit to pytorch/pytorch that referenced this pull request Jul 6, 2021
… better compiler error messages"

Turns external backend kernels into class methods, so they get helpful compiler errors instead of linker errors whenever they're a schema mismatch.

I took a stab at trying to do the same for in-tree kernels, but gave up after a while. It would probably make sense to come back to it with @wenleix 's nice set of regex calls, to automatically pick up all of the native kernels in the `aten/src/ATen/native` folder.

Corresponding xla PR: pytorch/xla#3012


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

[ghstack-poisoned]
bdhirsh added a commit to pytorch/pytorch that referenced this pull request Jul 6, 2021
… error messages"

Turns external backend kernels into class methods, so they get helpful compiler errors instead of linker errors whenever they're a schema mismatch.

I took a stab at trying to do the same for in-tree kernels, but gave up after a while. It would probably make sense to come back to it with @wenleix 's nice set of regex calls, to automatically pick up all of the native kernels in the `aten/src/ATen/native` folder.

Corresponding xla PR: pytorch/xla#3012


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

[ghstack-poisoned]
@bdhirsh bdhirsh force-pushed the make_kernels_methods branch from 8c0cf2f to b0736e8 Compare July 6, 2021 19:01
Copy link
Copy Markdown
Contributor

@ailzhang ailzhang left a comment

Choose a reason for hiding this comment

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

Thanks @bdhirsh !

@JackCaoG
Copy link
Copy Markdown
Collaborator

JackCaoG commented Jul 9, 2021

Merge this to fix #3033

@JackCaoG JackCaoG merged commit d033f8d into master Jul 9, 2021
@JackCaoG JackCaoG deleted the make_kernels_methods branch July 9, 2021 00:36
miladm added a commit that referenced this pull request Jul 9, 2021
miladm added a commit that referenced this pull request Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants