Skip to content

[nativert] Move Graph to pytorch core#153994

Closed
yiming0416 wants to merge 1 commit intopytorch:mainfrom
yiming0416:export-D74749418
Closed

[nativert] Move Graph to pytorch core#153994
yiming0416 wants to merge 1 commit intopytorch:mainfrom
yiming0416:export-D74749418

Conversation

@yiming0416
Copy link
Contributor

@yiming0416 yiming0416 commented May 20, 2025

Summary:
Torch Native Runtime RFC: pytorch/rfcs#72

4 classes have been introduced: Graph, Node, Value, Type

  • Type represents the kind of a Value
  • Value represents a single symbolic value, it could be any kind that exists in Type. Values are inputs and outputs of a Node.
  • Node represents a single unit of execution, typically a PyTorch op.
  • Graph represents a model's computation graph, which is designed to facilitate transformation/analysis.

Test Plan: Added test under test/cpp/nativert/test_graph.cpp

Differential Revision: D74749418

@pytorch-bot
Copy link

pytorch-bot bot commented May 20, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Unrelated Failure

As of commit 11332f6 with merge base 6706751 (image):

NEW FAILURE - The following job has failed:

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.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

Copy link
Collaborator

@Skylion007 Skylion007 left a comment

Choose a reason for hiding this comment

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

lots of performance nits here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Beware of signed char, most of these helpers only take unsigned char

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@yiming0416 yiming0416 changed the title [WIP][nativert] Move Graph to pytorch core [nativert] Move Graph to pytorch core May 21, 2025
@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 21, 2025
@yiming0416 yiming0416 removed the ciflow/trunk Trigger trunk jobs on your pull request label May 21, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@zhxchen17 zhxchen17 requested a review from swolchok May 22, 2025 14:53
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@yiming0416
Copy link
Contributor Author

yiming0416 commented May 28, 2025

how important is efficiency for this code? I'm worried about it, but maybe it's known not to matter?

@swolchok Thank you for all the comments and suggestions! At this point, our primary focus and top priority is on getting this open-sourced, and there are other ongoing efforts to improve efficiency in other parts of the runtime.
I've addressed most of your comments. If possible, I'd like to defer a few of the remaining points to follow-up tasks.

@yiming0416 yiming0416 requested a review from swolchok May 28, 2025 23:33
@dolpm dolpm closed this May 29, 2025
@dolpm dolpm reopened this May 29, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

Summary:
Pull Request resolved: pytorch#153994

Move Graph to pytorch core.

Test Plan: buck2 test mode/opt caffe2/test/cpp/nativert:graph_test

Differential Revision: D74749418
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74749418

Comment on lines +42 to +44
explicit Type(Kind kind, const std::string& classFqn)
: kind_(CustomObjData{classFqn}) {
TORCH_CHECK(kind == Kind::CustomObj);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why you need to pass kind argument if it's unsued

Suggested change
explicit Type(Kind kind, const std::string& classFqn)
: kind_(CustomObjData{classFqn}) {
TORCH_CHECK(kind == Kind::CustomObj);
explicit Type(const std::string& classFqn)
: kind_(CustomObjData{classFqn}) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@malfet Here we want to increase the readability when people calling the constructor of Type explicitly to ensure only CustomObj can be passed in.

@yiming0416 yiming0416 requested a review from malfet June 2, 2025 20:10
@yiming0416
Copy link
Contributor Author

splitting this PR into smaller ones. see stack #154532

@swolchok
Copy link
Contributor

swolchok commented Jun 3, 2025

splitting this PR into smaller ones. see stack #154532

do you need to close this one then?

@yiming0416 yiming0416 closed this Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants