Skip to content

Conversation

yanboliang
Copy link
Contributor

@yanboliang yanboliang commented Dec 15, 2023

Make SkipFilesVariable only handle function type, and route skipped classes to UserDefinedClassVariable. The reasons behind this are:

  • We'd like to remove is_allowed, so the allowed/disallowed torch classes should have a proper place to handle. We can put them in either SkipFilesVariable and UserDefinedClassVariable under the current architecture, but it's confusing to have two places do one thing.
    • Going forward, let's make SkipFilesVariable only handle functions, and probably I'll rename it to SkippedFunctionVariable in the following PRs.
    • Let's do dispatch by value's type, all torch classes stuff would go to UserDefinedClassVariable in the next PR.
  • We'd merge in_graph/skip/inline trace decision into the same API trace_rule.lookup, so probably we have to limit the input to only function for better organizing VariableBuilder._wrap logics.
    • Next step, I'll merge skipfiles.check into trace_rules.lookup, and do the skipfile check before wrapping them into correct variable tracker.
    • Though the TorchCtxManagerClassVariable is decided by trace_rules.lookup, I'll refactor it out in the following PRs.

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

Copy link

pytorch-bot bot commented Dec 15, 2023

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit 60f6896 with merge base e3aefe2 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

@yanboliang yanboliang marked this pull request as ready for review December 17, 2023 06:26
value,
(
types.FunctionType,
types.MethodType,
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 think this is typo in my previous PR, general method (non-nn.module) should be wrapped as UserDefinedObjectVariable as the binding object matters.


if self.value is contextlib.nullcontext:
return NullContextVariable()
elif self.value is collections.OrderedDict:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For a lot of logics around collection.OrderedDict in UDC and UDO, we should do further refactor. I think there are two major things we need to figure out:

  • Supporting arbitrary class as dict key - The challenging is how to generate global reference for these classes during installing guard. I was trying to fix this in this PR, but I found it's non-trivial, so I'll leave it as a separate PR. Or probably we only support int/float/str as key, arbitrary classes are not very common cases. If we do this, then many logics are not necessary, as they will be handled in ConstDictVariable.
  • Custom dict support - probably we need to consolidate these code.

@yanboliang
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Dec 18, 2023
@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

@yanboliang yanboliang deleted the dict1 branch December 19, 2023 02:03
@jeanschmidt
Copy link
Contributor

@pytorchbot revert -m "causing significant performance regression, identified by number of ops in ads, please check internal diff" -c nosignal

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot
Copy link
Collaborator

@yanboliang your PR has been successfully reverted.

pytorchmergebot added a commit that referenced this pull request Dec 20, 2023
…5963)"

This reverts commit bb5a270.

Reverted #115963 on behalf of https://github.com/jeanschmidt due to causing significant performance regression, identified by number of ops in ads, please check internal diff ([comment](#115963 (comment)))
@yanboliang yanboliang restored the dict1 branch December 20, 2023 19:35
@yanboliang yanboliang reopened this Dec 20, 2023
@facebook-github-bot
Copy link
Contributor

@yanboliang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@yanboliang
Copy link
Contributor Author

@pytorchbot merge

facebook-github-bot pushed a commit to pytorch/benchmark that referenced this pull request Dec 21, 2023
Summary:
Make ```SkipFilesVariable``` only handle function type, and route skipped classes to ```UserDefinedClassVariable```. The reasons behind this are:
* We'd like to remove ```is_allowed```, so the allowed/disallowed torch classes should have a proper place to handle. We can put them in either ```SkipFilesVariable``` and ```UserDefinedClassVariable``` under the current architecture, but it's  confusing to have two places do one thing.
   - Going forward, let's make ```SkipFilesVariable``` only handle functions, and probably I'll rename it to ```SkippedFunctionVariable``` in the following PRs.
   - Let's do dispatch by value's type, all torch classes stuff would go to ```UserDefinedClassVariable``` in the next PR.
* We'd merge in_graph/skip/inline trace decision into the same API ```trace_rule.lookup```, so probably we have to limit the input to only function for better organizing ```VariableBuilder._wrap``` logics.
   - Next step, I'll merge ```skipfiles.check``` into ```trace_rules.lookup```, and do the skipfile check before wrapping them into correct variable tracker.
   - Though the ```TorchCtxManagerClassVariable``` is decided by ```trace_rules.lookup```, I'll refactor it out in the following PRs.

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

X-link: pytorch/pytorch#115963

Reviewed By: williamwen42

Differential Revision: D52342184

Pulled By: yanboliang

fbshipit-source-id: 1dbc134384bc9bb5139e71796fa3796574c197fe
@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

@yanboliang yanboliang deleted the dict1 branch December 21, 2023 01:41
dmenig pushed a commit to dmenig/pytorch that referenced this pull request Dec 21, 2023
)

Make ```SkipFilesVariable``` only handle function type, and route skipped classes to ```UserDefinedClassVariable```. The reasons behind this are:
* We'd like to remove ```is_allowed```, so the allowed/disallowed torch classes should have a proper place to handle. We can put them in either ```SkipFilesVariable``` and ```UserDefinedClassVariable``` under the current architecture, but it's  confusing to have two places do one thing.
   - Going forward, let's make ```SkipFilesVariable``` only handle functions, and probably I'll rename it to ```SkippedFunctionVariable``` in the following PRs.
   - Let's do dispatch by value's type, all torch classes stuff would go to ```UserDefinedClassVariable``` in the next PR.
* We'd merge in_graph/skip/inline trace decision into the same API ```trace_rule.lookup```, so probably we have to limit the input to only function for better organizing ```VariableBuilder._wrap``` logics.
   - Next step, I'll merge ```skipfiles.check``` into ```trace_rules.lookup```, and do the skipfile check before wrapping them into correct variable tracker.
   - Though the ```TorchCtxManagerClassVariable``` is decided by ```trace_rules.lookup```, I'll refactor it out in the following PRs.

Pull Request resolved: pytorch#115963
Approved by: https://github.com/jansel
dmenig pushed a commit to dmenig/pytorch that referenced this pull request Dec 21, 2023
…orch#115963)"

This reverts commit bb5a270.

Reverted pytorch#115963 on behalf of https://github.com/jeanschmidt due to causing significant performance regression, identified by number of ops in ads, please check internal diff ([comment](pytorch#115963 (comment)))
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.

5 participants