Skip to content

Commit 1e14ec0

Browse files
committed
ci: add lintrunner for clang and pyrefly
1 parent 61abf03 commit 1e14ec0

File tree

10 files changed

+838
-2
lines changed

10 files changed

+838
-2
lines changed

.clang-format

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# The primary clang-format config file.
2+
# TODO(afuller): Set these settings when they aren't broken:
3+
# - AllowShortBlocksOnASingleLine: Empty
4+
---
5+
AccessModifierOffset: -1
6+
AlignAfterOpenBracket: AlwaysBreak
7+
AlignConsecutiveMacros: false
8+
AlignConsecutiveAssignments: false
9+
AlignConsecutiveBitFields: false
10+
AlignConsecutiveDeclarations: false
11+
AlignEscapedNewlines: Left
12+
AlignOperands: DontAlign
13+
AlignTrailingComments: false
14+
AllowAllArgumentsOnNextLine: true
15+
AllowAllConstructorInitializersOnNextLine: true
16+
AllowAllParametersOfDeclarationOnNextLine: false
17+
AllowShortEnumsOnASingleLine: true
18+
AllowShortBlocksOnASingleLine: Never
19+
AllowShortCaseLabelsOnASingleLine: false
20+
AllowShortFunctionsOnASingleLine: Empty
21+
AllowShortLambdasOnASingleLine: All
22+
AllowShortIfStatementsOnASingleLine: Never
23+
AllowShortLoopsOnASingleLine: false
24+
AlwaysBreakAfterReturnType: None
25+
AlwaysBreakBeforeMultilineStrings: true
26+
AlwaysBreakTemplateDeclarations: Yes
27+
BinPackArguments: false
28+
BinPackParameters: false
29+
BreakBeforeBinaryOperators: None
30+
BreakBeforeBraces: Attach
31+
BreakInheritanceList: BeforeColon
32+
BreakBeforeTernaryOperators: true
33+
BreakConstructorInitializers: BeforeColon
34+
BreakAfterJavaFieldAnnotations: false
35+
BreakStringLiterals: false
36+
ColumnLimit: 80
37+
CommentPragmas: '^ IWYU pragma:'
38+
CompactNamespaces: false
39+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
40+
ConstructorInitializerIndentWidth: 4
41+
ContinuationIndentWidth: 4
42+
Cpp11BracedListStyle: true
43+
DeriveLineEnding: true
44+
DerivePointerAlignment: false
45+
DisableFormat: false
46+
FixNamespaceComments: true
47+
ForEachMacros:
48+
- FOR_EACH
49+
- FOR_EACH_R
50+
- FOR_EACH_RANGE
51+
IncludeBlocks: Preserve
52+
IncludeCategories:
53+
- Regex: '^<.*\.h(pp)?>'
54+
Priority: 1
55+
- Regex: '^<.*'
56+
Priority: 2
57+
- Regex: '.*'
58+
Priority: 3
59+
IndentCaseLabels: true
60+
IndentCaseBlocks: false
61+
IndentGotoLabels: true
62+
IndentPPDirectives: None
63+
IndentExternBlock: AfterExternBlock
64+
IndentWidth: 2
65+
IndentWrappedFunctionNames: false
66+
InsertTrailingCommas: None
67+
JavaScriptQuotes: Leave
68+
JavaScriptWrapImports: true
69+
KeepEmptyLinesAtTheStartOfBlocks: false
70+
MacroBlockBegin: ''
71+
MacroBlockEnd: ''
72+
MaxEmptyLinesToKeep: 1
73+
NamespaceIndentation: None
74+
ObjCBinPackProtocolList: Auto
75+
ObjCBlockIndentWidth: 2
76+
ObjCBreakBeforeNestedBlockParam: true
77+
ObjCSpaceAfterProperty: false
78+
ObjCSpaceBeforeProtocolList: false
79+
PenaltyBreakAssignment: 2
80+
PenaltyBreakBeforeFirstCallParameter: 1
81+
PenaltyBreakComment: 300
82+
PenaltyBreakFirstLessLess: 120
83+
PenaltyBreakString: 1000
84+
PenaltyBreakTemplateDeclaration: 10
85+
PenaltyExcessCharacter: 1000000
86+
PenaltyReturnTypeOnItsOwnLine: 200
87+
PointerAlignment: Left
88+
ReflowComments: true
89+
SortIncludes: true
90+
SortUsingDeclarations: true
91+
SpaceAfterCStyleCast: false
92+
SpaceAfterLogicalNot: false
93+
SpaceAfterTemplateKeyword: true
94+
SpaceBeforeAssignmentOperators: true
95+
SpaceBeforeCpp11BracedList: false
96+
SpaceBeforeCtorInitializerColon: true
97+
SpaceBeforeInheritanceColon: true
98+
SpaceBeforeParens: ControlStatements
99+
SpaceBeforeRangeBasedForLoopColon: true
100+
SpaceInEmptyBlock: false
101+
SpaceInEmptyParentheses: false
102+
SpacesBeforeTrailingComments: 1
103+
SpacesInAngles: false
104+
SpacesInConditionalStatement: false
105+
SpacesInContainerLiterals: true
106+
SpacesInCStyleCastParentheses: false
107+
SpacesInParentheses: false
108+
SpacesInSquareBrackets: false
109+
SpaceBeforeSquareBrackets: false
110+
Standard: Latest
111+
TabWidth: 8
112+
UseCRLF: false
113+
UseTab: Never
114+
...

