Skip to content
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

[HOO][dynamo] Contextual hints for torch.compile backends #121639

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kbadz-pl
Copy link

@kbadz-pl kbadz-pl commented Mar 11, 2024

Idea:
Described in ticket attached to this PR.

Design proposition:
Implemented hinted_context higher-order-op that allows to specify function, arguments and a hint.

The hint currently is a JSON string that is going to be propagated into all ops within specified function. Such hints can be nested to provide even more structure to the operations. In that case, JSON objects are going to be automatically merged and presented as a string, again.

Hints can be specified in two manners:

  • hints only inside the FWD code, in that scenario hints are going to be visible in FWD only (this is optional path and we can choose to disallow it as explained in the ticket)
  • hints inside autograd overridden ops, in that scenario user can specify hints for FWD and BWD separately (preferred path)

Provided test shows various usages, including nested annotations for both cases above. Each test runs on dummy backend that just prints the hint metadata from the nodes:
image

Fixes #126393

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang

@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label Mar 11, 2024
Copy link

linux-foundation-easycla bot commented Mar 11, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

pytorch-bot bot commented Mar 11, 2024

🔗 Helpful Links

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

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 25012a4 with merge base d94db5f (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link

pytorch-bot bot commented Mar 11, 2024

Please seek CI approval before scheduling CIFlow labels

@ydwu4
Copy link
Contributor

ydwu4 commented Mar 11, 2024

The HOP feature seems useful in certain cases, but it's important to consider the potential uncertainties it could create and handle them carefully in different places. For example, when exporting, we need to serialize and deserialize the metadata, but hints can be of arbitrary type and may not be serializable. Additionally, we need to preserve the hint across transformations to avoid accidentally dropping it during the process, but the correct way of dealing with the hint might depend on the specific transformation and we can never be sure it's always correct because we don't know what kind of hint users can provide us.

Also cc @ezyang @zou3519 @bdhirsh for comments.

@kbadz-pl kbadz-pl marked this pull request as ready for review March 29, 2024 12:59
@kbadz-pl kbadz-pl changed the title [draft][HOO][dynamo] Contextual hints for torch.compile backends [HOO][dynamo] Contextual hints for torch.compile backends Mar 30, 2024
@janeyx99 janeyx99 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Apr 1, 2024
@janeyx99 janeyx99 requested a review from ydwu4 April 1, 2024 16:31
@kbadz-pl
Copy link
Author

Hello @ydwu4 @tugsbayasgalan - any update on the review or additional feedback? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/inductor module: dynamo open source release notes: fx release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allowing topology writer to pass hints to accelerator backends
5 participants