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

[autoparallel]add embedding handler #2089

Merged

Conversation

YuliangLiu0306
Copy link
Contributor

@YuliangLiu0306 YuliangLiu0306 commented Dec 6, 2022

What does this PR do

  1. This PR introduces embedding handler to generator valid strategies for embedding handler.
  2. Construct unit test to check the numerical correctness.

What need we do in future

  1. The computation cost is estimated as a dense operation, instead of a sparse one. Therefore, we need to take care of it when we want to get the correct time cost estimation.
  2. The weight of embedding has 2 dimensions, one is num_embeddings, another is embedding_dims. In this PR, only embedding_dims get shard, because num_embeddings case will require more actions in runtime preparation passes.

inplace=True)

if last_logical_output_dims in output_sharding_spec.dim_partition_dict:
dim_mapping = {0: i, last_logical_output_dims: last_physical_output_dims}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I combine the last dims and batch dimension together, instead of doing these actions one by one. Consider this example:
tensor shape: (1, 4, 16)
Device mesh: (2, 2)
ShardingSpec before converting: S0S1
If we recover the last dimensions first, the new dim_partition_dict will be {0: [0], 2: [1]}, 0 is inherit from the old_partition_dict({0: [0], 1: [1]}) and 2 comes from the dim_mapping {1: 2}. Then, the new ShardingSpec initialization process will crash, because the size of 0 dimension is 1 which is not dividable by 2.

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.

None yet

3 participants