-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【PIR Dist Op Reg No.4 and No.26】 reg global_scatter and limit_by_capa…
…city (#62579) * feat(pir): reg global_scatter and limit_by_capacity * feat(pir): reg global_scatter and limit_by_capacity * feat(pir): reg global_scatter and limit_by_capacity * feat(pir): reg global_scatter and limit_by_capacity * feat(pir): reg global_scatter and limit_by_capacity * feat(pir): reg global_scatter and limit_by_capacity * feat(pir): reg global_scatter and limit_by_capacity
- Loading branch information
Showing
11 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,8 @@ | |
'partial_allgather_', | ||
'nop', | ||
'nop_', | ||
'limit_by_capacity', | ||
'global_scatter', | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import unittest | ||
|
||
import test_op_translator | ||
|
||
import paddle | ||
from paddle.base.layer_helper import LayerHelper | ||
|
||
|
||
class TestDistributedLookupTableOpTranslator( | ||
test_op_translator.TestOpTranslator | ||
): | ||
def append_op(self): | ||
self.op_type = "global_scatter" | ||
x = paddle.ones(shape=(4, 8), dtype='float32') | ||
local_count = paddle.to_tensor([0, 1], dtype='int64') | ||
global_count = paddle.to_tensor([0, 1], dtype='int64') | ||
out = paddle.ones(shape=(2, 8), dtype='float32') | ||
attrs = {'ring_id': 0, 'use_calc_stream': False} | ||
helper = LayerHelper(self.op_type) | ||
helper.append_op( | ||
type=self.op_type, | ||
inputs={ | ||
"X": x, | ||
"local_count": local_count, | ||
"global_count": global_count, | ||
}, | ||
outputs={"Out": out}, | ||
attrs=attrs, | ||
) | ||
|
||
def test_translator(self): | ||
self.check() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
47 changes: 47 additions & 0 deletions
47
test/ir/pir/translator/test_limit_by_capacity_translator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import unittest | ||
|
||
import test_op_translator | ||
|
||
import paddle | ||
from paddle.base.layer_helper import LayerHelper | ||
|
||
|
||
class TestDistributedLookupTableOpTranslator( | ||
test_op_translator.TestOpTranslator | ||
): | ||
def append_op(self): | ||
self.op_type = "limit_by_capacity" | ||
expert_count = paddle.ones(shape=(8 * 8192,), dtype='int64') | ||
capacity = paddle.ones(shape=(8,), dtype='int64') | ||
out = paddle.ones(shape=(8,), dtype='int64') | ||
attrs = { | ||
'n_worker': 8192, | ||
} | ||
helper = LayerHelper(self.op_type) | ||
helper.append_op( | ||
type=self.op_type, | ||
inputs={"expert_count": expert_count, "capacity": capacity}, | ||
outputs={"Out": out}, | ||
attrs=attrs, | ||
) | ||
|
||
def test_translator(self): | ||
self.check() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |