Skip to content

[CodeStyle][ruff] clean some F401 step: 9 #60177

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,3 @@ known-first-party = ["paddle"]
"test/dygraph_to_static/test_loop.py" = ["C416", "F821"]
# Ignore unnecessary lambda in dy2st unittest test_lambda
"test/dygraph_to_static/test_lambda.py" = ["PLC3002"]

# temp ignore unused imports in all distributed files
"python/paddle/distributed/transpiler/__init__.py" = ["F401"]
"python/paddle/incubate/distributed/fleet/parameter_server/distribute_transpiler/__init__.py" = ["F401", "I001"]
"python/paddle/distributed/fleet/runtime/__init__.py" = ["F401"]
"python/paddle/distributed/transpiler/details/__init__.py" = ["F401", "I001"]
"python/paddle/incubate/distributed/models/moe/gate/__init__.py" = ["F401", "I001"]
"python/paddle/incubate/distributed/models/moe/__init__.py" = ["F401", "I001"]
"python/paddle/incubate/distributed/utils/io/__init__.py" = ["F401", "I001"]
"python/paddle/distributed/fleet/elastic/__init__.py" = ["F401", "I001"]

# temp ignore isort
"python/paddle/amp/__init__.py" = ["I001"]
"python/paddle/distributed/__init__.py" = ["I001"]
"python/paddle/distributed/communication/stream/__init__.py" = ["I001"]
"python/paddle/distributed/launch/context/__init__.py" = ["I001"]
"python/paddle/distributed/launch/controllers/__init__.py" = ["I001"]
"python/paddle/distributed/passes/__init__.py" = ["I001"]
"python/paddle/distributed/rpc/__init__.py" = ["I001"]
"python/paddle/distribution/__init__.py" = ["I001"]
"python/paddle/incubate/distributed/fleet/__init__.py" = ["I001"]
"python/paddle/incubate/distributed/fleet/parameter_server/pslib/__init__.py" = ["I001"]
34 changes: 16 additions & 18 deletions python/paddle/amp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .auto_cast import ( # noqa: F401
auto_cast,
decorate,
amp_guard,
amp_decorate,
)
from .amp_lists import ( # noqa: F401
white_list,
black_list,
from paddle.base import core
from paddle.base.framework import (
_current_expected_place,
_get_paddle_place,
)

from . import ( # noqa: F401
accuracy_compare,
debugging,
grad_scaler,
accuracy_compare,
)

from .amp_lists import ( # noqa: F401
black_list,
white_list,
)
from .auto_cast import ( # noqa: F401
amp_decorate,
amp_guard,
auto_cast,
decorate,
)
from .grad_scaler import ( # noqa: F401
GradScaler,
AmpScaler,
GradScaler,
OptimizerState,
)

from paddle.base import core
from paddle.base.framework import (
_current_expected_place,
_get_paddle_place,
)

__all__ = [
'auto_cast',
'GradScaler',
Expand Down
130 changes: 61 additions & 69 deletions python/paddle/distributed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,101 +13,93 @@
# limitations under the License.

import atexit # noqa: F401
from . import io
from .spawn import spawn
from .launch.main import launch
from .parallel import ( # noqa: F401
init_parallel_env,
get_rank,
get_world_size,
ParallelEnv,
DataParallel,
)
from .parallel_with_gloo import (
gloo_init_parallel_env,
gloo_barrier,
gloo_release,
)

from paddle.distributed.fleet.dataset import InMemoryDataset, QueueDataset
from paddle.distributed.fleet.base.topology import ParallelMode
from paddle.base.core import Placement, ReduceType

from . import (
cloud_utils, # noqa: F401
io,
rpc, # noqa: F401
)
from .auto_parallel import shard_op # noqa: F401
from .auto_parallel.api import (
DistAttr,
DistModel,
Strategy,
dtensor_from_fn,
reshard,
shard_layer,
shard_optimizer,
shard_tensor,
to_static,
)
from .auto_parallel.placement_type import (
Partial,
Replicate,
Shard,
)
from .auto_parallel.process_mesh import ProcessMesh
from .checkpoint.load_state_dict import load_state_dict
from .checkpoint.save_state_dict import save_state_dict
from .collective import (
split,
new_group,
is_available,
new_group,
split,
)
from .communication import ( # noqa: F401
stream,
from .communication import (
P2POp, # noqa: F401
ReduceOp,
all_gather,
all_gather_object,
all_reduce,
alltoall,
alltoall_single,
barrier,
batch_isend_irecv, # noqa: F401
broadcast,
broadcast_object_list,
reduce,
send,
scatter,
destroy_process_group,
gather,
scatter_object_list,
get_backend,
get_group,
irecv,
is_initialized,
isend,
recv,
irecv,
batch_isend_irecv,
P2POp,
reduce,
reduce_scatter,
is_initialized,
destroy_process_group,
get_group,
scatter,
scatter_object_list,
send,
stream, # noqa: F401
wait,
barrier,
get_backend,
)

from .auto_parallel.process_mesh import ProcessMesh

from paddle.base.core import ReduceType, Placement
from .auto_parallel.placement_type import (
Shard,
Replicate,
Partial,
)

from .auto_parallel import shard_op # noqa: F401

from .auto_parallel.api import (
DistAttr,
shard_tensor,
dtensor_from_fn,
reshard,
shard_layer,
shard_optimizer,
to_static,
Strategy,
DistModel,
)

from .fleet import BoxPSDataset # noqa: F401

from .entry_attr import ( # noqa: F401
ProbabilityEntry,
from .entry_attr import (
CountFilterEntry,
ProbabilityEntry,
ShowClickEntry,
)

from . import cloud_utils # noqa: F401

from .fleet import BoxPSDataset # noqa: F401
from .fleet.base.topology import ParallelMode
from .fleet.dataset import InMemoryDataset, QueueDataset
from .launch.main import launch
from .parallel import (
DataParallel, # noqa: F401
ParallelEnv,
get_rank,
get_world_size,
init_parallel_env,
)
from .parallel_with_gloo import (
gloo_barrier,
gloo_init_parallel_env,
gloo_release,
)
from .sharding import ( # noqa: F401
group_sharded_parallel,
save_group_sharded_model,
)

from . import rpc # noqa: F401

from .checkpoint.save_state_dict import save_state_dict
from .checkpoint.load_state_dict import load_state_dict
from .spawn import spawn

__all__ = [
"io",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import copy
from collections import defaultdict

from paddle.distributed.passes import PassContext
from paddle.framework import IrGraph, core, set_flags

from ...passes import PassContext
from ..process_mesh import ProcessMesh
from .dist_op import DistributedOperator
from .dist_tensor import DistributedTensor
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/distributed/communication/stream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from .all_reduce import all_reduce
from .all_to_all import alltoall, alltoall_single
from .broadcast import broadcast
from .gather import gather
from .recv import recv
from .reduce import reduce
from .reduce_scatter import reduce_scatter
from .recv import recv
from .scatter import scatter
from .send import send
from .gather import gather

__all__ = [
"all_gather",
Expand Down
16 changes: 9 additions & 7 deletions python/paddle/distributed/fleet/elastic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import signal
import os
import signal
import sys

from .manager import ElasticManager
from .manager import ElasticStatus
from .manager import ELASTIC_EXIT_CODE
from .manager import ElasticLevel
from .collective import CollectiveLauncher
from paddle.distributed.fleet.launch_utils import DistributeMode # noqa:F401

from paddle.distributed.fleet.launch_utils import DistributeMode
from .collective import CollectiveLauncher
from .manager import (
ELASTIC_EXIT_CODE,
ElasticLevel, # noqa:F401
ElasticManager,
ElasticStatus,
)


def enable_elastic(args, distribute_mode):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import re
import subprocess

import paddle.distributed.passes
import paddle
from paddle.distributed.passes import PassContext
from paddle.distributed.ps.utils.ps_factory import PsProgramBuilderFactory
from paddle.distributed.ps.utils.public import (
Expand Down
6 changes: 3 additions & 3 deletions python/paddle/distributed/fleet/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .collective_runtime import CollectiveRuntime
from .parameter_server_runtime import ParameterServerRuntime
from .the_one_ps import TheOnePSRuntime
from .collective_runtime import CollectiveRuntime # noqa:F401
from .parameter_server_runtime import ParameterServerRuntime # noqa:F401
from .the_one_ps import TheOnePSRuntime # noqa:F401

__all__ = []
6 changes: 3 additions & 3 deletions python/paddle/distributed/launch/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

from paddle.distributed.launch import plugins

from .args_envs import env_args_mapping, fetch_envs, parse_args
from .node import Node
from .status import Status
from .args_envs import parse_args, fetch_envs, env_args_mapping

import logging


class Context:
Expand Down
5 changes: 2 additions & 3 deletions python/paddle/distributed/launch/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

__all__ = []

from .collective import CollectiveController
from .collective import CollectiveElasticController
from .ps import PSController
from .collective import CollectiveController, CollectiveElasticController
from .ipu_controller import IPUController
from .ps import PSController
from .rpc import RpcController

# the order is extremely important
Expand Down
22 changes: 10 additions & 12 deletions python/paddle/distributed/passes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .pass_base import new_pass, PassManager, PassContext

from .auto_parallel_gradient_merge import * # noqa: F403
from .auto_parallel_sharding import * # noqa: F403
from .allreduce_matmul_grad_overlapping import * # noqa: F403
from .auto_parallel_amp import * # noqa: F403
from .auto_parallel_fp16 import * # noqa: F403
from .auto_parallel_recompute import * # noqa: F403
from .auto_parallel_quantization import * # noqa: F403
from .auto_parallel_data_parallel_optimization import * # noqa: F403
from .auto_parallel_grad_clip import * # noqa: F403
from .auto_parallel_fp16 import * # noqa: F403
from .auto_parallel_fused_linear_promotion import * # noqa: F403
from .auto_parallel_supplement_explicit_dependencies import * # noqa: F403
from .auto_parallel_grad_clip import * # noqa: F403
from .auto_parallel_gradient_merge import * # noqa: F403
from .auto_parallel_pipeline import * # noqa: F403
from .auto_parallel_quantization import * # noqa: F403
from .auto_parallel_recompute import * # noqa: F403
from .auto_parallel_sequence_parallel_optimization import * # noqa: F403
from .allreduce_matmul_grad_overlapping import * # noqa: F403
from .auto_parallel_sharding import * # noqa: F403
from .auto_parallel_supplement_explicit_dependencies import * # noqa: F403
from .cpp_pass import * # noqa: F403
from .fuse_all_reduce import * # noqa: F403
from .pass_base import PassContext, PassManager, new_pass
from .pipeline_scheduler_pass import * # noqa: F403
from .ps_trainer_pass import * # noqa: F403
from .ps_server_pass import * # noqa: F403

from .ps_trainer_pass import * # noqa: F403

__all__ = [
'new_pass',
Expand Down
Loading