KEMBAR78
Add aot_autograd.fx_utils by ezyang · Pull Request #159005 · pytorch/pytorch · GitHub
Skip to content

Conversation

@ezyang
Copy link
Contributor

@ezyang ezyang commented Jul 24, 2025

Stack from ghstack (oldest at bottom):

See docblock for details. The API here has been validated by use
in autoparallel but I'm always open to suggestions for tweaks. One
particular choice I made is to make most of the functions return dicts
by default; this isn't strictly necessary for inputs but it is very
convenient for outputs as the output desc lives on the output node,
not the argument that feeds into the node.

Signed-off-by: Edward Z. Yang ezyang@meta.com

[ghstack-poisoned]
@ezyang ezyang requested a review from bdhirsh as a code owner July 24, 2025 02:10
@pytorch-bot
Copy link

pytorch-bot bot commented Jul 24, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159005

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 378ad97 with merge base ba949c5 (image):

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.

ezyang added 3 commits July 24, 2025 14:34
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Copy link
Contributor

@wconstab wconstab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

)


def _raise_autograd_subclass_not_implemented() -> NoReturn:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: might be nice to pass in the 'name' of the unsupported subclass to include in the RuntimeError (e.g. input vs output node, possibly also the full name of the placeholder).

Also, as it stands the sentence isn't grammatical, "Subclasses are currently not.."

if isinstance(sub_d, SubclassGetAttrAOTOutput):
_raise_autograd_subclass_not_implemented()
output_index[sub_d] = (sub_n, None)
for n in g.nodes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to have a separate loop instead of an elif n.op == 'placeholder"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you need to fully populate the output_index first before you do the other nodes.

if n.op == "placeholder":
desc = n.meta["desc"]
if isinstance(desc, SubclassGetAttrAOTInput):
_raise_fqn_subclass_not_implemented()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, the FQN problem is indeed distinct from the other subclass error above. but doesn't that error also apply here? i guess it doesn't matter which error you return if that's true, so this is also fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is technically a different problem. It is best understood by thinking about what we'd have to do to "fix" the problem. For the autograd problem, you need to define what to do with subclass primals/tangents (which possibly mismatch). For the fqn problem, you need to define what to do if you have a subclass parameter.

A list of FX nodes representing all parameters in the graph.

Raises:
RuntimeError: If subclass tensors are encountered (not yet supported), as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could imagine someone arguing for this function just returning the flat list of parameters. But i'm ok with leaving it raising for now until someone complains

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't understand this comment. Isn't this a flat list of parameter (nodes)? You can't return the parameters, I don't have 'em!

@ezyang ezyang added topic: not user facing topic category ciflow/trunk Trigger trunk jobs on your pull request labels Jul 25, 2025
[ghstack-poisoned]
ezyang added a commit that referenced this pull request Jul 25, 2025
See docblock for details.  The API here has been validated by use
in autoparallel but I'm always open to suggestions for tweaks.  One
particular choice I made is to make most of the functions return dicts
by default; this isn't strictly necessary for inputs but it is very
convenient for outputs as the output desc lives on the output node,
not the argument that feeds into the node.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
ghstack-source-id: 8d200da
Pull-Request: #159005
@albanD albanD removed their request for review July 25, 2025 14:14
[ghstack-poisoned]
ezyang added a commit that referenced this pull request Jul 25, 2025
See docblock for details.  The API here has been validated by use
in autoparallel but I'm always open to suggestions for tweaks.  One
particular choice I made is to make most of the functions return dicts
by default; this isn't strictly necessary for inputs but it is very
convenient for outputs as the output desc lives on the output node,
not the argument that feeds into the node.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
ghstack-source-id: f6d9578
Pull-Request: #159005
@ezyang
Copy link
Contributor Author

ezyang commented Jul 25, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: New commits were pushed while merging. Please rerun the merge command.

Details for Dev Infra team Raised by workflow job

@ezyang
Copy link
Contributor Author

ezyang commented Jul 25, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

yangw-dev pushed a commit that referenced this pull request Aug 1, 2025
See docblock for details.  The API here has been validated by use
in autoparallel but I'm always open to suggestions for tweaks.  One
particular choice I made is to make most of the functions return dicts
by default; this isn't strictly necessary for inputs but it is very
convenient for outputs as the output desc lives on the output node,
not the argument that feeds into the node.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: #159005
Approved by: https://github.com/wconstab
@github-actions github-actions bot deleted the gh/ezyang/3115/head branch August 25, 2025 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants