This document covers the technical details of making your contributions to the code of hivemind. For other ways to contribute, read the contributing guide in our documentation.
Before you begin, file a new issue on GitHub or announce that you are going to work on an existing one to avoid duplicate effort. After you finish, submit a pull request and wait for it to be reviewed by the library maintainers (and possibly other community members).
First, install hivemind in the development mode, preferably with Python 3.8 on Linux.
git clone https://github.com/learning-at-home/hivemind
cd hivemind
pip install -e .
To make sure that the reviewers will request minimal changes in your PR, you can check that your contribution complies with the following rules:
get_logger
from hivemind.utils.logging
to log any information instead of print
ing directly to standard
output/error streams.To make sure that each change to hivemind is consistent across the entire project history and is easy to review by any community member, follow these guidelines when submitting your pull request and writing commit messages. The library maintainers use the same rules when merging your commits into the master branch after the PR approval.
To ensure a consistent format across the entire repository history, please follow the following rules when formatting your commits (especially for PR merge commits):
It is not required to use this format while you are still working on your pull request. However, each merged PR commit message has to adhere to these guidelines, and it will be easier for the maintainers to accept the PR if you have already done most of the necessary formatting work.
For further reading on the commit message format, see this guide on good Git commit messages, as well as this repository.
All commits from a pull request are squashed before merging to ensure a clean commit history in the master branch. The merge commit title is the name of the pull request along with the PR number reference; the merge commit body is either the pull request description (if it adheres to the format) or a cleaned up compilation of PR branch commit messages.
Implement decentralized parameter averaging
with Add hivemind.client.averaging
.For more on the philosophy of easy-to-review pull requests, read these guides: 1 2 . If the changelist is not very large (more than a hundred lines) already, we encourage making small improvements to the codebase in the files already changed by the PR; however, they should not dilute its major purpose.
Hivemind uses pytest for testing the behavior of the library modules. If you implement a new part of the library, you are expected to write a test for the correctness of its implementation. If you discovered a bug in the existing code base and intend to fix it, it's also best if you add the steps to reproduce it as a new test to make sure it's not reintroduced by future changes.
To run tests, you need to install hivemind in development mode with additional dependencies: pip install -e .[dev]
.
You can run all tests with pytest tests/
or choose a specific subset, e.g., pytest tests/test_dht.py
.
Any function exposed to a user must have a docstring compatible with Sphinx, which is used for building the online documentation.
To build the docs locally,
pip install -e .[docs]
cd ./docs && make html
The documentation root will be available in ./docs/_build/html/index.html
Currently, hivemind has three benchmark scripts for evaluating the impact of code changes on the most performance-sensitive parts of the library. If you make a change that might introduce a regression, you may be asked by the maintainers to provide the benchmarking results for your branch and a comparison with the master branch.
tests/benchmark_averaging.py
measures the performance of decentralized parameter averaging across the DHT.tests/benchmark_dht.py
measures the performance of core DHT operations.tests/benchmark_throughput.py
measures the performance of a server hosting several expert layers under heavy load
from multiple clients.Example benchmark runs are available in the benchmarking page of the documentation.
For more details on overall contributions, visit the contributing guide at:
https://learning-at-home.readthedocs.io/en/latest/user/contributing.html
This guide was inspired by several influential Python open source projects listed below: