CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 24.7k
handle state tensors in training ir path #137240
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/137240
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 a6338cd with merge base e80f47f ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This pull request was exported from Phabricator. Differential Revision: D63802576 |
9737ee0
to
4fb24de
Compare
This pull request was exported from Phabricator. Differential Revision: D63802576 |
4fb24de
to
f6c61bd
Compare
This pull request was exported from Phabricator. Differential Revision: D63802576 |
f6c61bd
to
38b8fae
Compare
This pull request was exported from Phabricator. Differential Revision: D63802576 |
1 similar comment
This pull request was exported from Phabricator. Differential Revision: D63802576 |
38b8fae
to
603b89b
Compare
torch/export/_trace.py
Outdated
if node.name == name: | ||
add_nodes.append(node) | ||
node.users[output_node] = None | ||
output_node.args = ((*add_nodes, *output_node.args[0]),) |
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.
In training IR, we are following the convention that we don't return mutated buffers. Could we just write it as inplace update?
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.
If the source code has buf = new_value
can we treat it the same as buf.copy_(new_value)
?
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.
I think this is ok as long as metadata etc remains the same (aka shape). I mean when we unlift, we just write them as copy_ anyways... So seems ok? What do you think?
torch/export/_trace.py
Outdated
output_node = None | ||
output_node = list(gm.graph.nodes)[-1] | ||
for buf, name in assigned_buffers.items(): # type: ignore[possibly-undefined] | ||
buffers_to_mutate[name] = buf |
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.
Same here: Can we make it a helper function in aot_autograd and use it here?
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 part is going to be substantially different, adding copy nodes instead of mutating buffer. I'll dedup the other part.
torch/export/_trace.py
Outdated
|
||
assigned_buffers = {} | ||
|
||
def _map_assigned_buffer_to_proxy(_mod, name, buffer): |
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.
Could we make this a util function in aot_autograd.py and use that here? I think this logic also exist in aot_autograd.py?
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.
Mostly true, although there we are seeing buffers as Functional(Fake(...)) and here just Fake(...).
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.
Could we filter out the other parts? What i am worried is this part is bit complicated to understand so it would be better if we have only place to change stuff. Maybe the util function can take what instance we want to assert on lol.
603b89b
to
d8c5687
Compare
This pull request was exported from Phabricator. Differential Revision: D63802576 |
d8c5687
to
9140277
Compare
This pull request was exported from Phabricator. Differential Revision: D63802576 |
Summary: Pull Request resolved: pytorch#137240 We had attribute assignment detection and handling of registered buffer assignments when using `aot_autograd`, but not when using just `make_fx`. Fixed. Test Plan: expanded coverage of `test_state_tensors` to use `export` instead of `torch.export.export` Differential Revision: D63802576
This pull request was exported from Phabricator. Differential Revision: D63802576 |
9140277
to
a6338cd
Compare
@pytorchbot merge -f 'Landed internally' (Initiating merge automatically since Phabricator Diff has merged, using force because this PR might not pass merge_rules.json but landed internally) |
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: We had attribute assignment detection and handling of registered buffer assignments when using
aot_autograd
, but not when using justmake_fx
. Fixed.Test Plan: expanded coverage of
test_state_tensors
to useexport
instead oftorch.export.export
Differential Revision: D63802576