-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[export] runtime asserts for while HOP subgraphs #158467
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/158467
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ You can merge normally! (1 Unrelated Failure)As of commit 88751f4 with merge base c917c63 ( UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
Summary: For #158366, disables unbacked memoization across HOP subgraphs and adds runtime assertions, so asserts stay in their respective graphs Rollback Plan: Differential Revision: D78431075
ffd32f5 to
9fc62c3
Compare
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
1 similar comment
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
Summary: For #158366 - Calls runtime asserts pass for HOP subgraphs (in reenter_make_fx) - For while_loop only (can be expanded), adds disabling unbacked memoization (item, nonzero, unique), to separate runtime asserts in their respective graphs Test Plan: test_export Rollback Plan: Differential Revision: D78431075
9fc62c3 to
3a691ce
Compare
Summary: For #158366 - Calls runtime asserts pass for HOP subgraphs (in reenter_make_fx) - For while_loop only (can be expanded), adds disabling unbacked memoization (item, nonzero, unique), to separate runtime asserts in their respective graphs Test Plan: test_export Rollback Plan: Differential Revision: D78431075
3a691ce to
e0af870
Compare
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
Summary: For #158366 - Calls runtime asserts pass for HOP subgraphs (in reenter_make_fx) - For while_loop only (can be expanded), adds disabling unbacked memoization (item, nonzero, unique), to separate runtime asserts in their respective graphs Test Plan: test_export Rollback Plan: Differential Revision: D78431075
e0af870 to
e621d3b
Compare
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
torch/_dynamo/config.py
Outdated
| _custom_ops_profile: Optional[Any] = None | ||
|
|
||
| # Disable memoization for data-dependent ops like item(), nonzero(), unique() | ||
| disable_unbacked_memo = False |
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.
this probably shouldn't be a dynamo config? Since what we're trying to do is more dynamic shape/hop related.
torch/_subclasses/fake_impls.py
Outdated
| @register_op_impl(torch.ops.aten._local_scalar_dense.default) | ||
| def local_scalar_dense(fake_mode, func, arg): | ||
| if (r := arg.item_memo) is not None: | ||
| if ( |
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.
is the item memo associated with the fake_tensor?
Disabling item_memo may not be what we want e.g. users might be doing something like:
def body_fn(c):
for _ in range(10):
c_val = c.item()
...In this case, we don't want to create an unbacked symint every iteration since they're essentially the same .item().
Summary: For #158366 - Calls runtime asserts pass for HOP subgraphs (in reenter_make_fx) - For while_loop only (can be expanded), clones input tensors for subgraph tracing, so unbacked memos (item, nonzero, etc.) aren't reused Test Plan: test_export Rollback Plan: Differential Revision: D78431075
e621d3b to
c3e82fc
Compare
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
Summary: For #158366 - Calls runtime asserts pass for HOP subgraphs (in reenter_make_fx) - For while_loop only (can be expanded), clones input tensors for subgraph tracing, so unbacked memos (item, nonzero, etc.) aren't reused Test Plan: test_export Rollback Plan: Differential Revision: D78431075
c3e82fc to
351e725
Compare
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
Summary: For #158366 - Calls runtime asserts pass for HOP subgraphs (in reenter_make_fx) - For while_loop only (can be expanded), clones input tensors for subgraph tracing, so unbacked memos (item, nonzero, etc.) aren't reused Test Plan: test_export Rollback Plan: Differential Revision: D78431075
351e725 to
180ae10
Compare
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
Summary: For #158366 - Calls runtime asserts pass for HOP subgraphs (in reenter_make_fx) - For while_loop only (can be expanded), clones input tensors for subgraph tracing, so unbacked memos (item, nonzero, etc.) aren't reused Test Plan: test_export Rollback Plan: Differential Revision: D78431075
180ae10 to
6094c4c
Compare
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
|
A follow up is to make all control flow operators (cond, scan, associative_scan, map) clone the inputs before speculate_subgraph. |
| new_operands_seq = [ | ||
| unspecialize_carried_inputs(tx, carry) for carry in operands_seq | ||
| # clone inputs across subgraphs, to avoid unbacked memoization in fake prop | ||
| cond_operands_seq = [ |
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.
this should be put under with discard_graph_changes(tx):
| ) | ||
| return reenter_make_fx(fn)(*cloned_carried_inputs, *additional_inputs) | ||
|
|
||
| cond_graph = produce_graph(cond_fn) |
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.
put under with disable_proxy_modes_tracing():
Summary: For #158366 - Calls runtime asserts pass for HOP subgraphs (in reenter_make_fx) - For while_loop only (can be expanded), clones input tensors for subgraph tracing, so unbacked memos (item, nonzero, etc.) aren't reused Test Plan: test_export Rollback Plan: Reviewed By: ydwu4 Differential Revision: D78431075
6094c4c to
88751f4
Compare
|
This pull request was exported from Phabricator. Differential Revision: D78431075 |
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
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 |
Differential Revision: D78431075
For #158366
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames @Lucaskabela @zou3519 @ydwu4