-
Notifications
You must be signed in to change notification settings - Fork 191
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
avoid .to() followed by inplace mutation to appease export #1387
base: gh/bdhirsh/1/base
Are you sure you want to change the base?
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1387
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 08bbd50 with merge base 8a805d0 (): BROKEN TRUNK - The following job 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. |
ghstack-source-id: b979b7637c8d062b5f5a61c56e1e78edf1b70290 Pull Request resolved: #1387
|
thanks, we can't use ghstack in torchao btw, you can use https://github.com/modularml/stack-pr or just normal |
I'm not sure if changing this would have perf implications actually, probably need to benchmark a bit for the popular code paths |
I think it is better to have |
Related pytorch/pytorch#138606 |
/cc @yushangdi |
Wording of error message to include AOTI package
fyi, @jerryzh168 @bhack , the approach in the PR linked above doesn't work. I'm trying out a new approach, mostly this: if we have a.to(b), and b has a different dtype with a, then it must be a copy. In this case, we do not need to freeze the tensor. Instead, we use torch.ops.aten._assert_tensor_metadata.default to ensure that a must not have the same dtype as b. |
Export currently has a restriction, where inplace mutations on the output of a call to
aten.to()
results in an error.We should really lift this restriction, but in the meantime, this PR avoids hitting that problem in the quantization logic.
I tested by adding the following lines to the bottom of https://github.com/hustvl/ViTMatte/blob/main/modeling%2Fbackbone%2Fvit.py and confirming that export did not error:
Stack from ghstack (oldest at bottom):