Skip to content

Commit 861bca0

Browse files
authored
[CI] --no-deps for installation with uv (#1493)
1 parent d92db40 commit 861bca0

6 files changed

Lines changed: 48 additions & 9 deletions

File tree

.github/unittest/linux/scripts/install.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ else
4444
fi
4545

4646
printf "* Installing tensordict\n"
47-
pip install -e .
47+
# Install runtime deps explicitly (except torch/torchvision which are handled above),
48+
# then install tensordict without resolving dependencies to avoid any solver changing
49+
# the PyTorch build (stable vs nightly).
50+
python -m pip install -U packaging pyvers importlib_metadata
51+
python -m pip install -e . --no-deps
4852

4953
# smoke test
5054
python -c "import functorch"

.github/workflows/benchmarks.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ jobs:
7979
uv pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu126
8080
uv pip install "pybind11[global]" "setuptools" "wheel" "ninja"
8181
uv pip install pytest pytest-benchmark
82-
uv pip install -e .
82+
# Do not resolve runtime dependencies here: we want to keep the PyTorch build (nightly)
83+
# that was explicitly installed above, and avoid any solver replacing it.
84+
uv pip install -e . --no-deps
85+
uv run --active python -c "import torch; print(torch.__version__); assert 'dev' in torch.__version__, 'Expected a PyTorch nightly build'"
8386
${{ matrix.device == 'CPU' && 'export CUDA_VISIBLE_DEVICES=' || '' }}
8487
- name: check GPU presence
8588
if: matrix.device == 'GPU'
@@ -162,8 +165,6 @@ jobs:
162165
github-token: ${{ secrets.GITHUB_TOKEN }}
163166
gh-pages-branch: gh-pages
164167
auto-push: true
165-
# Use regular comments instead of PR reviews to avoid permission issues
166-
comment-style: 'github'
167168

168169
- name: Store GPU benchmark results
169170
uses: benchmark-action/github-action-benchmark@v1
@@ -179,5 +180,3 @@ jobs:
179180
github-token: ${{ secrets.GITHUB_TOKEN }}
180181
gh-pages-branch: gh-pages
181182
auto-push: true
182-
# Use regular comments instead of PR reviews to avoid permission issues
183-
comment-style: 'github'

.github/workflows/benchmarks_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
uv pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu126
6969
uv pip install "pybind11[global]" "setuptools" "wheel" "ninja"
7070
uv pip install pytest pytest-benchmark
71-
uv pip install -e .
71+
uv pip install -e . --no-deps
7272
${{ matrix.device == 'CPU' && 'export CUDA_VISIBLE_DEVICES=' || '' }}
7373
- name: check GPU presence
7474
if: matrix.device == 'GPU'

.github/workflows/docs.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,21 @@ jobs:
5757
# Install PyTorch (CPU version for docs)
5858
python -m pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu -U --quiet --root-user-action=ignore
5959
60+
# Install tensordict runtime deps explicitly (except torch/torchvision which are handled above),
61+
# then install tensordict without resolving dependencies to avoid any solver changing the
62+
# PyTorch build (stable vs nightly).
63+
python -m pip install -U packaging pyvers importlib_metadata --quiet --root-user-action=ignore
64+
6065
# Set up versioning environment (conditional on release branch/tag)
6166
export GITHUB_REF_TYPE=${{ github.ref_type }}
6267
export GITHUB_REF_NAME=${{ github.ref_name }}
6368
source .github/scripts/version_script.sh
6469
6570
# Install tensordict -- install as develop if not on a release branch
6671
if [[ ${{ github.ref_type }} == branch && ${{ github.ref_name }} == release/* ]] || [[ ${{ github.ref_type }} == tag ]]; then
67-
python -m pip install .
72+
python -m pip install . --no-deps
6873
else
69-
python -m pip install -e .
74+
python -m pip install -e . --no-deps
7075
fi
7176
7277
# Install docs requirements

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,31 @@ To enjoy the latest features, one can use
143143
pip install tensordict-nightly
144144
```
145145

146+
**With uv + PyTorch nightlies**:
147+
148+
If you're using a **PyTorch nightly** (e.g. installed from the PyTorch nightly wheel index), then for **editable**
149+
installs you should install tensordict with **`--no-deps`**.
150+
151+
This avoids uv re-resolving `torch` from its configured indexes (by default: PyPI), which can otherwise replace an
152+
existing nightly with the latest stable `torch`.
153+
154+
This is an **uv-specific** behavior; plain `pip install -e .` typically won’t replace an already-installed PyTorch
155+
nightly.
156+
157+
To keep a nightly `torch` with an editable install:
158+
159+
- install without resolving deps (**recommended**):
160+
161+
```bash
162+
uv pip install -e . --no-deps
163+
```
164+
165+
- or (less recommended) explicitly point uv at the PyTorch nightly wheel index (CPU shown; use the appropriate backend directory like `cu126/`):
166+
167+
```bash
168+
uv pip install -e . --prerelease=allow -f "https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html"
169+
```
170+
146171
**With Conda**:
147172

148173
Install `tensordict` from `conda-forge` channel.

docs/source/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ or via a `git clone` if you're willing to contribute to the library:
5656
$ cd tensordict
5757
$ pip install -e .
5858
59+
.. note::
60+
61+
If you're using **uv** with a **PyTorch nightly** installed from the PyTorch nightly wheel index,
62+
prefer installing tensordict editable with ``--no-deps`` (or configure uv to use the nightly wheel index),
63+
otherwise uv may re-resolve and replace the existing nightly ``torch`` with a stable build from PyPI.
64+
5965
Tutorials
6066
=========
6167

0 commit comments

Comments
 (0)