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] refactor the runtime apply pass and add docstring to passes #1757

Merged

Conversation

YuliangLiu0306
Copy link
Contributor

What does this PR do

  1. This PR refactor the runtime pass into two files(runtime_apply_pass.py and runtime_preparetion_pass.py), runtime apply pass manages all the passes whose actions are used more than one time during training iters, while the runtime preparation pass manages all the passes whose actions are just used once during runtime preparation phase.
  2. Add docstring to passes.

Comment on lines 123 to 128
def runtime_preparation_pass(gm: torch.fx.GraphModule, solution: List[int], device_mesh: DeviceMesh):
gm, sharding_spec_convert_dict, origin_node_sharding_spec_dict, comm_actions_dict = _solution_annotatation_pass(
gm, solution)
# TODO: the pass below should be uncommented after the implementation of implicit_comm_action_apply_pass completed.
# gm = implicit_comm_action_apply_pass(gm)
gm = _module_params_sharding_pass(gm, device_mesh)
Copy link
Contributor

Choose a reason for hiding this comment

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

The function names seem a bit weird to me, it is kind of saying that there are passes within passes as runtime_preparation_pass calls _solution_annotatation_pass and _module_params_sharding_pass. Would it better if we treat _module_params_sharding_pass and _solution_annotatation_pass as the helper functions instead of passes.

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 see.

Comment on lines 1 to 20
from copy import deepcopy
from typing import Dict, List

import torch
from torch.fx.node import Node

from colossalai.auto_parallel.tensor_shard.sharding_strategy import (
CommAction,
CommType,
OperationData,
OperationDataType,
)
from colossalai.device.device_mesh import DeviceMesh
from colossalai.tensor.comm_spec import CommSpec
from colossalai.tensor.shape_consistency import ShapeConsistencyManager

shape_consistency_manager = ShapeConsistencyManager()


def runtime_apply(node: Node, origin_dict: Dict, input_dict: Dict, node_index: int, user_node_index: int):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should keep the passes in the auto_parallel module instead of the fx module. The relationship should be that auto_parallel module depends on the fx module. The current relationship is that auto parallel solver relies on fx tracing, and then fx passes relies on the auto parallel sharding strategy, which leads to high coupling between these modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

@FrankLeeeee FrankLeeeee merged commit 314d8c4 into hpcaitech:main Oct 25, 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