-
Notifications
You must be signed in to change notification settings - Fork 25.7k
New export API with dynamic shape specifications instead of constraints #108448
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
Conversation
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/108448
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit f0fd8a1 with merge base 0735f6c ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Pull Request resolved: #108448 ghstack-source-id: 199529853 @exported-using-ghexport Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/)
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Pull Request resolved: #108448 ghstack-source-id: 200335183 @exported-using-ghexport Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/)
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Pull Request resolved: #108448 ghstack-source-id: 200490523 @exported-using-ghexport Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/)
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Pull Request resolved: #108448 ghstack-source-id: 200541237 @exported-using-ghexport Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/)
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) [ghstack-poisoned]
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
Pull Request resolved: #108448 ghstack-source-id: 200691599 @exported-using-ghexport Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/)
Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
…f constraints" Our experience using `constraints` / `dynamic_dim` with the existing export API has found it to be (subjectively) clunky and (objectively) verbose in common cases. This PR implements a new design for the export API that replaces the use of `constraints` / `dynamic_dim` with a new way of specifying dynamic shapes, involving the following concepts: * a constructor `Dim` for first-class named dynamic dimensions with ranges (similar to `functorch.dim`, and analogous to internal symbolic sizes) * a special value `_` denoting a static dimension * specification mechanisms that use the above, for use either at an export call (`dynamic_shapes`) or on the export function itself (`TensorType`). Design doc: https://docs.google.com/presentation/d/168U7XK72C_WSsZpGESP6Cho9udh193fi0gfjxCNcJ4E/edit#slide=id.p (Meta-only). See docs for these new features in `torch._export`. The existing `torch.export.export` is modified to use the new API, `torch._export.export__RC__`, whenever `constraints=None`. We have not deprecated the existing API yet, but will do in a follow-up. Constraint violation errors arising through use of the new API will now contain suggested fixes using the new API. No longer do we need to report all specializations for static dimensions and suggest all constraints over dynamic dimensions to fix such errors. Instead, due to the redesign, the suggested fixes are much more concise, only involving modifying the definitions of relevant `Dim`s. Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
…f constraints" Our experience using `constraints` / `dynamic_dim` with the existing export API has found it to be (subjectively) clunky and (objectively) verbose in common cases. This PR implements a new design for the export API that replaces the use of `constraints` / `dynamic_dim` with a new way of specifying dynamic shapes, involving the following concepts: * a constructor `Dim` for first-class named dynamic dimensions with ranges (similar to `functorch.dim`, and analogous to internal symbolic sizes) * a mechanism that uses the above in `export` calls to associate inputs to their dynamic shape specifications (`dynamic_shapes`) Design doc: https://docs.google.com/presentation/d/168U7XK72C_WSsZpGESP6Cho9udh193fi0gfjxCNcJ4E/edit#slide=id.p (Meta-only). Note that we only implement Option 1 in that doc. An older version of this PR also implemented Option 3, which is an alternative way of specifying dynamic shapes using tensor type annotations on the exported callable; but we have moved that to future work for now. See docs for these new features in `torch.export`. The existing `torch.export.export` is modified to use the new API, `torch._export.export__RC__`, whenever `constraints=None`. We have not deprecated the existing API yet, but will do in a follow-up. Constraint violation errors arising through use of the new API will now contain suggested fixes using the new API. No longer do we need to report all specializations for static dimensions and suggest all constraints over dynamic dimensions to fix such errors. Instead, due to the redesign, the suggested fixes are much more concise, only involving modifying the definitions of relevant `Dim`s. Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
…f constraints" Our experience using `constraints` / `dynamic_dim` with the existing export API has found it to be (subjectively) clunky and (objectively) verbose in common cases. This PR implements a new design for the export API that replaces the use of `constraints` / `dynamic_dim` with a new way of specifying dynamic shapes, involving the following concepts: * a constructor `Dim` for first-class named dynamic dimensions with ranges (similar to `functorch.dim`, and analogous to internal symbolic sizes) * a mechanism that uses the above in `export` calls to associate inputs to their dynamic shape specifications (`dynamic_shapes`) Design doc: https://docs.google.com/presentation/d/168U7XK72C_WSsZpGESP6Cho9udh193fi0gfjxCNcJ4E/edit#slide=id.p (Meta-only). Note that we only implement Option 1 in that doc. An older version of this PR also implemented Option 3, which is an alternative way of specifying dynamic shapes using tensor type annotations on the exported callable; but we have moved that to future work for now. See docs for these new features in `torch.export`. The existing `torch.export.export` is modified to use the new API, `torch._export.export__RC__`, whenever `constraints=None`. We have not deprecated the existing API yet, but will do in a follow-up. Constraint violation errors arising through use of the new API will now contain suggested fixes using the new API. No longer do we need to report all specializations for static dimensions and suggest all constraints over dynamic dimensions to fix such errors. Instead, due to the redesign, the suggested fixes are much more concise, only involving modifying the definitions of relevant `Dim`s. Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
…f constraints" Our experience using `constraints` / `dynamic_dim` with the existing export API has found it to be (subjectively) clunky and (objectively) verbose in common cases. This PR implements a new design for the export API that replaces the use of `constraints` / `dynamic_dim` with a new way of specifying dynamic shapes, involving the following concepts: * a constructor `Dim` for first-class named dynamic dimensions with ranges (similar to `functorch.dim`, and analogous to internal symbolic sizes) * a mechanism that uses the above in `export` calls to associate inputs to their dynamic shape specifications (`dynamic_shapes`) Design doc: https://docs.google.com/presentation/d/168U7XK72C_WSsZpGESP6Cho9udh193fi0gfjxCNcJ4E/edit#slide=id.p (Meta-only). Note that we only implement Option 1 in that doc. An older version of this PR also implemented Option 3, which is an alternative way of specifying dynamic shapes using tensor type annotations on the exported callable; but we have moved that to future work for now. See docs for these new features in `torch.export`. The existing `torch.export.export` is modified to use the new API, `torch._export.export__RC__`, whenever `constraints=None`. We have not deprecated the existing API yet, but will do in a follow-up. Constraint violation errors arising through use of the new API will now contain suggested fixes using the new API. No longer do we need to report all specializations for static dimensions and suggest all constraints over dynamic dimensions to fix such errors. Instead, due to the redesign, the suggested fixes are much more concise, only involving modifying the definitions of relevant `Dim`s. Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng [ghstack-poisoned]
Pull Request resolved: #108448 ghstack-source-id: 201557160 @exported-using-ghexport Differential Revision: [D48919204](https://our.internmc.facebook.com/intern/diff/D48919204/)
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-focal-rocm5.6-py3.8 / test (default, 1, 3, linux.rocm.gpu) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -f "unrelated CI failure" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary: Following the new dynamic_shapes API (introduced in pytorch#108448), we will also add a dynamic_shapes API to _export.aot_compile Test Plan: CI Reviewed By: gmagogsfm Differential Revision: D49653815
Summary: Following the new dynamic_shapes API (introduced in #108448), we will also add a dynamic_shapes API to _export.aot_compile Test Plan: CI Differential Revision: D49653815 Pull Request resolved: #110101 Approved by: https://github.com/gmagogsfm
Stack from ghstack (oldest at bottom):
Our experience using
constraints/dynamic_dimwith the existing export API has found it to be (subjectively) clunky and (objectively) verbose in common cases.This PR implements a new design for the export API that replaces the use of
constraints/dynamic_dimwith a new way of specifying dynamic shapes, involving the following concepts:Dimfor first-class named dynamic dimensions with ranges (similar tofunctorch.dim, and analogous to internal symbolic sizes)exportcalls to associate inputs to their dynamic shape specifications (dynamic_shapes)Design doc: https://docs.google.com/presentation/d/168U7XK72C_WSsZpGESP6Cho9udh193fi0gfjxCNcJ4E/edit#slide=id.p (Meta-only). Note that we only implement Option 1 in that doc. An older version of this PR also implemented Option 3, which is an alternative way of specifying dynamic shapes using tensor type annotations on the exported callable; but we have moved that to future work for now.
See docs for these new features in
torch.export. The existingtorch.export.exportis modified to use the new API,torch._export.export__RC__, wheneverconstraints=None. We have not deprecated the existing API yet, but will do in a follow-up.Constraint violation errors arising through use of the new API will now contain suggested fixes using the new API. No longer do we need to report all specializations for static dimensions and suggest all constraints over dynamic dimensions to fix such errors. Instead, due to the redesign, the suggested fixes are much more concise, only involving modifying the definitions of relevant
Dims.Differential Revision: D48919204
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng