CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
auto_parallel add cp&sep strategy #73195
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
… add_cp_sep Conflicts: python/paddle/distributed/__init__.py test/auto_parallel/CMakeLists.txt
add sep unit test
… add_cp_sep Conflicts: python/paddle/nn/functional/flash_attention.py
… add_cp_sep Conflicts: python/paddle/distributed/__init__.py test/auto_parallel/CMakeLists.txt
… add_cp_sep Conflicts: python/paddle/distributed/__init__.py
if isinstance(args, (list, tuple)): | ||
all_args = [] | ||
for input_tensor in args: | ||
print( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use logging
instead of print
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -940,3 +943,402 @@ def tensor_parallel(model, optimizer=None, config=None): | |||
optimizer = ParallelOptimizer(optimizer) | |||
|
|||
return model, optimizer | |||
|
|||
|
|||
class ContextParallelPrefix(PlanBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PrepareContextParallel
is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
) | ||
|
||
|
||
class ContextParallel(PlanBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ContextParallel and TensorParallel are independent parallel strategies, it is recommended to put them in separate files later. e.g. context_parallel.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
assert self.period in [ | ||
'begin', | ||
'end', | ||
], f"period must be 'begin' or 'end', but got {self.period}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be no need of end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
@@ -48,6 +48,10 @@ | |||
) | |||
from .auto_parallel.high_level_api import to_distributed | |||
from .auto_parallel.interface import get_mesh, set_mesh | |||
from .auto_parallel.intermediate.context_parallel import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems to miss python/paddle/distributed/auto_parallel/intermediate/context_parallel.py
in this pr
("dp", self.dp), | ||
("pp", self.pp), | ||
("mp", self.mp), | ||
("sep", self.sep), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is better ot use cp
instead of sep
, can optimize later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增公开 API 需要添加文档和类型提示
super().__init__() | ||
self.backend = backend | ||
|
||
def all2all_reshard_pre_hook(self, process_mesh): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要添加类型提示、文档
|
||
return all2all_reshard_hook | ||
|
||
def all2all_reshard_post_hook(self, process_mesh): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
|
||
return all2all_reshard_hook | ||
|
||
def p2p_reshard_pre_hook(self, process_mesh): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
|
||
return input_hook | ||
|
||
def apply(self, layer, process_mesh, shard_param_list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
'all2all', | ||
], f"backend must be 'p2p' or 'all2all', but got {self.backend}" | ||
|
||
def all2all_split_input_pre_hook(self, process_mesh): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个类上的公开 API 同样需要添加文档和类型提示
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以先合入,后续需要补充API文档和类型提示
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Category
Auto Parallel
PR Types
New features
Description
add cp&sep strategy
cp: ring attention
sep: segment parallel strategy, similar as Deepspeed Ulyssess
Pcard-91295