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

Migrate tests to pytest + add GA #127

Merged
merged 51 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ad1ca57
use composer's .gitignore
Jul 29, 2024
61672a9
add packages for testing
Jul 29, 2024
cc2df4d
add pyproject.toml for torch requirements
Jul 29, 2024
38651bb
migrate 10/14 tests to pytest
Jul 29, 2024
3dd13eb
add GH action for testing
Jul 29, 2024
8ea7d03
use composer Makefile
Jul 29, 2024
2e807b2
add pytest settings to pyproject.toml
Jul 29, 2024
b1cb378
add coverage settings to pyproject.toml
Jul 29, 2024
1674dae
only test on main or releases
Jul 29, 2024
4bad1f6
update pytorch version
Jul 29, 2024
f29e3b9
add eitan-tests back
Jul 29, 2024
424cace
seperate testing requirement in setup.py
eitanturok Jul 29, 2024
a057bf4
cast to list
eitanturok Jul 29, 2024
b450fc4
use up to date ci-testing
eitanturok Jul 29, 2024
8678b6d
use action, not yaml
eitanturok Jul 29, 2024
0581764
go back to v0.0.9 ci-testing
eitanturok Jul 29, 2024
cf9d02b
use ci-testing v0.1.0 with order changes
eitanturok Jul 29, 2024
ecc926f
make pytests better
eitanturok Jul 29, 2024
a7507cb
new test!
eitanturok Jul 29, 2024
e7cf99a
remove unused import
eitanturok Jul 30, 2024
a979d27
restore old GA
eitanturok Jul 30, 2024
662e58d
update pytest settings with oythonpath
eitanturok Jul 30, 2024
5f5ebca
glu_test
eitanturok Jul 30, 2024
d5efaa4
comment out seed all autouse fixtureb/c of errors
eitanturok Jul 30, 2024
d4f34eb
reorder functions
eitanturok Jul 30, 2024
2c51199
turn off seed_all in histogram_test
eitanturok Jul 30, 2024
fd330bd
add color support
eitanturok Jul 30, 2024
41ef931
better defaults for pytest
eitanturok Jul 30, 2024
6db516e
pip install in color?
eitanturok Jul 30, 2024
d4c5cea
remove env varable
eitanturok Jul 30, 2024
d9a2179
add moe tests
eitanturok Jul 30, 2024
b6d357b
set log levels
eitanturok Jul 30, 2024
1cd4e27
run tests on 2 GPUs, not 8
eitanturok Jul 30, 2024
56f11eb
ignore logging format
eitanturok Jul 30, 2024
3fc9e04
remove local dev paths
eitanturok Jul 30, 2024
29544b0
delete comments
eitanturok Jul 30, 2024
f54c64e
remove smoketest
eitanturok Jul 30, 2024
c3a99ca
do not include testing in all
eitanturok Jul 30, 2024
7899a43
add scatter test
eitanturok Jul 30, 2024
b255dc2
delete all abslpy tests
eitanturok Jul 30, 2024
e3a0793
use v0.1.0 of ci-testing
eitanturok Jul 30, 2024
b521910
update runner type
eitanturok Jul 30, 2024
3e111dc
fix secrets
eitanturok Jul 30, 2024
170b075
fix typo
eitanturok Jul 30, 2024
3da7bb4
update README
eitanturok Jul 30, 2024
ae49bc6
reorder args
eitanturok Jul 30, 2024
889d051
add absl-py dependency back b/c we stil use it in some places
eitanturok Jul 30, 2024
78324e7
Merge pull request #3 from eitanturok/eitan-tests-2
eitanturok Jul 30, 2024
73a2e7e
update
eitanturok Jul 30, 2024
eb3d88b
remove my local branch
eitanturok Jul 30, 2024
a0145a7
rename to container
eitanturok Jul 30, 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
46 changes: 46 additions & 0 deletions .github/workflows/pr-gpu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PR GPU tests
on:
push:
branches:
- main
- dev
- release/*
- eitan-tests # todo: remove this branch
pull_request_target:
branches:
- main
- dev
- release/**
- eitan-tests # todo: remove this branch
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
jobs:
gpu-pytests:
uses: mosaicml/ci-testing/.github/workflows/[email protected]
strategy:
fail-fast: false
matrix:
include:
- name: "python3.11-pytorch2.3-gpus1"
gpu_num: 1
container: mosaicml/pytorch:2.3.0_cu121-python3.11-ubuntu20.04
- name: "python3.11-pytorch2.3-gpus8"
gpu_num: 8
container: mosaicml/pytorch:2.3.0_cu121-python3.11-ubuntu20.04
name: ${{ matrix.name }}
if: github.repository_owner == 'eitanturok' # todo: replace with `databricks`
with:
container: ${{ matrix.container }}
git_repo: eitanturok/megablocks # todo: replace with `databricks/megablocks`
mcloud-timeout: 3600
name: ${{ matrix.name }}
pip_deps: "[all]"
pytest-command: "coverage run -m pytest tests"
pytest-markers: "gpu"
python-version: 3.9
composer_package_name: mosaicml # Required as Composer is built from source
gpu_num: ${{ matrix.gpu_num }}
secrets:
mcloud-api-key: ${{ secrets.MCLOUD_API_KEY }}
173 changes: 165 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,165 @@
*~
gpt2-merges.txt
gpt2-vocab.json
core
__pycache__
*.egg-info
dist
build
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
docs/path/
docs/source/_build/
docs/source/api_reference/
# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Virtual Env
venv/

# WandB
wandb/

# Neptune
.neptune/

# Spacemacs
._#*
.#*
.vscode/

# Vim
*.swp

# README backups
README.md.bkp

# OS X
.DS_Store

# Sphinx
api_reference/

# Node (for pyright)
node_modules/
package.json
package-lock.json

# pycharm
.idea/
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
clean:
rm -rf dist/*
# several pytest settings
WORLD_SIZE ?= 1 # world size for launcher tests
MASTER_PORT ?= 26000 # port for distributed tests
PYTHON ?= python3 # Python command
PYTEST ?= pytest # Pytest command
PYRIGHT ?= pyright # Pyright command. Pyright must be installed seperately -- e.g. `node install -g pyright`
EXTRA_ARGS ?= # extra arguments for pytest
EXTRA_LAUNCHER_ARGS ?= # extra arguments for the composer cli launcher

dist: clean
python3 setup.py sdist
test:
LOCAL_WORLD_SIZE=1 $(PYTHON) -m $(PYTEST) $(EXTRA_ARGS)

upload: dist
twine upload dist/*
test-gpu:
LOCAL_WORLD_SIZE=1 $(PYTHON) -m $(PYTEST) -m gpu $(EXTRA_ARGS)

upload-test: dist
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
# runs tests with the launcher
test-dist:
$(PYTHON) -m composer.cli.launcher -n $(WORLD_SIZE) --master_port $(MASTER_PORT) $(EXTRA_LAUNCHER_ARGS) -m $(PYTEST) $(EXTRA_ARGS)

test-dist-gpu:
$(PYTHON) -m composer.cli.launcher -n $(WORLD_SIZE) --master_port $(MASTER_PORT) $(EXTRA_LAUNCHER_ARGS) -m $(PYTEST) -m gpu $(EXTRA_ARGS)

.PHONY: test test-gpu test-dist test-dist-gpu
48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# build requirements
[build-system]
requires = ["setuptools < 70.0.0", "torch >= 2.3.0, < 2.4"]
build-backend = "setuptools.build_meta"

# Pytest
[tool.pytest.ini_options]
# By default, skip gpu tests
addopts = "--tb=short -m 'not gpu'"

markers = [
# For distributed testing
"world_size(val)",
# Should be run during daily regression
"daily",
# Whether the test will be reading data from a remote source, and may require credentials
"remote",
# whether the test requires a gpu
"gpu",
]

filterwarnings = [
# "error", # warnings should be treated like errors, but still need to fix some warnings
'ignore:ExtraArgumentWarning', # extra arguments originate from pytest-specific CLI args
'ignore:DistributedDefaultValueWarning', # default distributed values are fine
'ignore:NoDistributedWarning', # running without distributed is fine
'ignore:Deterministic mode is activated:UserWarning', # all tests run with deterministic mode
'ignore:SubsetNumBatchesWarning', # different subsets OK for testing
'ignore:No optimizer:UserWarning', # testing defaults
'ignore:No scheduler:UserWarning', # testing defaults
'ignore::DeprecationWarning:tensorboard', # ignore tensorboard
]

# Enable logging for pytest
log_cli = true
log_cli_level = "INFO"
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
log_cli_date_format = "%Y-%m-%d %H:%M:%S"

# Coverage
[tool.coverage.run]
parallel = true
branch = true
relative_files = true
concurrency = ["thread"]
include = [
"megablocks/*"
]
24 changes: 17 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from setuptools import setup, find_packages
import os

import torch
from setuptools import find_packages, setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension

if os.environ.get("TORCH_CUDA_ARCH_LIST"):
Expand Down Expand Up @@ -28,19 +29,28 @@
)
]

install_requires=[
"triton>=2.1.0",
"stanford-stk==0.7.0",
install_requires = [
'numpy>=1.21.5,<2.1.0',
'torch>=2.3.0,<2.4',
'triton>=2.1.0',
'stanford-stk @ git+https://[email protected]/stanford-futuredata/stk.git@a1ddf98466730b88a2988860a9d8000fd1833301',
'packaging>=21.3.0,<24.2',
]

extra_deps = {}

extra_deps["gg"] = [
"grouped_gemm==0.1.4",
'grouped_gemm @ git+https://[email protected]/tgale96/grouped_gemm.git@66c7195e35e8c4f22fa6a014037ef511bfa397cb',
]

extra_deps["dev"] = [
"absl-py",
extra_deps['dev'] = [
'absl-py',
'coverage[toml]==7.4.4',
'pytest_codeblocks>=0.16.1,<0.17',
'pytest-cov>=4,<5',
'pytest>=7.2.1,<8',
'pre-commit>=3.4.0,<4',
'mosaicml>=0.22.0',
]

extra_deps['all'] = set(dep for deps in extra_deps.values() for dep in deps)
Expand Down
Loading