Skip to content
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

Move Lazy Shape Inference functions to pytorch core #72756

Closed
wants to merge 1 commit into from

Conversation

@wconstab
Copy link
Contributor

@wconstab wconstab commented Feb 11, 2022

Test Plan: tested via lazy_tensor_staging branch (test_ptltc operator tests as well as torchbench inference)

Differential Revision: D34187999

@pytorch-bot
Copy link

@pytorch-bot pytorch-bot bot commented Feb 11, 2022

CI Flow Status

⚛️ CI Flow

Ruleset - Version: v1
Ruleset - File: https://github.com/wconstab/pytorch/blob/d39ff769317b5ae6e0f590dba019ff569c9cbbec/.github/generated-ciflow-ruleset.json
PR ciflow labels: ciflow/default
Add ciflow labels to this PR to trigger more builds:

Workflows Labels (bold enabled) Status
Triggered Workflows
linux-binary-conda ciflow/binaries, ciflow/binaries_conda, ciflow/default triggered
linux-binary-libtorch-cxx11-abi ciflow/binaries, ciflow/binaries_libtorch, ciflow/default triggered
linux-binary-libtorch-pre-cxx11 ciflow/binaries, ciflow/binaries_libtorch, ciflow/default triggered
linux-binary-manywheel ciflow/binaries, ciflow/binaries_wheel, ciflow/default triggered
linux-bionic-py3.7-clang9 ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/noarch, ciflow/trunk, ciflow/xla triggered
linux-bionic-rocm4.5-py3.7 ciflow/all, ciflow/default, ciflow/linux, ciflow/rocm, ciflow/trunk triggered
linux-docs ciflow/all, ciflow/cpu, ciflow/default, ciflow/docs, ciflow/linux, ciflow/trunk triggered
linux-vulkan-bionic-py3.7-clang9 ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk, ciflow/vulkan triggered
linux-xenial-cuda11.3-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/default, ciflow/linux, ciflow/trunk triggered
linux-xenial-cuda11.3-py3.7-gcc7-bazel-test ciflow/all, ciflow/bazel, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk triggered
linux-xenial-py3-clang5-mobile-build ciflow/all, ciflow/default, ciflow/linux, ciflow/mobile, ciflow/trunk triggered
linux-xenial-py3-clang5-mobile-custom-build-static ciflow/all, ciflow/default, ciflow/linux, ciflow/mobile, ciflow/trunk triggered
linux-xenial-py3.7-clang7-asan ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/sanitizers, ciflow/trunk triggered
linux-xenial-py3.7-clang7-onnx ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/onnx, ciflow/trunk triggered
linux-xenial-py3.7-gcc5.4 ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk triggered
linux-xenial-py3.7-gcc7 ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk triggered
linux-xenial-py3.7-gcc7-no-ops ciflow/all, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk triggered
macos-arm64-binary-conda ciflow/binaries, ciflow/binaries_conda, ciflow/default triggered
macos-arm64-binary-wheel ciflow/binaries, ciflow/binaries_wheel, ciflow/default triggered
macos-binary-conda ciflow/binaries, ciflow/binaries_conda, ciflow/default triggered
macos-binary-libtorch-cxx11-abi ciflow/binaries, ciflow/binaries_libtorch, ciflow/default triggered
macos-binary-libtorch-pre-cxx11 ciflow/binaries, ciflow/binaries_libtorch, ciflow/default triggered
macos-binary-wheel ciflow/binaries, ciflow/binaries_wheel, ciflow/default triggered
pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single ciflow/all, ciflow/android, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk triggered
pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single-full-jit ciflow/all, ciflow/android, ciflow/cpu, ciflow/default, ciflow/linux, ciflow/trunk triggered
win-vs2019-cpu-py3 ciflow/all, ciflow/cpu, ciflow/default, ciflow/trunk, ciflow/win triggered
win-vs2019-cuda11.3-py3 ciflow/all, ciflow/cuda, ciflow/default, ciflow/trunk, ciflow/win triggered
windows-binary-libtorch-cxx11-abi ciflow/binaries, ciflow/binaries_libtorch, ciflow/default triggered
windows-binary-libtorch-pre-cxx11 ciflow/binaries, ciflow/binaries_libtorch, ciflow/default triggered
windows-binary-wheel ciflow/binaries, ciflow/binaries_wheel, ciflow/default triggered
Skipped Workflows
caffe2-linux-xenial-py3.7-gcc5.4 ciflow/all, ciflow/cpu, ciflow/linux, ciflow/trunk 🚫 skipped
docker-builds ciflow/all, ciflow/trunk 🚫 skipped
ios-12-5-1-arm64 ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
ios-12-5-1-arm64-coreml ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
ios-12-5-1-arm64-custom-ops ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
ios-12-5-1-arm64-full-jit ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
ios-12-5-1-arm64-metal ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
ios-12-5-1-x86-64 ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
ios-12-5-1-x86-64-coreml ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
ios-12-5-1-x86-64-full-jit ciflow/all, ciflow/ios, ciflow/macos, ciflow/trunk 🚫 skipped
libtorch-linux-xenial-cuda10.2-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/libtorch, ciflow/linux, ciflow/trunk 🚫 skipped
libtorch-linux-xenial-cuda11.3-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/libtorch, ciflow/linux, ciflow/trunk 🚫 skipped
linux-bionic-cuda10.2-py3.9-gcc7 ciflow/all, ciflow/cuda, ciflow/linux, ciflow/slow, ciflow/trunk 🚫 skipped
linux-docs-push ciflow/all, ciflow/cpu, ciflow/linux, ciflow/scheduled 🚫 skipped
linux-xenial-cuda11.3-py3.7-gcc7-no-ops ciflow/all, ciflow/cuda, ciflow/linux, ciflow/trunk 🚫 skipped
macos-10-15-py3-arm64 ciflow/all, ciflow/macos, ciflow/trunk 🚫 skipped
macos-10-15-py3-lite-interpreter-x86-64 ciflow/all, ciflow/macos, ciflow/trunk 🚫 skipped
macos-11-py3-x86-64 ciflow/all, ciflow/macos, ciflow/trunk 🚫 skipped
parallelnative-linux-xenial-py3.7-gcc5.4 ciflow/all, ciflow/cpu, ciflow/linux, ciflow/trunk 🚫 skipped
periodic-libtorch-linux-bionic-cuda11.5-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/libtorch, ciflow/linux, ciflow/scheduled 🚫 skipped
periodic-libtorch-linux-xenial-cuda11.1-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/libtorch, ciflow/linux, ciflow/scheduled 🚫 skipped
periodic-linux-bionic-cuda11.5-py3.7-gcc7 ciflow/all, ciflow/cuda, ciflow/linux, ciflow/scheduled 🚫 skipped
periodic-linux-xenial-cuda10.2-py3-gcc7-slow-gradcheck ciflow/all, ciflow/cuda, ciflow/linux, ciflow/scheduled, ciflow/slow, ciflow/slow-gradcheck 🚫 skipped
periodic-linux-xenial-cuda11.1-py3.7-gcc7-debug ciflow/all, ciflow/cuda, ciflow/linux, ciflow/scheduled 🚫 skipped
periodic-win-vs2019-cuda11.1-py3 ciflow/all, ciflow/cuda, ciflow/scheduled, ciflow/win 🚫 skipped
periodic-win-vs2019-cuda11.5-py3 ciflow/all, ciflow/cuda, ciflow/scheduled, ciflow/win 🚫 skipped
pytorch-linux-xenial-py3-clang5-android-ndk-r19c-build ciflow/all, ciflow/android, ciflow/cpu, ciflow/linux, ciflow/trunk 🚫 skipped

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Feb 11, 2022

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 9bb5aae (more details on the Dr. CI page):


  • 3/3 failures introduced in this PR