.github/workflows/docs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
build-docs:
1111
if: github.repository_owner == 'meta-pytorch'
1212
name: Build Documentation
13-
runs-on: linux.g5.12xlarge.nvidia.gpu
13+
runs-on: linux.12xlarge
1414
container:
1515
image: nvidia/cuda:12.8.1-devel-ubuntu24.04
1616
timeout-minutes: 30
@@ -72,7 +72,7 @@ jobs:
7272
path: docs/build/html/
7373

7474
upload:
75-
runs-on: linux.g5.4xlarge.nvidia.gpu
75+
runs-on: linux.12xlarge
7676
permissions:
7777
# Grant write permission here so that the doc can be pushed to gh-pages branch
7878
contents: write

.github/workflows/lint.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
lint:
11+
if: github.repository_owner == 'meta-pytorch'
12+
name: lintrunner
13+
runs-on: linux.12xlarge
14+
container:
15+
image: nvidia/cuda:12.8.1-devel-ubuntu24.04
16+
timeout-minutes: 30
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Setup conda env
23+
uses: conda-incubator/setup-miniconda@v2
24+
with:
25+
auto-update-conda: true
26+
miniconda-version: "latest"
27+
activate-environment: test
28+
python-version: '3.10'
29+
auto-activate: false
30+
- name: Verify conda environment
31+
shell: bash -l {0}
32+
run: |
33+
conda info
34+
which python
35+
which conda
36+
- name: Update pip
37+
shell: bash -l {0}
38+
run: python -m pip install --upgrade pip
39+
- name: Install pytorch
40+
shell: bash -l {0}
41+
run: pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128
42+
- name: Install Dependencies
43+
shell: bash -l {0}
44+
run: |
45+
set -eux
46+
47+
conda install -y git
48+
conda install -y -c conda-forge glog==0.4.0 gflags fmt
49+
pip install cmake
50+
export USE_NCCL=0
51+
export USE_NCCLX=0
52+
export USE_GLOO=0
53+
export USE_SYSTEM_LIBS=1
54+
pip install --no-build-isolation .[dev] -v
55+
- name: Install Lint Dependencies
56+
shell: bash -l {0}
57+
run: |
58+
set -eux
59+
60+
lintrunner init
61+
- name: Lint
62+
shell: bash -l {0}
63+
run: |
64+
set -eux
65+
66+
lintrunner --force-color --all-files -v

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ third-party/
44
__pycache__/
55
*.so
66
dist/
7+
.lintbin/

.lintrunner.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[[linter]]
2+
code = "CLANGFORMAT"
3+
include_patterns = [
4+
"comms/torchcomms/**/*.hpp",
5+
"comms/torchcomms/**/*.cpp",
6+
]
7+
exclude_patterns = []
8+
init_command = [
9+
"python3",
10+
"tools/linter/adapters/pip_init.py",
11+
"--dry-run={{DRYRUN}}",
12+
"clang-format==21.1.2",
13+
]
14+
command = [
15+
"python3",
16+
"tools/linter/adapters/clangformat_linter.py",
17+
"--binary=.lintbin/clang-format",
18+
"--",
19+
"@{{PATHSFILE}}",
20+
]
21+
is_formatter = true
22+
23+
[[linter]]
24+
code = "PYREFLY"
25+
include_patterns = [
26+
"comms/torchcomms/**/*.py",
27+
"comms/torchcomms/**/*.pyi",
28+
]
29+
exclude_patterns = []
30+
command = [
31+
"python3",
32+
"tools/linter/adapters/pyrefly_linter.py",
33+
"--config=pyrefly.toml",
34+
]
35+
init_command = [
36+
"python3",
37+
"tools/linter/adapters/pip_init.py",
38+
"--dry-run={{DRYRUN}}",
39+
"pyrefly==0.36.2",
40+
]

pyrefly.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
project-includes = ["comms/torchcomms/**/*"]
2+
project-excludes = [
3+
"**/node_modules",
4+
"**/__pycache__",
5+
"**/*venv/**/*",
6+
]

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def build_cmake(self, ext):
124124
"pytest",
125125
"numpy",
126126
"psutil",
127+
"lintrunner",
127128
],
128129
}
129130

0 commit comments

Comments
 (0)