Skip to content

Commit

Permalink
Merge branch 'eitan-pre-commit' into eitan-temp
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanturok authored Aug 1, 2024
2 parents 52186a6 + da015b5 commit 98a2bca
Show file tree
Hide file tree
Showing 69 changed files with 2,450 additions and 1,131 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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: linux-ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python_version:
- "3.9"
- "3.10"
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.0.9
path: ./ci-testing
- uses: ./ci-testing/.github/actions/code-quality
with:
python_version: ${{ matrix.python_version }}
pip_deps: ${{ matrix.pip_deps }}
2 changes: 1 addition & 1 deletion .github/workflows/pr-gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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
118 changes: 118 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Copyright 2024 MosaicML MegaBlocks authors
# SPDX-License-Identifier: Apache-2.0

default_language_version:
python: python3
repos:
- repo: local
hooks:
- id: pyright
name: pyright
entry: pyright
language: node
types: [python]
pass_filenames: false
args: [--warnings]
additional_dependencies: ["[email protected]"]
- 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
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
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',
]
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

0 comments on commit 98a2bca

Please sign in to comment.