diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py index ae6f7059bfa02b43bff330edf47eaa6f7bef172b..ca4f2fa78436acb9b2c46e11b05fbfc88400d969 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py @@ -24,7 +24,6 @@ from paddle.distributed.sharding import ( group_sharded_parallel, save_group_sharded_model, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear epoch = 10 @@ -196,7 +195,5 @@ def test_sharding_api(): if __name__ == '__main__': - with _test_eager_guard(): - pass fleet.init(is_collective=True) test_sharding_api() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py index ef3bf9df182058df5f4cc92ad3aa7dd12ae96bb2..3a2851a0c6ed94ba4f4236106640b3344f69bf30 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py @@ -22,7 +22,6 @@ from paddle.distributed.sharding import ( group_sharded_parallel, save_group_sharded_model, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear epoch = 10 @@ -199,5 +198,4 @@ def test_sharding_api(): if __name__ == '__main__': - with _test_eager_guard(): - test_sharding_api() + test_sharding_api() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py index 84be00cc1ccd1e50efa2e02462a613f347c34d6d..57444efb792e76d44112e8afc6f7fa25d8889341 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py @@ -28,7 +28,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_optimizer_sta from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage2 import ( GroupShardedStage2, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear seed = 2022 @@ -246,5 +245,4 @@ def test_dp_stage2(): if __name__ == '__main__': - with _test_eager_guard(): - test_dp_stage2() + test_dp_stage2() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py index e92577e78f8ddc01685f0b074b9e03515f8e1ec3..b5907d9e75d9471d11cf35dda9fad1cc7b99cffc 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py @@ -28,7 +28,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_optimizer_sta from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage2 import ( GroupShardedStage2, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear seed = 2022 @@ -250,5 +249,4 @@ def test_dp_stage2(): if __name__ == '__main__': - with _test_eager_guard(): - test_dp_stage2() + test_dp_stage2() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_offload.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_offload.py index 4bf301dcc2beb9d1df9941f08aec20d1554b57ee..94373b057112428999184fe55cc95dc63d9e2eba 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_offload.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_offload.py @@ -31,7 +31,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage2 import from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_utils import ( GroupShardedScaler, ) -from paddle.fluid.framework import _test_eager_guard seed = 2021 epoch = 2 @@ -115,5 +114,4 @@ def test_sharding_stage2_offload(): if __name__ == '__main__': - with _test_eager_guard(): - test_sharding_stage2_offload() + test_sharding_stage2_offload() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py index 95e0bdc6a068d12ae47e7fd1e96c7625b896ed04..245d71d3379f59490bd240ba3d712c386baadfaa 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py @@ -34,7 +34,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage3 import from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_utils import ( GroupShardedScaler, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear epoch = 10 @@ -320,5 +319,4 @@ def test_stage2_stage3(): if __name__ == '__main__': - with _test_eager_guard(): - test_stage2_stage3() + test_stage2_stage3() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py index f12de252c2c15a4a5e8235cd60d45d195dc05dcf..07ebba2bedfa2790c9f768fab1c34c283d6779f2 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py @@ -24,7 +24,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage3 import from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_utils import ( GroupShardedScaler, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear epoch = 10 @@ -220,5 +219,4 @@ def test_stage3_offload(): if __name__ == '__main__': - with _test_eager_guard(): - test_stage3_offload() + test_stage3_offload() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_optimizer_stage2.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_optimizer_stage2.py index e03360382612b28e124189cdc979dbc0119a6fe4..0c6f115d94a769f0f2f54d3b46d053ac481648bd 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_optimizer_stage2.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_optimizer_stage2.py @@ -23,7 +23,6 @@ from paddle.distributed.fleet.meta_optimizers.dygraph_optimizer.sharding_optimiz ShardingOptimizerStage2, ) from paddle.distributed.fleet.utils.internal_storage import GradStorage -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear base_lr = 0.1 @@ -142,6 +141,4 @@ def train_mlp(): if __name__ == '__main__': - with _test_eager_guard(): - pass train_mlp() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2.py index 94a735a01f9981b8b220f3f057861da883d78601..a3502f6000d00d313e0c1516fa06d7a2307a7ad4 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2.py @@ -29,7 +29,6 @@ from paddle.distributed.fleet.meta_optimizers.dygraph_optimizer.sharding_optimiz from paddle.distributed.fleet.meta_parallel.sharding.sharding_stage2 import ( ShardingStage2, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear seed = 2022 @@ -239,7 +238,5 @@ def test_dp_stage2(): if __name__ == '__main__': - with _test_eager_guard(): - pass fleet.init(is_collective=True, strategy=strategy) test_dp_stage2() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2_offload.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2_offload.py index 0288d1bcfd398b5757ee03b78bf5bbb38f7afa68..f4d15143f91c0a89e5c5af23db96ce997ae6f750 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2_offload.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2_offload.py @@ -28,7 +28,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.sharding_stage2 import ( from paddle.distributed.fleet.meta_parallel.sharding.sharding_utils import ( ShardingScaler, ) -from paddle.fluid.framework import _test_eager_guard seed = 2021 epoch = 2 @@ -119,7 +118,5 @@ def test_sharding_stage2_offload(): if __name__ == '__main__': - with _test_eager_guard(): - pass fleet.init(is_collective=True, strategy=strategy) test_sharding_stage2_offload() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3.py index 189c683db2ee4b3cab7177aab807c7b620d756ea..076cb810da3e0926e6600afe8fc5ea99623e8920 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3.py @@ -35,7 +35,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.sharding_stage3 import ( from paddle.distributed.fleet.meta_parallel.sharding.sharding_utils import ( ShardingScaler, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear epoch = 10 @@ -316,7 +315,5 @@ def test_stage2_stage3(): if __name__ == '__main__': - with _test_eager_guard(): - pass fleet.init(is_collective=True) test_stage2_stage3() diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3_offload.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3_offload.py index 07819a2f815a8ef8188f689725f5480725ffb6be..082160e4e3f04463da5b0514c4a0dcc666855792 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3_offload.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3_offload.py @@ -25,7 +25,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.sharding_stage3 import ( from paddle.distributed.fleet.meta_parallel.sharding.sharding_utils import ( ShardingScaler, ) -from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear epoch = 10 @@ -216,7 +215,5 @@ def test_stage3_offload(): if __name__ == '__main__': - with _test_eager_guard(): - pass fleet.init(is_collective=True) test_stage3_offload() diff --git a/python/paddle/fluid/tests/unittests/collective/init_process_group.py b/python/paddle/fluid/tests/unittests/collective/init_process_group.py index 2cdd029b90c8d96d9ddc0b32775d8cbf8bf418aa..e84d3ad6304d42b29a3b54bea7c06a48517d1984 100644 --- a/python/paddle/fluid/tests/unittests/collective/init_process_group.py +++ b/python/paddle/fluid/tests/unittests/collective/init_process_group.py @@ -15,7 +15,6 @@ import unittest import paddle -from paddle.fluid.framework import _test_eager_guard class TestProcessGroupFp32(unittest.TestCase): @@ -26,15 +25,14 @@ class TestProcessGroupFp32(unittest.TestCase): pass def test_init_process_group(self): - with _test_eager_guard(): - paddle.distributed.init_parallel_env() - paddle.distributed.new_group() - group = paddle.distributed.new_group([-1, -2]) - assert group.process_group is None - - group = paddle.distributed.collective.Group(-1, 2, 0, [-1, -2]) - ret = paddle.distributed.barrier(group) - assert ret is None + paddle.distributed.init_parallel_env() + paddle.distributed.new_group() + group = paddle.distributed.new_group([-1, -2]) + assert group.process_group is None + + group = paddle.distributed.collective.Group(-1, 2, 0, [-1, -2]) + ret = paddle.distributed.barrier(group) + assert ret is None paddle.enable_static() in_tensor = paddle.empty((1, 2)) in_tensor2 = paddle.empty((1, 2))