Skip to content
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

GA to Lint + Format MegaBlocks #131

Merged
merged 46 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c97bf02
add GA yaml
Jul 31, 2024
ddef812
apply ruff
Jul 31, 2024
d5502ab
fix init files
Jul 31, 2024
243afa9
add ruff to pre-commit
Aug 1, 2024
32ef2e6
add ruff settings to pyproject.toml
Aug 1, 2024
36dadc3
yapf
Aug 1, 2024
beb5d9b
yapf
Aug 1, 2024
021052c
isort
Aug 1, 2024
37feb12
isort
Aug 1, 2024
9eff684
pycln
Aug 1, 2024
1e6b927
pre-commit-hooks
Aug 1, 2024
f25369c
add license
Aug 1, 2024
e89975a
docformatter
Aug 1, 2024
90c12a9
pydocstyle
Aug 1, 2024
121b7b5
more pydocstyle
Aug 1, 2024
f292bb6
yamllint
Aug 1, 2024
9d4b5f3
trufflehog
Aug 1, 2024
da015b5
pyright init
Aug 1, 2024
98a2bca
Merge branch 'eitan-pre-commit' into eitan-temp
eitanturok Aug 1, 2024
cfdfe32
Merge pull request #8 from eitanturok/eitan-temp
eitanturok Aug 1, 2024
de11700
change runner
Aug 1, 2024
d1a3395
format
Aug 1, 2024
7c7c9f2
remove pyright
Aug 1, 2024
fb72ccd
make all executable
Aug 2, 2024
11b9e83
chmod
Aug 2, 2024
6fed8ab
fix format
Aug 2, 2024
bf6b2bd
test against python 3.11
Aug 2, 2024
ab27938
todo -> TODO
Aug 2, 2024
7ba7aaa
use v0.1.0 of ci-testing
Aug 2, 2024
abb7916
Merge branch 'main' into eitan-pre-commit
eitanturok Aug 6, 2024
40f1a97
fix yaml lint
eitanturok Aug 6, 2024
63d8b18
update ci-testing version
eitanturok Aug 7, 2024
87daf42
fix comment
Aug 8, 2024
cffc463
add contributing and style guides
Aug 8, 2024
5277c70
add PULL_REQUEST template
Aug 8, 2024
e339ac5
fix imports
Aug 8, 2024
159a6c6
Update .github/workflows/pr-gpu.yaml
eitanturok Aug 8, 2024
6c303a0
update python version
Aug 8, 2024
a309f94
import more files
Aug 8, 2024
405150a
Merge branch 'eitan-pre-commit' of https://github.com/eitanturok/mega…
Aug 8, 2024
b5f5869
change license
Aug 8, 2024
e9e7576
only support 3.11
Aug 8, 2024
b69d4f8
comment on new line
Aug 8, 2024
b1ab8b7
fix license
Aug 8, 2024
3b342ff
fix license
Aug 8, 2024
4d6ce4b
make python-version and container consistent python versions
Aug 8, 2024
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
43 changes: 43 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Code Quality Checks
on:
push:
branches:
- main
- release/**
pull_request:
branches:
- main
- release/**
workflow_call:
workflow_dispatch:
# Cancel old runs when a new commit is pushed to the same branch if not on main or dev
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
defaults:
run:
working-directory: .
jobs:
code-quality:
runs-on: ubuntu-latest # TODO: switch to linux-ubuntu-latest later
timeout-minutes: 30
strategy:
matrix:
python_version:
- "3.9"
- "3.10"
b-chu marked this conversation as resolved.
Show resolved Hide resolved
- "3.11"
pip_deps:
- "[dev]"
steps:
- uses: actions/checkout@v3
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/ci-testing
ref: v0.1.0
path: ./ci-testing
- uses: ./ci-testing/.github/actions/code-quality
with:
python_version: ${{ matrix.python_version }}
pip_deps: ${{ matrix.pip_deps }}
4 changes: 2 additions & 2 deletions .github/workflows/pr-gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
pytest-gpu:
name: ${{ matrix.name }}
if: github.repository_owner == 'databricks'
runs-on: ubuntu-latest # todo: switch to linux-ubuntu-latest later
runs-on: ubuntu-latest # todo: switch to linux-ubuntu-latest later
eitanturok marked this conversation as resolved.
Show resolved Hide resolved
eitanturok marked this conversation as resolved.
Show resolved Hide resolved
strategy:
fail-fast: false
matrix:
Expand All @@ -39,7 +39,7 @@ jobs:
gpu_num: ${{ matrix.gpu_num }}
git_repo: databricks/megablocks
pip_deps: "[all,testing]"
pytest_command: "coverage run -m pytest tests" # todo: remove tests from pytest tests when we delete all tests outside of MegaBlocks repo
pytest_command: "coverage run -m pytest tests" # TODO: remove `tests` when delete tests outside megablocks dir
pytest_markers: "gpu"
composer_package_name: mosaicml # Required as Composer is built from source
mcloud_timeout: 3600
Expand Down
108 changes: 108 additions & 0 deletions .pre-commit-config.yaml
b-chu marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright 2024 MosaicML MegaBlocks authors
# SPDX-License-Identifier: Apache-2.0

default_language_version:
python: python3
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/google/yapf
rev: v0.32.0
hooks:
- id: yapf
name: yapf
description: A formatter for Python files.
entry: yapf
args: [-i, -vv, -p] # inplace
language: python
types: [python]
additional_dependencies:
- toml
- repo: https://github.com/hadialqattan/pycln
rev: v2.1.2
hooks:
- id: pycln
args: [. --all]
- repo: https://github.com/pycqa/isort
hooks:
- id: isort
rev: 5.12.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-shebang-scripts-are-executable
- id: pretty-format-json
args:
- --autofix
- --no-sort-keys
- --indent=4
- --no-ensure-ascii
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: insert-license
args:
- --license-filepath
- .pre-commit/FILE_HEADER
- --comment-style
- "#"
- --allow-past-years
types: [python]
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.0
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries=120, --wrap-descriptions=120]
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
name: pydocstyle
entry: pydocstyle
language: python
types: [python]
exclude: (.ci|.github)
additional_dependencies:
- toml
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
hooks:
- id: yamllint
name: yamllint
description: This hook runs yamllint.
entry: yamllint
language: python
types: [file, yaml]
- repo: https://github.com/trufflesecurity/trufflehog.git
rev: v3.40.0
hooks:
- id: trufflehog
name: secret scan
exclude: tests/horrible_strings.py
entry: trufflehog filesystem ./
args:
- --only-verified
- --fail
2 changes: 2 additions & 0 deletions .pre-commit/FILE_HEADER
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Copyright 2024 MosaicML MegaBlocks authors
SPDX-License-Identifier: Apache-2.0
42 changes: 42 additions & 0 deletions .yamllint.yaml
b-chu marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
yaml-files:
- "*.yaml"
- "*.yml"
- .yamllint

ignore: |
wandb

rules:
braces:
forbid: non-empty
brackets:
forbid: false
colons: enable
commas: enable
comments: enable
comments-indentation: enable
document-end:
present: false
document-start:
present: false
empty-lines: enable
empty-values: disable
hyphens: enable
indentation:
spaces: 2
indent-sequences: false
check-multi-line-strings: false
key-duplicates: enable
key-ordering: disable
line-length:
max: 120
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
new-line-at-end-of-file: enable
new-lines: enable
octal-values: enable
quoted-strings:
quote-type: double
required: false
trailing-spaces: enable
truthy: disable
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ RUN pip install flash-attn

ENV PYTHONPATH="/mount/megablocks/third_party/Megatron-LM:${PYTHONPATH}"

WORKDIR /mount/megablocks
WORKDIR /mount/megablocks
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
recursive-include csrc *.h
recursive-include csrc *.cu
recursive-include csrc *.cu
Empty file modified docker.sh
100644 → 100755
Empty file.
Empty file modified exp/dmoe/dmoe_125m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/dmoe/dmoe_356m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/dmoe/dmoe_46m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/dmoe/dmoe_760m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_125m_1gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_125m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_1315m_1gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_1315m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_356m_1gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_356m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_46m_1gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_46m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_760m_1gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/gpt2/gpt2_760m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/moe/moe_125m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/moe/moe_356m_8gpu.sh
100644 → 100755
Empty file.
Empty file modified exp/moe/moe_46m_8gpu.sh
100644 → 100755
Empty file.
11 changes: 9 additions & 2 deletions megablocks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
import megablocks.layers.dmoe
import megablocks.layers.moe
# Copyright 2024 MosaicML MegaBlocks authors
# SPDX-License-Identifier: Apache-2.0

from megablocks.layers import dmoe, moe

__all__ = [
'dmoe',
'moe',
]
2 changes: 1 addition & 1 deletion megablocks/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 MegaBlocks Composer authors
# Copyright 2024 MosaicML MegaBlocks authors
# SPDX-License-Identifier: Apache-2.0

"""The MegaBlocks Version."""
Expand Down
3 changes: 2 additions & 1 deletion megablocks/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

# Copyright 2024 MosaicML MegaBlocks authors
# SPDX-License-Identifier: Apache-2.0
Loading
Loading