How to Contribute ? 💜

Since you landed on this part of the documentation, we want to first of all say thank you! 💜 Contributions from the community are essential to improving pruna, we appreciate your effort in making the repository better for everyone!

Please make sure to review and adhere to the Pruna Code of Conduct and AI Contribution Policy before contributing to Pruna. Contributions that do not adhere to the code of conduct or AI contribution policy will be ignored.

If you don’t have uv installed, you can install it by following the instructions on the uv website.

There are various ways you can contribute:

Setup

If you want to contribute to pruna with a Pull Request, you can do so by following these steps. If it is your very first time contributing to an open source project, we recommend to start with this guide for some generally helpful tips.

1. Clone the repository

First, fork the repository by navigating to the original pruna repository on GitHub and click the Fork button at the top-right. This creates a copy of the repository in your own GitHub account. Then, clone the forked repository from your account to your local machine and change into its directory:

git clone https://github.com/your_username/pruna.git
cd pruna

To keep your fork up to date with the original repository, add the upstream remote:

git remote add upstream https://github.com/PrunaAI/pruna.git

Always work on a new branch rather than the main branch. You can create a new branch for your feature or fix:

git checkout -b feat/new-feature

2. Installation

You have two options for installing dependencies:

Option A: Using uv with its own virtual environment (recommended)

uv sync --extra dev

This creates a virtual environment in .venv/ and installs all dependencies there, including pruna itself in editable mode. Important: This does NOT install into your current conda environment! You’ll need to use uv run for all commands.

Option B: Installing into your current environment (conda/pip)

If you want to install directly into your current conda environment or use pip:

pip install -e .
pip install -e .[dev]

This installs dependencies directly in your current environment.

You can then also install the pre-commit hooks with

pre-commit install

3. Develop your contribution

You are now ready to work on your contribution. Check out a branch on your forked repository and start coding! When committing your changes, we recommend to follow the Conventional Commit Guidelines.

git checkout -b feat/new-feature
git add .
git commit -m "feat: new amazing feature setup"
git push origin feat/new-feature

Make sure to develop your contribution in a way that is well documented, concise and easy to maintain. We will do our best to have your contribution integrated and maintained into pruna but reserve the right to reject contributions that we do not feel are in the best interest of the project.

Tensor Annotations with jaxtyping

We use jaxtyping to annotate PyTorch tensors with both shape and dtype information, mainly in collate functions, dataloaders, and model interfaces. This improves readability, helps catch shape/type mismatches early, and makes functions more self-documenting. Contributors are encouraged to follow this style when defining tensor inputs or outputs—for details and examples, see the official jaxtyping documentation.

How to add a new dependency

Your contribution may require packages that pruna does not yet list as a dependency. Declare them in pyproject.toml and mention them in your pull request so reviewers can weigh impact and versioning.

Use the dependencies section when the library is generally required for pruna to work as intended across typical usage.

If it should not be installed for every pruna user, put it under optional-dependencies. This often applies when a dependency is too heavy or platform-specific, or only needed for one backend. Then follow these steps to add a new optional extra:

  1. Define the dependency group in pyproject.toml under [project.optional-dependencies]. Then go through the installation process with uv (see installation) and register conflicts with other extras by extending the conflicts under [tool.uv].

  2. If this extra is required for an algorithm, set the required_install attribute on the algorithm class, for example required_install = "uv pip install 'pruna[my-extra]'".

  3. Register a matching requires_my_extra marker in tests/conftest.py and mark tests that need the extra.

  4. Finally, if CPU tests rely on that extra, update .github/workflows/tests.yaml: append your extra to the test job’s strategy:

    name: [..., my-extra]
    matrix:
        include:
        # ...
        - name: my-extra
            extras: "--extra my-extra"
            mark_filter: "requires_my_extra"
    

4. Run the tests

We have a comprehensive test suite that is designed to catch potential issues before they are merged into pruna. When you make a contribution, it is highly recommended to not only run the existing tests but also to add new tests that cover your contribution.

You can run the tests depending on which installation option you chose:

If you used Option A (uv):

uv run pytest

For specific test markers:

uv run pytest -m "cpu and not slow"

If you used Option B (pip/conda):

pytest

For specific test markers:

pytest -m "cpu and not slow"

Note: uv run automatically uses uv’s virtual environment in .venv/, not your conda environment.

5. Create a Pull Request

Once you have made your changes and tested them, you can create a Pull Request. We will then review your Pull Request and get back to you as soon as possible. If there are any questions along the way, please do not hesitate to reach out on Discord.