@@ -12,14 +12,35 @@ mandatory, we only provide installation steps with this tool. You can install it
12121 ) Pre-requisites: Use ` uv ` to install a Python version compatible with TorchJD and to pin it to the
1313 ` torchjd ` folder. From the root of the ` torchjd ` repo, run:
1414 ``` bash
15- uv python install 3.13.3
16- uv python pin 3.13.3
15+ uv python install 3.14.0
16+ uv python pin 3.14.0
1717 ```
1818
19192 ) Create a virtual environment and install the project in it. From the root of ` torchjd ` , run:
2020 ``` bash
2121 uv venv
22- CC=gcc uv pip install -e ' .[full]' --group check --group doc --group test --group plot
22+ CC=gcc uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot
23+ ```
24+ If you want to install PyTorch with a different CUDA version (this could be required depending on
25+ your GPU), you'll need to specify and extra index. For instance, for CUDA 12.6, run:
26+ ``` bash
27+ uv venv
28+ CC=gcc uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot --index-strategy unsafe-best-match --extra-index-url https://download.pytorch.org/whl/cu126
29+ ```
30+
31+ We also advise using ` UV_NO_SYNC=1 ` to prevent ` uv ` from syncing all the time. This is because by
32+ default, it tries to resolve libraries compatible with the whole range of Python versions
33+ supported by TorchJD, but in reality, we just need an installation compatible with the currently
34+ used Python version. That's also why we specify ` --python-version=3.14 ` when running
35+ ` uv pip install ` . To follow that recommendation, add the following line to your ` .bashrc ` :
36+ ``` bash
37+ export UV_NO_SYNC=1
38+ ```
39+ and start a new terminal. The alternative is to use the ` --no-sync ` flag whenever you run a pip
40+ command that would normally sync (like ` uv run ` ).
41+
42+ 3 ) Install pre-commit:
43+ ``` bash
2344 uv run pre-commit install
2445 ```
2546
@@ -37,12 +58,30 @@ mandatory, we only provide installation steps with this tool. You can install it
3758> created by ` uv ` , using ` source .venv/bin/activate ` from the root of ` torchjd ` . This will, however,
3859> only work in the current terminal until it is closed.
3960
61+
62+ ## Clean reinstallation
63+
64+ If you want to update all dependencies or just reinstall from scratch, run the following command
65+ from the root of ` torchjd ` :
66+ ``` bash
67+ rm -rf .venv
68+ rm uv.lock
69+ uv venv
70+ CC=gcc uv pip install --python-version=3.14 -e ' .[full]' --group check --group doc --group test --group plot
71+ uv run pre-commit install
72+ ```
73+
4074## Running tests
41- - To verify that your installation was successful, and that all unit tests pass, run:
75+ - To verify that your installation was successful, and that unit tests pass, run:
4276 ``` bash
4377 uv run pytest tests/unit
4478 ```
4579
80+ - To also run the unit tests that are marked as slow, add the ` --runslow` flag:
81+ ` ` ` bash
82+ uv run pytest tests/unit --runslow
83+ ` ` `
84+
4685 - If you have access to a cuda-enabled GPU, you should also check that the unit tests pass on it:
4786 ` ` ` bash
4887 CUBLAS_WORKSPACE_CONFIG=:4096:8 PYTEST_TORCH_DEVICE=cuda:0 uv run pytest tests/unit
@@ -100,29 +139,31 @@ We ask contributors to implement the unit tests necessary to check the correctne
100139implementations. Besides, whenever usage examples are provided, we require the example' s code to be
101140tested in `tests/doc`. We require a very high code coverage for newly introduced sources (~95-100%).
102141To ensure that the tensors generated during the tests are on the right device, you have to use the
103- partial functions defined in `tests/unit/_utils.py` to instantiate tensors. For instance, instead of
142+ partial functions defined in `tests/utils/tensors.py` to instantiate tensors. For instance, instead
143+ of
104144```python
105145import torch
106146a = torch.ones(3, 4)
107147```
108148use
109149```python
110- from unit._utils import ones_
150+ from utils.tensors import ones_
111151a = ones_(3, 4)
112152```
113153
114- This will automatically call `torch.ones` with `device=unit.conftest. DEVICE`.
115- If the function you need does not exist yet as a partial function in `_utils .py`, add it.
154+ This will automatically call `torch.ones` with `device=DEVICE`.
155+ If the function you need does not exist yet as a partial function in `tensors .py`, add it.
116156Lastly, when you create a model or a random generator, you have to move them manually to the right
117- device (the `DEVICE` defined in `unit.conftest`):
157+ device (the `DEVICE` defined in `device.py`).
118158```python
119159import torch
120160from torch.nn import Linear
121- from unit.conftest import DEVICE
161+ from device import DEVICE
122162
123163model = Linear(3, 4).to(device=DEVICE)
124164rng = torch.Generator(device=DEVICE)
125165```
166+ You may also use a `ModuleFactory` to make the modules on `DEVICE` automatically.
126167
127168### Coding
128169
@@ -149,6 +190,11 @@ implementation of a mathematical aggregator.
149190> Before working on the implementation of a new aggregator, please contact us via an issue or a
150191> discussion: in many cases, we have already thought about it, or even started an implementation.
151192
193+ ## Deprecation
194+
195+ To deprecate some public functionality, make it raise a `DeprecationWarning`. A test should also be
196+ added in `tests/units/test_deprecations.py`, ensuring that this warning is issued.
197+
152198## Release
153199
154200*This section is addressed to maintainers.*
0 commit comments