🕵️ 3 new failures recognized by patterns

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

See GitHub Actions build win-vs2019-cuda11.3-py3 / test (default, 1, 2, windows.8xlarge.nvidia.gpu) (1/3)

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

2022-02-24T05:27:37.8291361Z RuntimeError: CUDA error: an illegal memory access was encountered
2022-02-24T05:27:37.8284072Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\testing\_internal\common_device_type.py", line 376, in instantiated_test
2022-02-24T05:27:37.8285088Z     result = test(self, **param_kwargs)
2022-02-24T05:27:37.8286051Z   File "C:\actions-runner\_work\pytorch\pytorch\build\win_tmp\build\torch\testing\_internal\common_utils.py", line 2950, in wrapped
2022-02-24T05:27:37.8286970Z     f(self, *args, **kwargs, coalesced=True)
2022-02-24T05:27:37.8287639Z   File "test_sparse.py", line 1629, in test_basic_ops
2022-02-24T05:27:37.8288192Z     _test_basic_ops_hybrid()
2022-02-24T05:27:37.8288795Z   File "test_sparse.py", line 1622, in _test_basic_ops_hybrid
2022-02-24T05:27:37.8289516Z     self._test_basic_ops_shape(9, 12, [10, 10, 10], [2, 0], dtype, device, coalesced)
2022-02-24T05:27:37.8290273Z   File "test_sparse.py", line 1541, in _test_basic_ops_shape
2022-02-24T05:27:37.8290764Z     y1 = x1 * x2
2022-02-24T05:27:37.8291361Z RuntimeError: CUDA error: an illegal memory access was encountered
2022-02-24T05:27:37.8293984Z CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
2022-02-24T05:27:37.8295065Z For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
2022-02-24T05:27:37.8295492Z 
2022-02-24T05:27:37.8305735Z ✅ 36848 Passed
2022-02-24T05:27:37.8306193Z 💨 27954 Skipped
2022-02-24T05:27:37.8306579Z 🚨 1 Failed
2022-02-24T05:27:37.9103264Z ##[group]Run .github\scripts\wait_for_ssh_to_drain.ps1
2022-02-24T05:27:37.9104083Z �[36;1m.github\scripts\wait_for_ssh_to_drain.ps1�[0m
2022-02-24T05:27:37.9126739Z shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.EXE -command ". '{0}'"
2022-02-24T05:27:37.9127432Z env:

See GitHub Actions build linux-bionic-rocm4.5-py3.7 / test (default, 2, 2, linux.rocm.gpu) (2/3)

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

2022-02-24T06:47:49.4256680Z RuntimeError: test_sparse failed! Received signal: SIGIOT
2022-02-24T06:47:48.1228476Z test_sparse.py:1567: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
2022-02-24T06:47:48.1230460Z   expected = self.safeToDense(x1) // 37.5
2022-02-24T06:47:48.1429230Z Memory exception on virtual address 0x0, node id 2 : Page not present
2022-02-24T06:47:48.1430397Z Address does not belong to a known buffer
2022-02-24T06:47:48.1432215Z Memory access fault by GPU node-2 (Agent handle: 0x563dce898670) on address (nil). Reason: Page not present or supervisor privilege.
2022-02-24T06:47:48.2950227Z Traceback (most recent call last):
2022-02-24T06:47:48.2951079Z   File "test/run_test.py", line 1106, in <module>
2022-02-24T06:47:48.2955459Z     main()
2022-02-24T06:47:48.2956094Z   File "test/run_test.py", line 1084, in main
2022-02-24T06:47:48.2961802Z     raise RuntimeError(err_message)
2022-02-24T06:47:49.4256680Z RuntimeError: test_sparse failed! Received signal: SIGIOT
2022-02-24T06:47:49.4257253Z 
2022-02-24T06:47:49.4257505Z real	69m32.342s
2022-02-24T06:47:49.4258040Z user	287m37.816s
2022-02-24T06:47:49.4258579Z sys	13m37.881s
2022-02-24T06:47:49.4259076Z + cleanup
2022-02-24T06:47:49.4259592Z + retcode=1
2022-02-24T06:47:49.4260076Z + set +x
2022-02-24T06:47:49.4401041Z ##[error]Process completed with exit code 1.
2022-02-24T06:47:49.4478005Z ##[group]Run python3 -m pip install junitparser==2.1.1 rich==10.9.0
2022-02-24T06:47:49.4478398Z �[36;1mpython3 -m pip install junitparser==2.1.1 rich==10.9.0�[0m

See GitHub Actions build linux-xenial-cuda11.3-py3.7-gcc7 / test (default, 2, 2, linux.4xlarge.nvidia.gpu) (3/3)

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

2022-02-24T02:20:11.4205153Z RuntimeError: CUDA error: an illegal memory access was encountered
2022-02-24T02:20:11.4201555Z   File "/opt/conda/lib/python3.7/site-packages/torch/testing/_internal/common_device_type.py", line 376, in instantiated_test
2022-02-24T02:20:11.4201975Z     result = test(self, **param_kwargs)
2022-02-24T02:20:11.4202555Z   File "/opt/conda/lib/python3.7/site-packages/torch/testing/_internal/common_utils.py", line 2950, in wrapped
2022-02-24T02:20:11.4202972Z     f(self, *args, **kwargs, coalesced=True)
2022-02-24T02:20:11.4203291Z   File "test_sparse.py", line 1629, in test_basic_ops
2022-02-24T02:20:11.4203567Z     _test_basic_ops_hybrid()
2022-02-24T02:20:11.4203876Z   File "test_sparse.py", line 1622, in _test_basic_ops_hybrid
2022-02-24T02:20:11.4204225Z     self._test_basic_ops_shape(9, 12, [10, 10, 10], [2, 0], dtype, device, coalesced)
2022-02-24T02:20:11.4204584Z   File "test_sparse.py", line 1541, in _test_basic_ops_shape
2022-02-24T02:20:11.4204861Z     y1 = x1 * x2
2022-02-24T02:20:11.4205153Z RuntimeError: CUDA error: an illegal memory access was encountered
2022-02-24T02:20:11.4205625Z CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
2022-02-24T02:20:11.4206051Z For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
2022-02-24T02:20:11.4206599Z 		
2022-02-24T02:20:11.4206878Z ✅ 19586 Passed
2022-02-24T02:20:11.4207158Z 💨 6735 Skipped
2022-02-24T02:20:11.4210279Z 🚨 1 Failed
2022-02-24T02:20:11.4672831Z ##[group]Run # Remove any previous test jsons if they exist
2022-02-24T02:20:11.4673254Z �[36;1m# Remove any previous test jsons if they exist�[0m
2022-02-24T02:20:11.4673547Z �[36;1mrm -f test-jsons-*.zip�[0m
2022-02-24T02:20:11.4673877Z �[36;1mzip -r "test-jsons-${FILE_SUFFIX}.zip" test -i '*.json'�[0m

This comment was automatically generated by Dr. CI (expand for details).

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

Click here to manually regenerate this comment.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Feb 11, 2022

This pull request was exported from Phabricator. Differential Revision: D34187999

1 similar comment
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Feb 14, 2022

This pull request was exported from Phabricator. Differential Revision: D34187999

@wconstab wconstab force-pushed the export-D34187999 branch from d39ff76 to 9d7dd6f Feb 14, 2022
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Feb 15, 2022

This pull request was exported from Phabricator. Differential Revision: D34187999

@wconstab wconstab force-pushed the export-D34187999 branch from 9d7dd6f to f0dff06 Feb 15, 2022
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Feb 16, 2022

This pull request was exported from Phabricator. Differential Revision: D34187999

@wconstab wconstab force-pushed the export-D34187999 branch from f0dff06 to 84d8303 Feb 16, 2022
tools/codegen/api/lazy.py Outdated Show resolved Hide resolved
return typ.type == valueT
# I am regretting my naming conventions, but now we are wrapping at::scalar in
# lazy value, while preserving other 'scalar' types as scalars in the IR
return typ.type == valueT or typ.type == scalarT
Copy link
Contributor

@bdhirsh bdhirsh Feb 16, 2022

Choose a reason for hiding this comment

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

I don't totally follow from the comment - can you give a code example?

It also doesn't seem like this really matches the description of the function: "This is equivalent to being Tensor-like", if we directly return true on scalar types.

Copy link
Contributor Author

@wconstab wconstab Feb 16, 2022

Choose a reason for hiding this comment

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

lazy tensor tracing promotes at::Scalars to become lazy tensors. This enables treating the scalars as inputs to the lazy trace and not burning them into the program.

it could use a bit of fresh paint. i think i might want to refactor some of this stuff but probably in a separate PR. I could use your suggestions for that too more generally. but I don't think I want to make too many changes at this PR since it's aiming to just sync up master to what we are already using on staging. Better to develop the new version on staging where we can test it directly. (until we finally finish merging enough to master that we can build/run entirely on master's CI.)

if curr_args is not None:
if isinstance(curr_args, TensorOptionsArguments):
curr_args = curr_args.all()
keyword_arg_types.extend([NamedCType(arg.name, process_ir_type(arg.type)) for arg in curr_args])
Copy link
Contributor

@bdhirsh bdhirsh Feb 16, 2022

Choose a reason for hiding this comment

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

Basic question - it looks like right now, LazyIrSchema has separate fields for positional and keyword arguments. Is that info used meaningfully anywhere?

If not, I think you could simplify a bunch of this logic into something like:

self.keyword_arg_types = [NamedCType(arg.name, process_ir_type(arg.type)) for ag in func.schema_order_arguments()]

That would help you avoid having to special-case TensorOptionsArguments, SelfArgument, and have to explicitly list out the Arguments field names (which I think would cause LTC codegen to break in pretty subtle ways if we changed the names of those fields in core codegen)

Copy link
Contributor Author

@wconstab wconstab Feb 16, 2022

Choose a reason for hiding this comment

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

if you look at lazy_ts_lowering.py you'll see how we generate different code for kw args vs positional args. I couldn't think of a cleaner way at the time but I agree it's a bit complex.

self.keyword_arg_types = tuple(keyword_arg_types)
self.name = func.name
self.returns = func.returns
self.wrapped_scalar_names = [arg.name for arg in func.schema_order_arguments() if isWrappedScalarType(arg.type)]
Copy link
Contributor

@bdhirsh bdhirsh Feb 16, 2022

Choose a reason for hiding this comment

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

Ok, so the LazyIrSchema object knows "what are the C++ types and names of all arguments in my schema", and now it also knows "which of my arguments were originally scalars before processing", using this separate list.

I think the other "data-model-y" option you could take would be to represent that info per-argument using a new type (e.g. a LTCArgument that knows both its NamedCType, and whether it was a scalar argument). The advantage there is that your processing functions (node_ctor_arg_rvalue_string) can run on each argument in isolation, instead of having to take in the whole schema. But if this list is used in a really minimal/targeted way then maybe that's overkill.

Copy link
Contributor Author

@wconstab wconstab Feb 17, 2022

Choose a reason for hiding this comment

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

i think this approach sounds good. generally i think i want to separate out more 'refactoring' to a separate diff. Lets collect ideas for that on a GH issue. i'll make one and link here: #72960


def aten_symbol(schema: LazyIrSchema) -> str:
missing_interned_strings = {
'sigmoid_backward',
Copy link
Contributor

@bdhirsh bdhirsh Feb 16, 2022

Choose a reason for hiding this comment

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

side note: now that this is all in core, should we just add these symbols in core instead of having to handle them specially in codegen?

Copy link
Contributor Author

@wconstab wconstab Feb 16, 2022

Choose a reason for hiding this comment

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

I actually added a handful of symbols to core, and was never sure why i had to do that, and ultimately figured this was a cleaner escape hatch.

if the idea is to have all the symbols be constants in core, should we just make a diff that adds all the symbols at once? otherwise, it's not super clear why we have some and not others...

Copy link
Contributor

@bdhirsh bdhirsh Feb 23, 2022

Choose a reason for hiding this comment

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

I was trying to look into where at::aten::{symbol} is actually defined - do you know where it is?

eter Bell landed some changes recently that I think are meant to codegen all of the aten symbols, so I'm wondering if this probably was basically already solved for you. (I can see sigmoid_backward listed in the codegen'd file build/aten/src/ATen/core/aten_interned_strings.h)

tools/codegen/dest/lazy_ir.py Outdated Show resolved Hide resolved
node_ctor_input_str = node_ctor_inputs(schema)

# Only generate shape/dtype fn for non-structured kernels,
# since we just use the meta function for structured kernels
if not f.structured and f.structured_delegate is None:
shape_sig = ComputeShapeSignature(f)
shape_sig = ComputeShapeSignature(metadata.kernel, f)
Copy link
Contributor

@bdhirsh bdhirsh Feb 16, 2022

Choose a reason for hiding this comment

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

This doesn't seem like a big deal - but any reason why we need to use the metadata.kernel to choose how to name the shape functions? For example, we could do something like f.func.name.unambiguous_name() instead

Copy link
Contributor Author

@wconstab wconstab Feb 16, 2022

Choose a reason for hiding this comment

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

I can't answer off the top of my head. I probably didn't know about unambiguous_name(). I think i needed metadata.kernel to overcome some ambiguity so this may be possible to substitute. I'll have to test it separately (back on staging) and then drop the update in if it works.

Copy link
Contributor Author

@wconstab wconstab Feb 16, 2022

Choose a reason for hiding this comment

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

ok, so here is one case where they differ.

ipdb> p metadata.kernel
'arange_out'
ipdb> p f.func.name.unambiguous_name()
'arange_start_out'

I'm not sure what the right thing to do is.

Copy link
Contributor

@bdhirsh bdhirsh Feb 23, 2022

Choose a reason for hiding this comment

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

leaving for a refactor sounds fine.

I think at a high level, what we probably want to have happen (based on what some of the other codegen in core does), is that the shape signatures are part of some API (the "lazy API", or "lazy shape API") that knows how to generate its name. That way at both the place where you define those functions in the codegen, and at the place where you call those functions, you can use the same api call to generate the name (and you don't have to remember whether or not it was actually using metadata.kernel or f.unambiguous_name().

Copy link
Contributor Author

@wconstab wconstab Feb 23, 2022

Choose a reason for hiding this comment

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

yea that makes sense. i'll reflect that in the other (refactor) issue.

tools/codegen/dest/lazy_ir.py Outdated Show resolved Hide resolved
tools/codegen/dest/lazy_ir.py Outdated Show resolved Hide resolved
tools/codegen/dest/lazy_ir.py Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Feb 17, 2022

This pull request was exported from Phabricator. Differential Revision: D34187999

wconstab added a commit to wconstab/pytorch that referenced this issue Feb 17, 2022
Summary: Pull Request resolved: pytorch#72756

Test Plan: tested via lazy_tensor_staging branch (test_ptltc operator tests as well as torchbench inference)

Differential Revision: D34187999

fbshipit-source-id: 5138fcfbbb3567078f0253881beda3ff4b77fa84
Copy link
Contributor

@bdhirsh bdhirsh left a comment

Approving, since the main purpose of this PR is to true up master with the staging branch and refactors are left as a followup item in #72960

wconstab added a commit to wconstab/pytorch that referenced this issue Feb 23, 2022
Summary: Pull Request resolved: pytorch#72756

Test Plan: tested via lazy_tensor_staging branch (test_ptltc operator tests as well as torchbench inference)

Reviewed By: bdhirsh

Differential Revision: D34187999

fbshipit-source-id: a9d2c2cabe4eb2d921b04e4086181568116190d4
@wconstab wconstab force-pushed the export-D34187999 branch from 5632777 to 3a22785 Feb 23, 2022
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Feb 23, 2022

This pull request was exported from Phabricator. Differential Revision: D34187999

Summary: Pull Request resolved: pytorch#72756

Test Plan: tested via lazy_tensor_staging branch (test_ptltc operator tests as well as torchbench inference)

Reviewed By: bdhirsh

Differential Revision: D34187999

fbshipit-source-id: 0fb6856a111e76408f32de227f3e5dfa2d2eb28c
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Feb 24, 2022

This pull request was exported from Phabricator. Differential Revision: D34187999

@wconstab wconstab force-pushed the export-D34187999 branch from 3a22785 to 9bb5aae Feb 24, 2022
facebook-github-bot added a commit that referenced this issue Feb 24, 2022
Summary: Pull Request resolved: #72756

Test Plan: tested via lazy_tensor_staging branch (test_ptltc operator tests as well as torchbench inference)

Reviewed By: bdhirsh

Differential Revision: D34187999

fbshipit-source-id: f40c5869d573de4a58233ee1e8710f8a0ea7f284
@github-actions
Copy link

@github-actions github-actions bot commented Feb 24, 2022

Hey @wconstab.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants