Skip to content

Latest commit

 

History

History
98 lines (72 loc) · 2.73 KB

CONTRIBUTING.md

File metadata and controls

98 lines (72 loc) · 2.73 KB

Development

Please follow our established coding style including variable names, module imports, and function definitions. The Pyro codebase follows the PEP8 style guide (which you can check with make lint) and follows isort import order (which you can enforce with make format).

Setup

First install PyTorch.

Then, install all the dev dependencies for Pyro.

make install

or explicitly

pip install -e .[dev]

Testing

Before submitting a pull request, please autoformat code and ensure that unit tests pass locally

make format            # runs isort
make test              # linting and unit tests

If you've modified core pyro code, examples, or tutorials, you can run more comprehensive tests locally

make test-examples     # test examples/
make integration-test  # longer-running tests (may take hours)
make test-cuda         # runs unit tests in cuda mode

To run all tests locally in parallel, use the pytest-xdist package

pip install pytest-xdist
pytest -vs -n auto

To run a single test from the command line

pytest -vs {path_to_test}::{test_name}

Profiling

The profiler module contains scripts to support profiling different Pyro modules, as well as test for performance regression.

To run the profiling utilities, ensure that all dependencies for profiling are satisfied, by running make install, or more specifically, pip install -e .[profile].

There are some generic test cases available in the profiler module. Currently, this supports only the distributions library, but we will be adding test cases for inference methods soon.

Some useful invocations

To get help on the parameters that the profiling script takes, run:

python -m profiler.distributions --help

To run the profiler on all the distributions, simply run:

python -m profiler.distributions

To run the profiler on a few distributions by varying the batch size, run:

python -m profiler.distributions --dist bernoulli normal --batch_sizes 1000 100000 

To get more details on the potential sources of slowdown, use the cProfile tool as follows:

python -m profiler.distributions --dist bernoulli --tool cprofile

Submitting

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

Please add the awaiting review tag and add any of the core Pyro contributors as reviewers. For speculative changes meant for early-stage review, add the WIP tag. Our policy is to require the reviewer to merge the PR, rather than the PR author.