Skip to content

Conversation

@shunting314
Copy link
Contributor

@shunting314 shunting314 commented Apr 5, 2022

Stack from ghstack (oldest at bottom):

  • Follow the convention in this doc to setup config for ltc force fallback ops.
  • Pybinds are added to read/set the config.
  • Use the added pybinds in the unit test which needs to force fallbacks.

Test plan:

pytest test/lazy/test_extract_compiled_graph.py

Differential Revision: D35417678

…est_extract_compiled_graph.py

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Apr 5, 2022

🔗 Helpful links

💊 CI failures summary and remediations

As of commit a1d444d (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

…e that in test_extract_compiled_graph.py"



- Follow the convention in [this doc](https://docs.google.com/document/d/1Vi96ITGoK7BW01ZEccexs4pvCQKF4_LdV8w7TfIWPvM/edit) to setup config for ltc force fallback ops. 
- Pybinds are added to read/set the config.
- Use the added pybinds in the unit test which needs to force fallbacks.

Test plan:
```
pytest test/lazy/test_extract_compiled_graph.py
```

[ghstack-poisoned]
try:
yield None
finally:
config.set_force_fallback("")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe better to first do
_orig_force_fallback = config.get_force_fallback()
finally
config.set_force_fallback(_orig_force_fallback)
?

probably unlikely to use multiple values though..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, that's better.

@shunting314
Copy link
Contributor Author

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

namespace torch {
namespace lazy {

std::string& getLTCForceFallback() {
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm thinking of changing the name to fit in with the torch_lazy pattern, but i haven't really thought of what the right name scheme is. i think we should land this first and then we can consider names later. my suggestion might be torch::lazy::get_force_fallback but i wonder what other people think. Should 'config' be a namespace, or any other proposal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both getLTCForceFallback/getForceFallback and get_force_fallback sounds good as long as we are consistent about the flavor.

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.

awesome thanks for following up on this @shunting314 💯

…e that in test_extract_compiled_graph.py"



- Follow the convention in [this doc](https://docs.google.com/document/d/1Vi96ITGoK7BW01ZEccexs4pvCQKF4_LdV8w7TfIWPvM/edit) to setup config for ltc force fallback ops. 
- Pybinds are added to read/set the config.
- Use the added pybinds in the unit test which needs to force fallbacks.

Test plan:
```
pytest test/lazy/test_extract_compiled_graph.py
```

Differential Revision: [D35417678](https://our.internmc.facebook.com/intern/diff/D35417678)

[ghstack-poisoned]
shunting314 added a commit that referenced this pull request Apr 6, 2022
…est_extract_compiled_graph.py

ghstack-source-id: 3f2ca77
Pull Request resolved: #75292
@shunting314
Copy link
Contributor Author

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

facebook-github-bot pushed a commit that referenced this pull request Apr 7, 2022
…est_extract_compiled_graph.py (#75292)

Summary:
Pull Request resolved: #75292

- Follow the convention in [this doc](https://docs.google.com/document/d/1Vi96ITGoK7BW01ZEccexs4pvCQKF4_LdV8w7TfIWPvM/edit) to setup config for ltc force fallback ops.
- Pybinds are added to read/set the config.
- Use the added pybinds in the unit test which needs to force fallbacks.

Test Plan:
```
pytest test/lazy/test_extract_compiled_graph.py
```

Reviewed By: malfet

Differential Revision: D35417678

Pulled By: shunting314

fbshipit-source-id: 1e05b8c831174872d70257a0ddd958863d6ca80d
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2022

Hey @shunting314.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

@facebook-github-bot facebook-github-bot deleted the gh/shunting314/19/head branch April 10, 2022 14:17
@yxd886
Copy link

yxd886 commented Sep 7, 2022

Hello, I am wondering whether there is a way for me to fallback all ops with a flag?

static char* force_str = std::getenv("LTC_FORCE_FALLBACK");
if (force_str != nullptr) {
auto force_str = getLTCForceFallback();
if (!force_str.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@yxd886 this is the code that actually implements the force fallback.

you could modify it to accept a list of ops separated by a comma or something, but currently it only supports a single op, and its both more complex and less efficient to set it up for a long list of many ops.

if you want another mode that just falls back all the time, you could add an env for that and make this function just always return true based on that env.

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