Skip to content
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

[benchmarks] Initialize moco and TPU experiments on XLA. #7257

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

ysiraichi
Copy link
Collaborator

Fix: #6083

This PR partially fixes moco benchmark by initializing it using the XLA device, instead of its accelerator. Alongside benchmark#2292, this should fix moco for, at least, inference (training should be tested soon).

cc @miladm @JackCaoG @vanbasten23 @zpcore @frgossen

@ysiraichi ysiraichi requested review from frgossen and zpcore June 12, 2024 19:20
device = (
str(self.benchmark_experiment.get_device())
if self.is_accelerator_tpu() else self.benchmark_experiment.accelerator)
if self.should_initialize_on_xla():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remind me why we didn't initialize on CUDA device for GPU experiment before? Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We actually do initialize them on CUDA device (i.e. self.benchmark_experiment.accelerator). The thing is that for moco we have to initialize the benchmark on XLA device (i.e. str(self.benchmark_experiment.get_device())).

# Move the initialized model to XLA device.
if self.benchmark_experiment.xla:
# Move the initialized model to XLA device if it's not there already.
if self.benchmark_experiment.xla and not self.should_initialize_on_xla():
# First, move the model and the inputs to CPU.
# This avoids having dupplicated data on CUDA.
if self.is_accelerator_cuda():
Copy link
Collaborator

Choose a reason for hiding this comment

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

you may want to do a rebase.

@ysiraichi ysiraichi force-pushed the ysiraichi/init-moco-on-xla branch from 5b7f9b7 to 150941d Compare June 17, 2024 22:53
@ysiraichi ysiraichi merged commit abf5c31 into master Jun 18, 2024
23 checks passed
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.

[torchbench] moco fails to run.
3 participants