Skip to content

Commit ac12f07

Browse files
committed
change lint
1 parent af5a4ff commit ac12f07

Some content is hidden

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

57 files changed

+775
-304
lines changed

.clang-format

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlinesLeft: true
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: true
17+
AlwaysBreakTemplateDeclarations: true
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BraceWrapping:
21+
AfterClass: false
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: false
25+
AfterNamespace: false
26+
AfterObjCDeclaration: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
BeforeCatch: false
30+
BeforeElse: false
31+
IndentBraces: false
32+
BreakBeforeBinaryOperators: None
33+
BreakBeforeBraces: Attach
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializersBeforeComma: false
36+
BreakAfterJavaFieldAnnotations: false
37+
BreakStringLiterals: false
38+
ColumnLimit: 80
39+
CommentPragmas: '^ IWYU pragma:'
40+
CompactNamespaces: false
41+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
42+
ConstructorInitializerIndentWidth: 4
43+
ContinuationIndentWidth: 4
44+
Cpp11BracedListStyle: true
45+
DerivePointerAlignment: false
46+
DisableFormat: false
47+
ForEachMacros:
48+
- FOR_EACH_RANGE
49+
- FOR_EACH
50+
IncludeCategories:
51+
- Regex: '^<.*\.h(pp)?>'
52+
Priority: 1
53+
- Regex: '^<.*'
54+
Priority: 2
55+
- Regex: '.*'
56+
Priority: 3
57+
IndentCaseLabels: true
58+
IndentWidth: 2
59+
IndentWrappedFunctionNames: false
60+
KeepEmptyLinesAtTheStartOfBlocks: false
61+
MacroBlockBegin: ''
62+
MacroBlockEnd: ''
63+
Macros:
64+
- >-
65+
PyObject_HEAD_INIT(type)={
66+
/* this is not exactly match with PyObject_HEAD_INIT in Python source code
67+
* but it is enough for clang-format */
68+
{ 0xFFFFFFFF },
69+
(type)
70+
},
71+
- >-
72+
PyVarObject_HEAD_INIT(type, size)={
73+
{
74+
/* manually expand PyObject_HEAD_INIT(type) above
75+
* because clang-format do not support recursive expansion */
76+
{ 0xFFFFFFFF },
77+
(type)
78+
},
79+
(size)
80+
},
81+
MaxEmptyLinesToKeep: 1
82+
NamespaceIndentation: None
83+
PenaltyBreakBeforeFirstCallParameter: 1
84+
PenaltyBreakComment: 300
85+
PenaltyBreakFirstLessLess: 120
86+
PenaltyBreakString: 1000
87+
PenaltyExcessCharacter: 1000000
88+
PenaltyReturnTypeOnItsOwnLine: 2000000
89+
PointerAlignment: Left
90+
ReflowComments: true
91+
SortIncludes: true
92+
SpaceAfterCStyleCast: false
93+
SpaceBeforeAssignmentOperators: true
94+
SpaceBeforeParens: ControlStatements
95+
SpaceInEmptyParentheses: false
96+
SpacesBeforeTrailingComments: 1
97+
SpacesInAngles: false
98+
SpacesInContainerLiterals: true
99+
SpacesInCStyleCastParentheses: false
100+
SpacesInParentheses: false
101+
SpacesInSquareBrackets: false
102+
Standard: c++17
103+
StatementMacros:
104+
- C10_DEFINE_bool
105+
- C10_DEFINE_int
106+
- C10_DEFINE_int32
107+
- C10_DEFINE_int64
108+
- C10_DEFINE_string
109+
- C10_DEFINE_REGISTRY_WITHOUT_WARNING
110+
- C10_REGISTER_CREATOR
111+
- DEFINE_BINARY
112+
- PyObject_HEAD
113+
- PyObject_VAR_HEAD
114+
- PyException_HEAD
115+
- TORCH_DECLARE_bool
116+
117+
TabWidth: 8
118+
UseTab: Never
119+
---
120+
Language: ObjC
121+
ColumnLimit: 120
122+
AlignAfterOpenBracket: Align
123+
IndentWidth: 2
124+
ObjCBlockIndentWidth: 2
125+
ObjCSpaceAfterProperty: false
126+
ObjCSpaceBeforeProtocolList: false
127+
...

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 256
3+
extend-ignore = E302, G004, SIM105, G201, SIM115, SIM904

.github/workflows/lint.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@ jobs:
2424
sudo apt-get install -y protobuf-compiler
2525
2626
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128
27-
2827
pip install .[dev] -v
2928
29+
# install recent version of Rust via rustup
30+
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=default -y
31+
. "$HOME/.cargo/env"
32+
33+
rustup install nightly
34+
rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt
35+
3036
lintrunner init
3137
- name: Run lintrunner
3238
run: |
3339
set -eux
3440
35-
lintrunner --skip PYRE --force-color --all-files
41+
lintrunner --skip PYRE,FLAKE --force-color --all-files
3642
- name: Run pyre
3743
run: |
3844
set -eux
@@ -42,4 +48,4 @@ jobs:
4248
run: |
4349
set -eux
4450
45-
cargo fmt --check
51+
cargo +nightly fmt --check

.lintrunner.toml

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,62 @@
11
[[linter]]
2-
code = 'BLACK-ISORT'
2+
code = 'CLANGFORMAT'
3+
include_patterns = [
4+
'**/*.proto',
5+
]
6+
exclude_patterns = []
7+
command = [
8+
'python',
9+
'-m',
10+
'lintrunner_adapters',
11+
'run',
12+
'clangformat_linter',
13+
'--binary=clang-format',
14+
'--fallback',
15+
'--',
16+
'@{{PATHSFILE}}'
17+
]
18+
init_command = [
19+
'python',
20+
'-m',
21+
'lintrunner_adapters',
22+
'run',
23+
'pip_init',
24+
'--dry-run={{DRYRUN}}',
25+
'clang-format==18.1.3',
26+
]
27+
28+
[[linter]]
29+
code = 'UFMT'
30+
include_patterns = [
31+
'*.py',
32+
'**/*.py',
33+
'**/*.pyi',
34+
]
35+
exclude_patterns = []
36+
command = [
37+
'python',
38+
'-m',
39+
'lintrunner_adapters',
40+
'run',
41+
'ufmt_linter',
42+
'--',
43+
'@{{PATHSFILE}}'
44+
]
45+
init_command = [
46+
'python',
47+
'-m',
48+
'lintrunner_adapters',
49+
'run',
50+
'pip_init',
51+
'--dry-run={{DRYRUN}}',
52+
'black==24.4.2',
53+
'ufmt==2.6.0',
54+
'usort==1.0.5',
55+
'ruff-api==0.1.0',
56+
]
57+
58+
[[linter]]
59+
code = 'FLAKE'
360
include_patterns = [
461
'*.py',
562
'**/*.py',
@@ -10,8 +67,8 @@ command = [
1067
'-m',
1168
'lintrunner_adapters',
1269
'run',
13-
'black_isort_linter',
14-
'--fast',
70+
'flake8_linter',
71+
'--config=.flake8',
1572
'--',
1673
'@{{PATHSFILE}}',
1774
]
@@ -22,8 +79,17 @@ init_command = [
2279
'run',
2380
'pip_init',
2481
'--dry-run={{DRYRUN}}',
25-
'black==24.10.0', # Use 24.x when ruff styles are updated
26-
'isort==5.13.2',
82+
'flake8==7.3.0',
83+
'flake8-bugbear==24.12.12',
84+
'flake8-comprehensions==3.16.0',
85+
'flake8-executable==2.1.3',
86+
'flake8-logging-format==2024.24.12',
87+
'flake8-pyi==25.5.0',
88+
'flake8-simplify==0.22.0',
89+
'mccabe==0.7.0',
90+
'pycodestyle==2.14.0',
91+
'pyflakes==3.4.0',
92+
'torchfix==0.4.0 ; python_version >= "3.10" and python_version < "3.13"',
2793
]
2894
is_formatter = true
2995

@@ -34,10 +100,7 @@ include_patterns = [
34100
]
35101
command = [
36102
'python',
37-
'-m',
38-
'lintrunner_adapters',
39-
'run',
40-
'rustfmt_linter',
103+
'tools/linter/adapters/rust_linter.py',
41104
'--binary=rustfmt',
42105
'--config-path=.rustfmt.toml',
43106
'--',

.pyre_configuration

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
}
99
],
1010
"search_path": [
11-
{"site-package": "torchx"},
12-
{"site-package": "parameterized"}
11+
{
12+
"site-package": "torchx"
13+
},
14+
{
15+
"site-package": "parameterized"
16+
}
1317
]
1418
}

.rustfmt.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
edition = "2021"
2+
group_imports = "StdExternalCrate"
3+
imports_granularity = "Item"
4+
merge_derives = false
5+
style_edition = "2024"
6+
use_field_init_shorthand = true

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ We actively welcome your pull requests.
6363
pip install lintrunner lintrunner-adapters
6464
lintrunner init
6565
lintrunner -a
66+
cargo +nightly fmt
6667
```
6768

6869
### Tests

docs/source/conf.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
from importlib.metadata import version
3232

3333
import pytorch_sphinx_theme2
34+
35+
import torchft
3436
from docutils import nodes
3537
from sphinx import addnodes
3638
from sphinx.util.docfields import TypedField
3739

38-
import torchft
39-
4040
FBCODE = "fbcode" in os.getcwd()
4141

4242
# -- General configuration ------------------------------------------------
@@ -236,9 +236,7 @@ def setup(app):
236236

237237
# In Sphinx 1.8 it was renamed to `add_css_file`, 1.7 and prior it is
238238
# `add_stylesheet` (deprecated in 1.8).
239-
add_css = getattr(
240-
app, "add_css_file", getattr(app, "add_stylesheet", None)
241-
) # noqa B009
239+
add_css = getattr(app, "add_css_file", getattr(app, "add_stylesheet", None)) # noqa B009
242240
for css_file in html_css_files:
243241
add_css(css_file)
244242

examples/monarch/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Monarch-TorchFT-TorchTitan Distributed Training Orchestrator
22

3-
#### Overview
3+
#### Overview
44
This script orchestrates fault-tolerant distributed training using TorchTitan and TorchMonarch
55
frameworks. It manages multiple training replicas across SLURM-scheduled compute nodes
66
with automatic failure recovery and TorchFT lighthouse coordination.
@@ -47,4 +47,4 @@ You can also override the resource configuration manually:
4747
- TensorBoard metrics enabled by default
4848

4949
##### CLEANUP
50-
All SLURM jobs are automatically terminated at script completion.
50+
All SLURM jobs are automatically terminated at script completion.

examples/monarch/train_distributed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import torch
1717
from monarch._rust_bindings.monarch_hyperactor.alloc import AllocConstraints, AllocSpec
1818
from monarch._src.actor.allocator import RemoteAllocator, TorchXRemoteAllocInitializer
19-
from monarch.actor import Actor, ProcMesh, current_rank, endpoint, this_host
19+
from monarch.actor import Actor, current_rank, endpoint, ProcMesh, this_host
2020
from monarch.tools import commands
2121
from monarch.tools.components import hyperactor
2222
from monarch.tools.config import Config

0 commit comments

Comments
 (0)