Skip to content

Conversation

@alanwaketan
Copy link
Collaborator

Summary:
This pull request makes FSDPv2 to shard on the maximal dim of weights instead of the 0th dim.

Test Plan:
XLA_USE_SPMD=1 PJRT_DEVICE=TPU python test/spmd/test_fsdp_v2.py

@alanwaketan alanwaketan requested review from JackCaoG and jonb377 May 29, 2024 03:29
@alanwaketan alanwaketan self-assigned this May 29, 2024
continue
spmd.mark_sharding(param, mesh, _prepare_spmd_partition_spec(param))
spmd.mark_sharding(
param, mesh, _prepare_spmd_partition_spec(param, shard_maximal=True))
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we make it configureable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, not necessary... It shouldn't matter to the user...

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok I think I get it.. We need to do a all-gather anyway before entering the layer and only one dimension is being sharded.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, that's right. If the 0th dim is like size of 8 (MoE) and we are sharding it on v5p-2048, it will be a disaster.

@alanwaketan alanwaketan force-pushed the alanwaketan/fsdp_maximal branch from 701277f to 9dd39cc Compare May 29, 2024 03:33
@alanwaketan
Copy link
Collaborator Author

Thanks Jack for approving the change.

@alanwaketan
Copy link
Collaborator Author

Skip GPU to move fast.

@alanwaketan alanwaketan merged commit 15fc0f1 into master May 29, 2024
@alanwaketan alanwaketan deleted the alanwaketan/fsdp_maximal branch May 29, 2024 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants