Contributing#
TorchUncertainty is in early development stage. We are looking for contributors to help us build a comprehensive library for uncertainty quantification in PyTorch.
We are particularly open to any comment that you would have on this project. Specifically, we are open to changing these guidelines as the project evolves.
The scope of TorchUncertainty#
TorchUncertainty can host any method - if possible linked to a paper - and roughly contained in the following fields:
Uncertainty quantification in general, including Bayesian deep learning, Monte Carlo dropout, ensemble methods, etc.
Out-of-distribution detection methods
Applications (e.g. object detection, segmentation, etc.)
Common guidelines#
Clean development install of TorchUncertainty#
If you are interested in contributing to torch_uncertainty, we first advise you to follow the following steps to reproduce a clean development environment ensuring continuous integration does not break.
Install
uvfollowing the steps hereClone the repository
Install torch-uncertainty with the dev packages:
uv sync --extra gpufor GPU-based systems oruv sync --extra cpuif no GPUs are available
Note
Failure to include the extra flag will result in the GPU version of PyTorch without CUDA and might cause issues.
Install pre-commit hooks with
uv run pre-commit install
Build the documentation locally#
To build the documentation on Linux, navigate to ./docs and build the documentation with:
make html
Optionally, specify html-noplot instead of html to avoid running the tutorials.
This option is necessary if you only have a CPU on your machine.
Guidelines#
Code quality
We use ruff for code formatting, linting, and imports (as a drop-in replacement for black, isort, and flake8). The pre-commit hooks will ensure that your code is properly formatted and linted before committing.
To ensure that your code complies with the standards, run the following and check for warnings:
uv run ruff check --fix
And then:
uv run ruff format
Please ensure that the tests are passing on your machine before pushing on a PR. This will avoid multiplying the number of featureless commits. To do this, run, at the root of the folder:
uv run pytest tests
Commit message convention
We follow a structured commit message format inspired by gitmoji and the Conventional Commits specification:
:emoji:(scope): description
Emoji: pick the most appropriate emoji from gitmoji to categorize the change at a glance.
Scope: a short identifier in parentheses describing the area of the codebase affected (e.g.
packed,metrics,docs,CI,all).Description: a concise summary of the change after the
:separator.Breaking changes: use
!before:to signal a breaking change.
Here are some examples from the project:
Commit message |
Meaning |
|---|---|
|
Bug fix in the CLI module |
|
New feature in losses |
|
Refactoring of segformer |
|
Fixing linter warnings across the codebase |
|
Documentation for the tabular module |
|
Test improvements |
|
Configuration/tooling changes |
|
Breaking change in routines |
Some of the most commonly used gitmoji in this project:
Emoji |
Code |
Use |
|---|---|---|
β¨ |
|
New feature |
π |
|
Bug fix |
β»οΈ |
|
Refactor code |
π |
|
Documentation |
π¨ |
|
Fix linter warnings |
β |
|
Add/fix tests |
π§ |
|
Configuration files |
π₯ |
|
Remove code or files |
β¬οΈ |
|
Upgrade dependencies |
π |
|
Fix CI build |
π· |
|
CI system changes |
π¨ |
|
Improve code structure/format |
π₯ |
|
Breaking changes |
π |
|
Code review changes |
For the full list of available emojis, visit gitmoji.dev.
You donβt need to follow this convention.
Pull requests
To make your changes, create a branch on a personal fork and create a PR when your contribution is mostly finished or if you need help.
PR naming convention
Pull requests should follow the same naming convention as commits:
:emoji:(scope): description
For instance: :sparkles:(datamodules): add support for CIFAR-100-C.
PR labels
Please flag your PRs with the appropriate labels to help maintainers triage and track changes. Common labels include:
enhancementβ new feature or improvementbugβ bug fixdocumentationβ documentation changesrefactorβ code restructuring without behavior changetestsβ test additions or fixesdependenciesβ dependency updatesbreaking-changeβ introduces a breaking changeneed-helpβ you need assistance from a maintainer
PR checklist
Check that your PR complies with the following conditions:
The name of your branch is not
mainnordev(see issue #58)Your PR does not reduce the code coverage
Your code is documented: the function signatures are typed, and the main functions have clear docstrings
Your code is mostly original, and the parts coming from licensed sources are explicitly stated as such
If you implement a method, please add a reference to the corresponding paper in the references page.
Also, remember to add TorchUncertainty to the list of libraries implementing this reference on PapersWithCode.
If you need help to implement a method, increase the coverage, or solve ruff-raised errors,
create the PR with the need-help flag and explain your problems in the comments. A maintainer
will do their best to help you.
Datasets & Datamodules#
We intend to include datamodules for the most popular datasets only.
Post-processing methods#
For now, we intend to follow scikit-learn style API for post-processing methods (except that we use a validation dataset instead of a numpy array). You may get inspiration from the already implemented temperature-scaling.
License#
If you feel that the current license is an obstacle to your contribution, let us know, and we may reconsider. However, the modelsβ weights hosted on Hugging Face are likely to remain Apache 2.0.