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] refactored shape consistency to remove redundancy #1591

Merged
merged 4 commits into from Sep 13, 2022

Conversation

FrankLeeeee
Copy link
Contributor

@FrankLeeeee FrankLeeeee commented Sep 13, 2022

This PR refactored the usage of shape consistency manager. The details are described below.

Problem

Previously, each handler and strategy constructor requires a shape consistency manager object as input for initialization. However, this manager is only used in calculating the resharding cost and nowhere else. Meanwhile, calculating resharding cost is implemented twice in the op handler and strategy constructor. After moving this to utils, the handler and constructor do not need to keep the manager as a member any more.

Fix

The shape consistency manager is now a singleton class where there will only be one instance in the global namespace. The usage of resharding is now purely via function call (i.e. generate_resharding_cost and set_shape_consistency_manager_options, even though the latter is not implemented yet). The handler and constructor only need to call these functions now.

Side note

  1. Besides, I found the previous PR has an inconsistent way of refactoring compared to this one, thus I also updated the usage of generate_sharding_spec.
  2. Each op handler now has a new argument handle_backward. This is to configure whether backward stats should be computed, can be useful for inference as backward is not needed.

@YuliangLiu0306 YuliangLiu0306 merged commit 27fe8af into hpcaitech:main Sep 13, 2022
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

2 participants