Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 16fadfe

Browse files
Copilotcrcrparpre-commit-ci[bot]
authored
Enable Ruff pre-commit hooks (#1957)
* Initial plan * Enable Ruff pre-commit hooks in .pre-commit-config.yaml Co-authored-by: crcrpar <[email protected]> * run pre-commit Signed-off-by: Masaki Kozuki <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add Ruff configuration to pyproject.toml with line-length 100 Co-authored-by: crcrpar <[email protected]> * Add ruff ignore rules with occurrence statistics to pyproject.toml Configure ruff to ignore common code style violations that are present throughout the codebase. Added occurrence counts for each ignored rule, sorted by count (ascending) to help prioritize which violations to fix first. This allows the ruff pre-commit hook to pass while providing visibility into the scope of each violation type. Ignored rules include: - E731 (6 occurrences) - lambda assignment - E721, E741 (8 occurrences) - type comparison, ambiguous names - E712, F403 (9 occurrences) - comparison to True/False, star imports - E701, E711 (10-11 occurrences) - multiple statements, None comparison - F821, E722 (14-15 occurrences) - undefined names, bare except - E402, F401 (41-45 occurrences) - import issues - F841, F405 (52-80 occurrences) - unused variables, star imports Signed-off-by: Masaki Kozuki <[email protected]> --------- Signed-off-by: Masaki Kozuki <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: crcrpar <[email protected]> Co-authored-by: Masaki Kozuki <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 27e0e89 commit 16fadfe

177 files changed

Lines changed: 11624 additions & 6465 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ repos:
66
files: \.(c|h|cpp|hpp|proto|cu|cuh)$
77
exclude: ^(apex/contrib/csrc/multihead_attn/cutlass|apex/contrib/csrc/cudnn-frontend)/
88

9-
# TODO: Enable Ruff
10-
# - repo: https://github.com/astral-sh/ruff-pre-commit
11-
# rev: v0.14.0
12-
# hooks:
13-
# - id: ruff-check
14-
# args: ["--fix"]
15-
# - id: ruff-format
16-
# types_or: [python]
17-
# exclude: "examples"
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.14.0
11+
hooks:
12+
- id: ruff-check
13+
args: ["--fix"]
14+
- id: ruff-format
15+
types_or: [python]
16+
exclude: "examples"

apex/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,32 @@
1616

1717
if torch.distributed.is_available():
1818
from . import transformer
19+
1920
__all__ = ["optimizers", "normalization", "transformer"]
2021

2122
# Logging utilities for apex.transformer module
2223
class RankInfoFormatter(logging.Formatter):
23-
2424
def format(self, record):
2525
from apex.transformer.parallel_state import get_rank_info
26+
2627
record.rank_info = get_rank_info()
2728
return super().format(record)
2829

2930
_library_root_logger = logging.getLogger(__name__)
3031
handler = logging.StreamHandler()
31-
handler.setFormatter(RankInfoFormatter("%(asctime)s - PID:%(process)d - rank:%(rank_info)s - %(filename)s:%(lineno)d - %(levelname)s - %(message)s", "%y-%m-%d %H:%M:%S"))
32+
handler.setFormatter(
33+
RankInfoFormatter(
34+
"%(asctime)s - PID:%(process)d - rank:%(rank_info)s - %(filename)s:%(lineno)d - %(levelname)s - %(message)s",
35+
"%y-%m-%d %H:%M:%S",
36+
)
37+
)
3238
_library_root_logger.addHandler(handler)
3339
_library_root_logger.propagate = False
3440
else:
3541
# Transformers require PyTorch built with distributed support
3642
__all__ = ["optimizers", "normalization"]
3743

44+
3845
def check_cudnn_version_and_warn(global_option: str, required_cudnn_version: int) -> bool:
3946
cudnn_available = torch.backends.cudnn.is_available()
4047
cudnn_version = torch.backends.cudnn.version() if cudnn_available else None
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
from .bottleneck import Bottleneck, SpatialBottleneck
2-
from .halo_exchangers import HaloExchangerNoComm, HaloExchangerAllGather, HaloExchangerSendRecv, HaloExchangerPeer
2+
from .halo_exchangers import (
3+
HaloExchangerNoComm,
4+
HaloExchangerAllGather,
5+
HaloExchangerSendRecv,
6+
HaloExchangerPeer,
7+
)

0 commit comments

Comments
 (0)