Skip to content
Merged
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
127 changes: 127 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
AccessModifierOffset: -1
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros:
- FOR_EACH_RANGE
- FOR_EACH
IncludeCategories:
- Regex: '^<.*\.h(pp)?>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
Macros:
- >-
PyObject_HEAD_INIT(type)={
/* this is not exactly match with PyObject_HEAD_INIT in Python source code
* but it is enough for clang-format */
{ 0xFFFFFFFF },
(type)
},
- >-
PyVarObject_HEAD_INIT(type, size)={
{
/* manually expand PyObject_HEAD_INIT(type) above
* because clang-format do not support recursive expansion */
{ 0xFFFFFFFF },
(type)
},
(size)
},
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 2000000
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++17
StatementMacros:
- C10_DEFINE_bool
- C10_DEFINE_int
- C10_DEFINE_int32
- C10_DEFINE_int64
- C10_DEFINE_string
- C10_DEFINE_REGISTRY_WITHOUT_WARNING
- C10_REGISTER_CREATOR
- DEFINE_BINARY
- PyObject_HEAD
- PyObject_VAR_HEAD
- PyException_HEAD
- TORCH_DECLARE_bool

TabWidth: 8
UseTab: Never
---
Language: ObjC
ColumnLimit: 120
AlignAfterOpenBracket: Align
IndentWidth: 2
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
...
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 256
extend-ignore = E302, G004, SIM105, G201, SIM115, SIM904
12 changes: 9 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ jobs:
sudo apt-get install -y protobuf-compiler

pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128

pip install .[dev] -v

# install recent version of Rust via rustup
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=default -y
. "$HOME/.cargo/env"

rustup install nightly
rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt

lintrunner init
- name: Run lintrunner
run: |
set -eux

lintrunner --skip PYRE --force-color --all-files
lintrunner --skip PYRE,FLAKE --force-color --all-files
- name: Run pyre
run: |
set -eux
Expand All @@ -42,4 +48,4 @@ jobs:
run: |
set -eux

cargo fmt --check
cargo +nightly fmt --check
81 changes: 72 additions & 9 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
[[linter]]
code = 'BLACK-ISORT'
code = 'CLANGFORMAT'
include_patterns = [
'**/*.proto',
]
exclude_patterns = []
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'clangformat_linter',
'--binary=clang-format',
'--fallback',
'--',
'@{{PATHSFILE}}'
]
init_command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'clang-format==18.1.3',
]

[[linter]]
code = 'UFMT'
include_patterns = [
'*.py',
'**/*.py',
'**/*.pyi',
]
exclude_patterns = []
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'ufmt_linter',
'--',
'@{{PATHSFILE}}'
]
init_command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'black==24.4.2',
'ufmt==2.6.0',
'usort==1.0.5',
'ruff-api==0.1.0',
]

[[linter]]
code = 'FLAKE'
include_patterns = [
'*.py',
'**/*.py',
Expand All @@ -10,8 +67,8 @@ command = [
'-m',
'lintrunner_adapters',
'run',
'black_isort_linter',
'--fast',
'flake8_linter',
'--config=.flake8',
'--',
'@{{PATHSFILE}}',
]
Expand All @@ -22,8 +79,17 @@ init_command = [
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'black==24.10.0', # Use 24.x when ruff styles are updated
'isort==5.13.2',
'flake8==7.3.0',
'flake8-bugbear==24.12.12',
'flake8-comprehensions==3.16.0',
'flake8-executable==2.1.3',
'flake8-logging-format==2024.24.12',
'flake8-pyi==25.5.0',
'flake8-simplify==0.22.0',
'mccabe==0.7.0',
'pycodestyle==2.14.0',
'pyflakes==3.4.0',
'torchfix==0.4.0 ; python_version >= "3.10" and python_version < "3.13"',
]
is_formatter = true

Expand All @@ -34,10 +100,7 @@ include_patterns = [
]
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'rustfmt_linter',
'tools/linter/adapters/rust_linter.py',
'--binary=rustfmt',
'--config-path=.rustfmt.toml',
'--',
Expand Down
8 changes: 6 additions & 2 deletions .pyre_configuration
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
}
],
"search_path": [
{"site-package": "torchx"},
{"site-package": "parameterized"}
{
"site-package": "torchx"
},
{
"site-package": "parameterized"
}
]
}
5 changes: 5 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
edition = "2021"
group_imports = "StdExternalCrate"
imports_granularity = "Item"
merge_derives = false
style_edition = "2024"
use_field_init_shorthand = true
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ We actively welcome your pull requests.
pip install lintrunner lintrunner-adapters
lintrunner init
lintrunner -a
cargo +nightly fmt
```

### Tests
Expand Down
8 changes: 3 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
from importlib.metadata import version

import pytorch_sphinx_theme2

import torchft
from docutils import nodes
from sphinx import addnodes
from sphinx.util.docfields import TypedField

import torchft

FBCODE = "fbcode" in os.getcwd()

# -- General configuration ------------------------------------------------
Expand Down Expand Up @@ -236,9 +236,7 @@ def setup(app):

# In Sphinx 1.8 it was renamed to `add_css_file`, 1.7 and prior it is
# `add_stylesheet` (deprecated in 1.8).
add_css = getattr(
app, "add_css_file", getattr(app, "add_stylesheet", None)
) # noqa B009
add_css = getattr(app, "add_css_file", getattr(app, "add_stylesheet", None)) # noqa B009
for css_file in html_css_files:
add_css(css_file)

Expand Down
4 changes: 2 additions & 2 deletions examples/monarch/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Monarch-TorchFT-TorchTitan Distributed Training Orchestrator

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

##### CLEANUP
All SLURM jobs are automatically terminated at script completion.
All SLURM jobs are automatically terminated at script completion.
2 changes: 1 addition & 1 deletion examples/monarch/train_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from monarch._rust_bindings.monarch_hyperactor.alloc import AllocConstraints, AllocSpec
from monarch._src.actor.allocator import RemoteAllocator, TorchXRemoteAllocInitializer
from monarch.actor import Actor, ProcMesh, current_rank, endpoint, this_host
from monarch.actor import Actor, current_rank, endpoint, ProcMesh, this_host
from monarch.tools import commands
from monarch.tools.components import hyperactor
from monarch.tools.config import Config
Expand Down
Loading
Loading