functionalization: add a copy() native function#76083
functionalization: add a copy() native function#76083bdhirsh wants to merge 9 commits intogh/bdhirsh/209/basefrom
Conversation
[ghstack-poisoned]
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 34893d8 (more details on the Dr. CI page): Expand to see more
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages
|
[ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
|
@pytorchbot merge this please |
|
Hey @bdhirsh. |
Summary: Pull Request resolved: #76083 Approved by: https://github.com/albanD Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/5da76acd1d8ad1c40f8d58d52a12aa215dbae7ce Reviewed By: osalpekar Differential Revision: D35938186 Pulled By: bdhirsh fbshipit-source-id: 4a93d39088b5944cf4911c9c08feb549ecb72ac3
Right now the functionalization codegen has special logic to handle
copy_(). Instead, in this PR I add anat::copynative function (not exposed to python), and effectively move that logic into C++ and out of the codegen.copy()decomposes intotoandexpand, and it's CompositeImplicitAutograd so it won't appear in traces.One annoying thing - since
copy()decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly becauseat::copy()really just exists for the functionalization pass anyway.Existing tests for
copy_intest_functionalization.pyshould test the change (since the end-result trace is the same).Stack from ghstack: