-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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] Support operators have mixed inputs. #57774
[AutoParallel] Support operators have mixed inputs. #57774
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
local_t_2 = paddle.to_tensor(np_array, dtype='float16') | ||
elif np_array.dtype == np.int32: | ||
local_t_1 = paddle.to_tensor(np_array, dtype='int32') | ||
# local_t_2 = paddle.to_tensor(np_array, dtype='float16') |
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.
这里要新增一个int32的local值吗
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.
注释忘记删除了,已经恢复
x = np.random.random(size=[4, 4]).astype("float32") | ||
y = np.random.random(size=[4, 4]).astype("float32") | ||
local_x, dist_x = self.create_local_and_dist_tensor_pair(x) | ||
local_y, dist_y = self.create_two_local_tensor_pair(y) |
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.
local_y, dist_y -> local_y1, local_y2?
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, thx.
@@ -72,6 +72,13 @@ def FindParsingFunctionFromAttributeType(atype): | |||
" auto {} = {}(\"{}\", \"{}\", args, {}, {});\n" | |||
) | |||
|
|||
CONVERT_INPUT_TENSORS_TO_DIST_TENSOR_TEMPLATE = """ | |||
const phi::distributed::ProcessMesh* mesh = nullptr; | |||
auto mesh_ptr = &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.
这里是不是直接传入&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.
Done, thx.
@@ -325,7 +332,9 @@ def GeneratePythonCFunction(self): | |||
inplace_returns_pos_map = {} | |||
# Generate Python-C Tensors Parsing Logic | |||
get_eager_tensor_str = "" | |||
input_names = "mesh_ptr, " |
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.
这个可以放到上面模板里吗?这样看模板能知道mesh传进去了,inputs则只包含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.
Done, thx.
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.
LGTM
* [AutoParallel] Support operators have mixed inputs like DenseTensor and DistTensor. * Polish code with review comments.
* [AutoParallel] Support operators have mixed inputs like DenseTensor and DistTensor. * Polish code with review comments.
* [AutoParallel] Support operators have mixed inputs like DenseTensor and DistTensor. * Polish code with review comments.
PR types
Others
PR changes
Others
Description
Pcard-73145
Support operators have mixed inputs like DenseTensor and DistTensor. DenseTensor will be sharded to replicate DistTensor automatically.
Former implementation is deployed in
phi
APIs: PR 57684. However, inputs are allconst
reference, which means converting inputDenseTensor
toDistTensor
is an unsafe operation. Meanwhile, there is modification of inputs inAutoGrad
level like convert them to continuous Tensors. As a result, modification ofphi
input likex_tmp
inAutoGrad
level will not change the real inputx
, but backward node relies on the real inputx
information as Tensor metas. It's more properly to implement this sharding strategy inPython-C
level.