We are happy to accept contributions to PEFT. If you plan to contribute, please read this to make the process as smooth as possible.
For code contributions to PEFT, you should choose the “source” installation method.
If you are new to creating a pull request, follow the Creating a pull request guide by GitHub.
Regardless of the contribution type (unless it’s only about the docs), you should run tests and code quality checks before creating a PR to ensure your contribution doesn’t break anything and follows the project standards.
We provide a Makefile to execute the necessary tests. Run the code below for the unit test:
make test
Run one of the following to either only check or check and fix code quality and style:
make quality # just check
make style # check and fix
You can also set up pre-commit
to run these fixes
automatically as Git commit hooks.
$ pip install pre-commit $ pre-commit install
Running all the tests can take a couple of minutes, so during development it can be more efficient to only run tests specific to your change:
pytest tests/ -k <name-of-test>
This should finish much quicker and allow for faster iteration. However, you should still run the whole test suite before creating a PR because your change can inadvertently break tests that at first glance are unrelated.
If your change is specific to a hardware setting (e.g., it requires CUDA), take a look at tests/test_gpu_examples.py and tests/test_common_gpu.py to see if it makes sense to add tests there. If your change could have an effect on saving and loading models, please run the tests with the --regression
flag to trigger regression tests.
It can happen that while you’re working on your PR, the underlying code base changes due to other changes being merged. If that happens – especially when there is a merge conflict – please update your branch with the latest changes. This can be a merge or a rebase, and we’ll squash and merge the PR once it’s ready.
When opening a PR, please provide a nice description of the change you’re proposing. If it relates to other issues or PRs, please reference them. Providing a good description not only helps the reviewers review your code better and faster, it can also be used later (as a basis) for the commit message which helps with long term maintenance of the project.
If your code makes some non-trivial changes, it may also be a good idea to add comments to the code to explain those changes. For example, if you had to iterate on your implementation multiple times because the most obvious way didn’t work, it’s a good indication that a code comment is needed.
Please give a description of the circumstances that led to the bug. If there is an existing issue, please link to it (e.g., “Resolves #12345”).
Ideally when a bugfix is provided, it should be accompanied by a test for the bug. The test should fail with the current code and pass with the bugfix. Add a comment to the test that references the issue or PR. Without a test, it is more difficult to prevent regressions in the future.
New parameter-efficient fine-tuning methods are developed all the time. If you would like to add a new and promising method to PEFT, please follow these steps.
It is best if you first open an issue on GitHub with a proposal to add the new feature. This way, you can discuss with the maintainers if it makes sense to add the feature before spending too much time on implementing it.
New features should generally be accompanied by tests and documentation or examples. Without the latter, users will have a hard time discovering your cool new feature.
Changes to the code should be implemented in a backward-compatible way. For example, existing code should continue to work the same way after the feature is merged.