Skip to content

[spmd_rules] Add SPMD rules for ArgSort operator #72388

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

Merged
merged 1 commit into from
May 16, 2025

Conversation

Yeenyeong
Copy link
Contributor

@Yeenyeong Yeenyeong commented Apr 21, 2025

PR Category

Auto Parallel

PR Types

New features

Description

pcard-90510

The version upon committing incorporates SPMD rules for the ArgSort operator, covering both the forward and backward passes.
The SPMD rules for both the forward and backward passes simply replicate the sorting axis across one worker mesh dimension. For example, dimension mapping [0, 1, -1], given sorting axis of 1, will be transformed into dimension mapping [0, -1, -1].
The rules that involve splitting the sorting axis are deeply coupled with the reduce communication mechanism. Specifically, merging sorted sequences during reduction is not currently supported and remains a topic for future work.

Copy link

paddle-bot bot commented Apr 21, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Apr 21, 2025
@Yeenyeong Yeenyeong force-pushed the dev-argsort-spmd-rule branch 3 times, most recently from 561556f to e14325b Compare April 23, 2025 06:47
x_tensor_dist_attr = dist_attr[0]
y_tensor_dist_attr = dist_attr[1]

self.assertEqual(len(dist_attr), 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

this line should be before L77, first determine the length, then retrieve the element

x_tensor_dist_attr = dist_attr[0]
y_tensor_dist_attr = dist_attr[1]

self.assertEqual(len(dist_attr), 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

same issue as above

x_tensor_dist_attr = dist_attr[0]
y_tensor_dist_attr = dist_attr[1]

self.assertEqual(len(dist_attr), 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

same issue as above

Comment on lines 24 to 34
SpmdInfo ArgSortInferSpmdBase(const DistMetaTensor& x,
int axis,
bool descending,
bool stable);

SpmdInfo ArgSortGradInferSpmdBase(const DistMetaTensor& indices,
const DistMetaTensor& x,
const DistMetaTensor& out_grad,
int axis,
bool descending,
bool stable);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for ArgSortInferSpmdBase and ArgSortGradInferSpmdBase? for other operators reuse these codes?

@Yeenyeong Yeenyeong force-pushed the dev-argsort-spmd-rule branch 2 times, most recently from f62d6e7 to 51a9572 Compare April 27, 2025 15:30
@Yeenyeong
Copy link
Contributor Author

@jeff41404 Code has been modified according issues you highlighted.
First, lines of code that asserts the length is moved to position before the array is accessed.
Second, ArgSortInferSpmdBase and ArgSortGradInferSpmdBase are deprecated and removed.
Thanks!

@Yeenyeong Yeenyeong requested a review from jeff41404 April 28, 2025 05:51
@jeff41404
Copy link
Contributor

to generate the correct code, ArgSortInferSpmd and ArgSortGradInferSpmd need to be configured in paddle/phi/ops/yaml/ops.yaml and paddle/phi/ops/yaml/backward.yaml respectively.

@Yeenyeong Yeenyeong force-pushed the dev-argsort-spmd-rule branch from 51a9572 to 62735f0 Compare April 28, 2025 07:48
zyfncg
zyfncg previously approved these changes Apr 29, 2025
@@ -0,0 +1,37 @@
/* Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2023 -> 2015

@@ -0,0 +1,184 @@
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

jeff41404
jeff41404 previously approved these changes May 6, 2025
zyfncg
zyfncg previously approved these changes May 6, 2025
@Yeenyeong Yeenyeong dismissed stale reviews from zyfncg and jeff41404 via 4be10d4 May 9, 2025 03:56
@Yeenyeong Yeenyeong force-pushed the dev-argsort-spmd-rule branch from 4be10d4 to 0a50085 Compare May 13, 2025 07:03
@Yeenyeong
Copy link
Contributor Author

/re-run approval

@jeff41404 jeff41404 merged commit 22dc7af into PaddlePaddle:develop May 16, 2025
46 of 48 checks passed
@Yeenyeong Yeenyeong deleted the dev-argsort-spmd-rule branch May 20, 2025 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants