Skip to content

refactor: move dynamo/TorchXLA bridge to pytorch/xla repo#4476

Merged
JackCaoG merged 1 commit intomasterfrom
dynamo-xla-refactor
Jan 24, 2023
Merged

refactor: move dynamo/TorchXLA bridge to pytorch/xla repo#4476
JackCaoG merged 1 commit intomasterfrom
dynamo-xla-refactor

Conversation

@shunting314
Copy link
Copy Markdown
Collaborator

@shunting314 shunting314 commented Jan 19, 2023

Check the pytorch side PR for details: pytorch/pytorch#92601 .

The pytorch one needs to wait for this one to be merged first.

@shunting314
Copy link
Copy Markdown
Collaborator Author

@JackCaoG should I be worried about the CI break?

  1. for the lint error, it looks like xla/ repo wants 2 spaces indent while pytorch/ repo usually uses 4. I can run some quick 'sed' command to format the code. Or let me know if there is already some script in the repo that can do the job.
  2. the build error seems to be caused by some unrelated network error.

@JackCaoG
Copy link
Copy Markdown
Collaborator

I just restarted the CI, let's see how it goes. I think you also want to update the test under test/dynamo since the bridge is under a new path.

@shunting314
Copy link
Copy Markdown
Collaborator Author

Looks like the exsting tests under test/dynamo does not refer to the bridge directly. They specify the backend by string name which is not affected by the refactoring.

@wconstab
Copy link
Copy Markdown
Collaborator

should I review the code in this PR as if it is just a code move from pytorch/pytorch or is there also some significant change to the code?

@shunting314
Copy link
Copy Markdown
Collaborator Author

@wconstab there is no significant change. Just some code movements and some necessary renames.

@JackCaoG
Copy link
Copy Markdown
Collaborator

Thanks Shutning, I will try to take a look tmr.

Comment thread test/dynamo/test_bridge.py
Comment thread test/dynamo/test_num_output.py
Comment thread torch_xla/csrc/tensor.cpp
Comment thread torch_xla/dynamo_bridge.py
Copy link
Copy Markdown
Collaborator

@JackCaoG JackCaoG left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, thanks Shunting!

Copy link
Copy Markdown
Collaborator

@JackCaoG JackCaoG left a comment

Choose a reason for hiding this comment

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

Let's fix the linter then we can merge this one. Thanks @shunting314 !

@shunting314
Copy link
Copy Markdown
Collaborator Author

@JackCaoG any good way for me to fix the lint errors?
I already fixed a few but what I'm doing right now is too inefficient:
1, check the CI lint error log
2, the CI lint error log only report the first couple of lint errors, so I go ahead to fix them manually
3, go back to 1

How do you guys fix lint errors? Any more efficient ways? (hopefully there is some script to do that locally?)

@JackCaoG
Copy link
Copy Markdown
Collaborator

You can follow https://github.com/pytorch/xla/blob/master/CONTRIBUTING.md#before-submiting-a-pull-request

@JackCaoG
Copy link
Copy Markdown
Collaborator

failure is unrealted, merging

@JackCaoG JackCaoG merged commit 0c9801b into master Jan 24, 2023
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Jan 25, 2023
This is a follow up from the previous PR: #88449 , to move the dynamo/TorchXLA bridge from pytorch repo to xla repo.

Overall the dynamo/TorchXLA integration has the following four layers of code
- pybind layer: This is the bottom layer containing various pybind APIs as the foundation. This part resident in xla repo
- bridge layer: build upon the pybind layer to implement the trace once functionality. This layer and it's corresponding unit test are in pytorch repro previously. This PR (and the corresponding xla pr pytorch/xla#4476 ) moves them to the xla repo.
- dynamo backend registration: this a thin layer registers 4 dynamo backends (training/inference/trace_once/trace_everytime). It remains in pytorch repo.
- benchmark script: the torchbench.py script in dynamo is adapted so it can be used in dynamo/TorchXLA integration. This one remains in pytorch repo.

We think the new code organization is cleaner.

I'll wait for the xla PR in first before trying to merge this one.

Tests
1. run the unit tests moved to the xla repo
2. Test for inference:  `GPU_NUM_DEVICES=1 python benchmarks/dynamo/torchbench.py --randomize-input --performance --trace-on-xla --backend=torchxla_trace_once --only resnet18`
3. Test for training: `GPU_NUM_DEVICES=1 python benchmarks/dynamo/torchbench.py --randomize-input --performance --trace-on-xla --training --backend=aot_torchxla_trace_once --only resnet18 --collect-outputs`

Pull Request resolved: #92601
Approved by: https://github.com/wconstab
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 25, 2026
)

This is a follow up from the previous PR: pytorch#88449 , to move the dynamo/TorchXLA bridge from pytorch repo to xla repo.

Overall the dynamo/TorchXLA integration has the following four layers of code
- pybind layer: This is the bottom layer containing various pybind APIs as the foundation. This part resident in xla repo
- bridge layer: build upon the pybind layer to implement the trace once functionality. This layer and it's corresponding unit test are in pytorch repro previously. This PR (and the corresponding xla pr pytorch/xla#4476 ) moves them to the xla repo.
- dynamo backend registration: this a thin layer registers 4 dynamo backends (training/inference/trace_once/trace_everytime). It remains in pytorch repo.
- benchmark script: the torchbench.py script in dynamo is adapted so it can be used in dynamo/TorchXLA integration. This one remains in pytorch repo.

We think the new code organization is cleaner.

I'll wait for the xla PR in first before trying to merge this one.

Tests
1. run the unit tests moved to the xla repo
2. Test for inference:  `GPU_NUM_DEVICES=1 python benchmarks/dynamo/torchbench.py --randomize-input --performance --trace-on-xla --backend=torchxla_trace_once --only resnet18`
3. Test for training: `GPU_NUM_DEVICES=1 python benchmarks/dynamo/torchbench.py --randomize-input --performance --trace-on-xla --training --backend=aot_torchxla_trace_once --only resnet18 --collect-outputs`

Pull Request resolved: pytorch#92601
Approved by: https://github.com/wconstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants