Fix unsafe copies in EXIR and permute transforms#19873
Open
oscarandersson8218 wants to merge 1 commit into
Open
Fix unsafe copies in EXIR and permute transforms#19873oscarandersson8218 wants to merge 1 commit into
oscarandersson8218 wants to merge 1 commit into
Conversation
Replace deepcopy-based copies of shape lists with shallow container copies in paths that can carry torch.SymInt values from fake tensor metadata. This is safe as torch.Size is immutable, so creating a shallow list copy of it is safe: we can insert/delete elements in the new list without affecting the original shape. This fixes symbolic-shape failures in exir.tensor.stride_from_dim_order() and in PostponePermuteOpBelowSqueezeOrUnsqueezeLikeView, where deepcopy() could crash while handling SymInt-backed shapes. The error that was produced: "RuntimeError: Cannot access data pointer of Tensor (e.g. FakeTensor, FunctionalTensor). If you're using torch.compile/export/fx, it is likely that we are erroneously tracing into a custom kernel. To fix this, please wrap the custom kernel into an opaque custom op. Please see the following for details: https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html" Add focused regression coverage for both cases: one test for stride computation with symbolic sizes, and one dynamic-shape edge-graph test for the permute/view transform pass. Signed-off-by: Oscar Andersson <oscar.andersson@arm.com> Change-Id: I4eb2cae7b05f988edee570decb1307a671af4c2a
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19873
Note: Links to docs will display an error until the docs builds have been completed. ❗ 2 Active SEVsThere are 2 currently active SEVs. If your PR is affected, please view them below:
❌ 2 New Failures, 4 Unrelated FailuresAs of commit 8f91cfb with merge base b0441b5 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace deepcopy-based copies of shape lists with shallow container copies in paths that can carry torch.SymInt values from fake tensor metadata. This is safe as torch.Size is immutable, so creating a shallow list copy of it is safe: we can insert/delete elements in the new list without affecting the original shape.
This fixes symbolic-shape failures in exir.tensor.stride_from_dim_order() and in PostponePermuteOpBelowSqueezeOrUnsqueezeLikeView, where deepcopy() could crash while handling SymInt-backed shapes. The error that was produced: "RuntimeError: Cannot access data pointer of Tensor (e.g. FakeTensor, FunctionalTensor). If you're using torch.compile/export/fx, it is likely that we are erroneously tracing into a custom kernel. To fix this, please wrap the custom kernel into an opaque custom op. Please see the following for details:
https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html"
Add focused regression coverage for both cases: one test for stride computation with symbolic sizes, and one dynamic-shape edge-graph test for the permute/view transform pass.
cc @digantdesai @freddan80 @per @zingo @mansnils @Sebastian-Larsson @robell @rascani