Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
fehiepsi committed Dec 16, 2021
2 parents c2f96ef + de22e71 commit f5b3b50
Show file tree
Hide file tree
Showing 206 changed files with 31,779 additions and 8,571 deletions.
51 changes: 40 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6]
python-version: [3.7]

steps:
- uses: actions/checkout@v2
Expand All @@ -24,7 +24,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt install -y pandoc
sudo apt install -y pandoc gsfonts
python -m pip install --upgrade pip
pip install https://github.com/pyro-ppl/funsor/archive/master.zip
pip install jaxlib
Expand All @@ -44,13 +44,13 @@ jobs:
python -m doctest -v README.md
test:
test-modeling:

runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: [3.6]
python-version: [3.7]

steps:
- uses: actions/checkout@v2
Expand All @@ -60,6 +60,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt install -y graphviz
python -m pip install --upgrade pip
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
Expand All @@ -70,14 +71,45 @@ jobs:
pip freeze
- name: Test with pytest
run: |
pytest -vs -k "not test_example" --durations=100
CI=1 pytest -vs -k "not test_example" --durations=100 --ignore=test/infer/
test-inference:

runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: [3.7]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
pip install https://github.com/pyro-ppl/funsor/archive/master.zip
pip install jaxlib
pip install jax
pip install .[dev,test]
pip freeze
- name: Test with pytest
run: |
pytest -vs --durations=20 test/infer/test_mcmc.py
pytest -vs --durations=20 test/infer --ignore=test/infer/test_mcmc.py
- name: Test x64
run: |
JAX_ENABLE_X64=1 pytest -vs test/test_mcmc.py -k x64
JAX_ENABLE_X64=1 pytest -vs test/infer/test_mcmc.py -k x64
- name: Test chains
run: |
XLA_FLAGS="--xla_force_host_platform_device_count=2" pytest -vs test/test_mcmc.py -k "chain or pmap or vmap"
XLA_FLAGS="--xla_force_host_platform_device_count=2" pytest -vs test/infer/test_mcmc.py -k "chain or pmap or vmap"
XLA_FLAGS="--xla_force_host_platform_device_count=2" pytest -vs test/contrib/test_tfp.py -k "chain"
XLA_FLAGS="--xla_force_host_platform_device_count=2" pytest -vs test/infer/test_hmc_gibbs.py -k "chain"
examples:
Expand All @@ -86,7 +118,7 @@ jobs:
needs: lint
strategy:
matrix:
python-version: [3.6]
python-version: [3.7]

steps:
- uses: actions/checkout@v2
Expand All @@ -103,8 +135,5 @@ jobs:
pip install .[dev,examples,test]
pip freeze
- name: Test with pytest
run: |
pytest -vs -k test_example
- name: Test chains
run: |
XLA_FLAGS="--xla_force_host_platform_device_count=2" pytest -vs -k test_example
60 changes: 60 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Development

Please follow our established coding style including variable names, module imports, and function definitions.
The NumPyro codebase follows the [PEP8 style guide](https://www.python.org/dev/peps/pep-0008/)
(which you can check with `make lint`) and follows
[`isort`](https://github.com/timothycrosley/isort) import order (which you can enforce with `make format`).

# Setup

To set up local development environment, install NumPyro from source:

```sh
git clone https://github.com/pyro-ppl/numpyro.git
# install jax/jaxlib first for CUDA support
pip install -e .[dev,test] # contains additional dependencies for NumPyro development
```

# Testing

Before submitting a pull request, please autoformat code and ensure that unit tests pass locally
```sh
make lint # linting
make format # runs black and isort
make test # linting and unit tests
make doctest # test module's docstrings
```

To run all tests locally in parallel, use the `pytest-xdist` package
```sh
pip install pytest-xdist
pytest -vs -n auto
```

To run a single test from the command line
```sh
pytest -vs {path_to_test}::{test_name}
# or in cuda mode and double precision
JAX_PLATFORM_NAME=gpu JAX_ENABLE_X64=1 pytest -vs {path_to_test}::{test_name}
```

# Profiling

TensorBoard can be used to profile NumPyro following the instructions following [JAX documentation](https://jax.readthedocs.io/en/latest/profiling.html).

# Submitting

For relevant design questions to consider, see past [design documents](https://github.com/pyro-ppl/pyro/wiki/Design-Docs).

For larger changes, please open an issue for discussion before submitting a pull request.

In your PR, please include:
- Changes made
- Links to related issues/PRs
- Tests
- Dependencies

If you add new files, please run `make license` to automatically add copyright headers.

For speculative changes meant for early-stage review, include `[WIP]` in the PR's title.
(One of the maintainers will add the `WIP` tag.)
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ all: test

lint: FORCE
flake8
black --check .
isort --check .
python scripts/update_headers.py --check

format: FORCE
isort -rc .
license: FORCE
python scripts/update_headers.py

format: license FORCE
black .
isort .

install: FORCE
pip install -e .[dev,doc,test,examples]

doctest: FORCE
$(MAKE) -C docs doctest
JAX_PLATFORM_NAME=cpu $(MAKE) -C docs doctest

test: lint FORCE
pytest -v test
Expand Down
Loading

0 comments on commit f5b3b50

Please sign in to comment.