-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Dynamo+LTC: merging related code from staging branch to master #75044
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
Conversation
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit f98d4f0 (more details on the Dr. CI page):
🕵️ 2 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages
|
| Job | Step | Action |
|---|---|---|
| Run mypy | 🔁 rerun |
This comment was automatically generated by Dr. CI (expand for details).
Please report bugs/suggestions to the (internal) Dr. CI Users group.
|
@shunting314 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
| """Return a unique id of the lazy tensor maintained by LTC""" | ||
| return torch._C._lazy._get_tensor_id(tensor) | ||
|
|
||
| def get_tensors_text(tensors): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if we want to make a _lazy.debug. module for apis like this,
and if we want to rename the APIs
get_tensors_text -> debug.dump_ir(tensors)?
get_tensors_dot -> debug.render_ir_graph(tensors)?
it's easier to land it as-is, i am ok with possibly renaming/moving in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And for get_tensors_backend , rename to debug.dump_ir_backend(tensors) ?
I can do that in a followup PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, sgtm. (or, just make a parameter to debug.dump_ir(tensors, format="text"/"backend")? which is cleaner?
| import torch._C._lazy | ||
| import torch._C._lazy_ts_backend | ||
|
|
||
| def get_tensors_ts_device_data_node(tensors): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think anything that is ts_backend specific should be under the torch._lazy.ts_backend module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about the same thing. The reason I'm putting the method here is we should generalize it for XLA soon. But I'm okay to move this to ts_backend.py before that . Just let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, I think ideally we want it at this level, and it is unclear if we can actually deliver that easily or if it will be a little different for xla. but lets leave it here now and just add some comments explaining the proposal to add xla here, and that this is still 'unstable/prototype'
| """Return the graph hash for the passed in lazy tensors""" | ||
| return torch._C._lazy._get_graph_hash(tensors) | ||
|
|
||
| def run_cached_graph(hash_str, graph_inputs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe for now you can leave this 'run_cached_graph' api under the ts_backend namespace, and later we can consider a generic api at this level if we can make it work for all backends
| print("Fx code:\n", model.code) | ||
| print("LTC IR:", lazy.get_tensors_text(lazy_out)) | ||
|
|
||
| graph_input_tensor_ids, graph_input_ivalues = computation.get_tensors_ts_device_data_node(lazy_out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we leave this file here and leave the ts_backend specific things in it? I think there are 2 alternatives that are not that great
- move this file and all of this related stuff to under _lazy.ts_backend module (to be most correct, even though we want this functionality to be generic later
- or just leave it all like it is now, but add some comments saying we intend to make this file more generic in the future and replace ts_ functions with generic ones in _lazy.computation layer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we anyway need to make things generic to all backends, I would prefer option 2.
| namespace torch { | ||
| namespace lazy { | ||
|
|
||
| struct NoGilSection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to land NoGilSection, can you switch to pybind11::gil_scoped_release no_gil; like mark_step uses?
| @@ -1,3 +1,5 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woah! good catch
ok, no problem. But i'm confused, i never use ghstack but i seem to be able to land PRs that I just directly push. did something change since this morning? |
|
@wconstab I don't know. I just figured that since I'm merging to master, I need follow some doc which says I should use ghstack. Maybe not using ghstack should also work. |
|
ah. you don't have to do it any particular way. you can export from sandcastle to gh, or you can push to gh any way and import to sandcastle. you still have to land via sandcastle either way, until GH first workflow is live. |
Got it. That's good to now. I guess I'm just scared by the red 'Merging is blocked' warning. |
Merge the code needed for dynamic+ltc integration from the staging branch to the master branch.
Test plan:
Unit test
test thru dynamo