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

[FSDPv2] Move the module to xla device #6525

Merged
merged 2 commits into from
Feb 13, 2024
Merged

Conversation

alanwaketan
Copy link
Collaborator

Summary:
This change allows moving module to the xla device during wrapping such that the caller doesn't need to move the module to the xla device.

Test Plan:
python test/spmd/test_fsdp_v2.py -v -k test_fsdp_v2_cpu_model

Summary:
This change allows moving module to the xla device during wrapping such that
the caller doesn't need to move the module to the xla device.

Test Plan:
python test/spmd/test_fsdp_v2.py -v -k test_fsdp_v2_cpu_model
@alanwaketan alanwaketan self-assigned this Feb 13, 2024
Copy link
Collaborator

@jonb377 jonb377 left a comment

Choose a reason for hiding this comment

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

LGTM!

self._orig_module = module
# Let's move the module to xla device in case it's not moved
# by the caller already.
self._orig_module = module.to(xm.xla_device())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a no-op if the model is already on xla?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think so.

@alanwaketan
Copy link
Collaborator Author

Thanks Jon for the quick review!

@alanwaketan alanwaketan merged commit afc1f0e into master Feb 13, 2024
18 checks passed
@alanwaketan alanwaketan deleted the alanwaketan/fsdp_cpu branch February 13, 2024 19:36
amithrm pushed a commit to amithrm/xla that referenced this pull request Mar 1, 2024
Summary:
This change allows moving module to the xla device during wrapping such that the caller doesn't need to move the module to the xla device.

Test Plan:
python test/spmd/test_fsdp_v2.py -v -k test_fsdp_v2_cpu_model
bhavya01 pushed a commit that referenced this pull request Apr 22, 2024
Summary:
This change allows moving module to the xla device during wrapping such that the caller doesn't need to move the module to the xla device.

Test Plan:
python test/spmd/test_fsdp_v2.py -v -k test_fsdp_v2_cpu_model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants