-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[HOP] Rework Autograd DispatchKey for scan and map #153336
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
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/153336
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit 9f9adc1 with merge base 47df195 ( NEW FAILURE - The following job has failed:
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. |
@pytorchbot label "topic: not user facing" |
# outs = f(xs, *args) | ||
# if pytree.tree_any(lambda elem: not isinstance(elem, torch.Tensor) if elem is not None else False, outs): | ||
# raise RuntimeError( | ||
# "Expect outputs of map only contains tensors or None. " | ||
# f"Got types {[type(out) for out in pytree.tree_leaves(outs)]}." | ||
# ) | ||
# return outs | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using the new key @map_impl.py_autograd_impl
, the map_dense
gets triggered directly and thus create_fw_bw_graph
is not used. Therefore, the check of the outputs in create_fw_bw_graph
is also not performed and the check can either be done here or below (see comment)
outs_flatten = pytree.tree_leaves(pytrees) | ||
if any( | ||
# pytree.tree_map(lambda elem: not isinstance(elem, torch.Tensor), outs) | ||
not isinstance(out, torch.Tensor) for out in outs_flatten if out is not None | ||
): | ||
raise RuntimeError( | ||
"Expect outputs of map only contains tensors or None. " | ||
f"Got types {[type(out) for out in outs_flatten]}." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or here.
Which option would be preferable?
This PR introduces the
py_autograd_impl
instead of theDispatchKey.Autograd
for some HOPs.cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames