Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adopt KeyPath API in nonstrict mode (#1669)
Summary: Pull Request resolved: #1669 X-link: pytorch/pytorch#118609 This PR rewrites two paths to use the newly-added keypaths API in pytree: First: we were hand-rolling a tree_map during fakification because we wanted to track sources. This PR uses keypaths instead, which can do the same thing without needing custom code. Second: our constraint error formatting was referencing placeholder names in error messages. These placeholder names are not otherwise user-visible, so they are super confusing to users (e.g. "which input does arg1_3 correspond to?"). This diff uses the `keystr` API to format the error message. This necessitated some small refactors—generating the keystr is expensive so doing it in an f-string was very bad. It can also be further improved—we can inspect the signature so that instead of `*args[0]` we can give people the actual argument name, which would be the ideal UX. But leaving that for later. ghstack-source-id: 213477246 exported-using-ghexport bypass-github-pytorch-ci-checks Reviewed By: avikchaudhuri, zhxchen17 Differential Revision: D53139358 fbshipit-source-id: de43133060eaf9de1fd61aaba6dd712c6183daa0
- Loading branch information