From 0852475838301192b8de0c6b1dd0cb62b531d298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=B0=B8=E4=B9=85?= <34344716+yjjiang11@users.noreply.github.com> Date: Mon, 12 Dec 2022 23:41:55 -0800 Subject: [PATCH] remove fleet eager guard tests (#48765) --- .../fleet/dygraph_group_sharded_api.py | 3 --- .../fleet/dygraph_group_sharded_api_eager.py | 4 +--- .../fleet/dygraph_group_sharded_stage2.py | 4 +--- ...ygraph_group_sharded_stage2_comm_overlap.py | 4 +--- .../dygraph_group_sharded_stage2_offload.py | 4 +--- .../fleet/dygraph_group_sharded_stage3.py | 4 +--- .../dygraph_group_sharded_stage3_offload.py | 4 +--- .../fleet/dygraph_sharding_optimizer_stage2.py | 3 --- .../fleet/dygraph_sharding_stage2.py | 3 --- .../fleet/dygraph_sharding_stage2_offload.py | 3 --- .../fleet/dygraph_sharding_stage3.py | 3 --- .../fleet/dygraph_sharding_stage3_offload.py | 3 --- .../unittests/collective/init_process_group.py | 18 ++++++++---------- 13 files changed, 14 insertions(+), 46 deletions(-) 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 ae6f7059bf..ca4f2fa784 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 ef3bf9df18..3a2851a0c6 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 84be00cc1c..57444efb79 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 e92577e78f..b5907d9e75 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 4bf301dcc2..94373b0571 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 95e0bdc6a0..245d71d337 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 f12de252c2..07ebba2bed 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 e033603826..0c6f115d94 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 94a735a01f..a3502f6000 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 0288d1bcfd..f4d15143f9 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 189c683db2..076cb810da 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 07819a2f81..082160e4e3 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 2cdd029b90..e84d3ad630 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)) -- GitLab