Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/scripts/pre-build-script-win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pip install --upgrade setuptools packaging
${CONDA_RUN} pip install "pybind11[global]"
${CONDA_RUN} pip install cloudpickle importlib_metadata numpy orjson "pyvers>=0.2.0,<0.3.0"

# Determine tensordict installation source based on branch/tag
# - release/* branches or release tags: use PyPI stable release
Expand All @@ -28,5 +29,3 @@ install_tensordict() {
}

install_tensordict

export TORCHRL_BUILD_VERSION=0.10.0
11 changes: 6 additions & 5 deletions .github/scripts/pre-build-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
${CONDA_RUN} pip install --upgrade setuptools packaging

${CONDA_RUN} pip install "pybind11[global]"
${CONDA_RUN} pip install cloudpickle importlib_metadata numpy orjson "pyvers>=0.2.0,<0.3.0"
${CONDA_RUN} conda install anaconda::cmake -y

# Determine tensordict installation source based on branch/tag
Expand All @@ -16,19 +17,19 @@ install_tensordict() {

if [[ "$source" == "stable" ]]; then
echo "Installing tensordict from PyPI (stable) - explicit override"
${CONDA_RUN} pip install tensordict -U
${CONDA_RUN} pip install tensordict -U --no-deps
elif [[ "$source" == "git" ]]; then
echo "Installing tensordict from git - explicit override"
${CONDA_RUN} pip install git+https://github.com/pytorch/tensordict.git -U
${CONDA_RUN} pip install git+https://github.com/pytorch/tensordict.git -U --no-deps
elif [[ "$GITHUB_REF_TYPE" == "branch" && "$GITHUB_REF_NAME" == release/* ]]; then
echo "Installing tensordict from PyPI (stable) - detected release branch: $GITHUB_REF_NAME"
${CONDA_RUN} pip install tensordict -U
${CONDA_RUN} pip install tensordict -U --no-deps
elif [[ "$GITHUB_REF_TYPE" == "tag" && "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Installing tensordict from PyPI (stable) - detected release tag: $GITHUB_REF_NAME"
${CONDA_RUN} pip install tensordict -U
${CONDA_RUN} pip install tensordict -U --no-deps
else
echo "Installing tensordict from git - branch: ${GITHUB_REF_NAME:-unknown}, type: ${GITHUB_REF_TYPE:-unknown}"
${CONDA_RUN} pip install git+https://github.com/pytorch/tensordict.git -U
${CONDA_RUN} pip install git+https://github.com/pytorch/tensordict.git -U --no-deps
fi
}

Expand Down
3 changes: 2 additions & 1 deletion .github/scripts/td_script.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

export TORCHRL_BUILD_VERSION=0.12.0
export TORCHRL_BUILD_VERSION="${BUILD_VERSION:-0.12.0}"
${CONDA_RUN} pip install --upgrade setuptools packaging

# Always install pybind11 - required for building C++ extensions
${CONDA_RUN} pip install "pybind11[global]"
${CONDA_RUN} pip install cloudpickle importlib_metadata numpy orjson "pyvers>=0.2.0,<0.3.0"

# Check if ARCH is set to aarch64
ARCH=${ARCH:-} # This sets ARCH to an empty string if it's not defined
Expand Down
6 changes: 5 additions & 1 deletion .github/scripts/version_script.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@echo off
set TORCHRL_BUILD_VERSION=0.12.0
if "%BUILD_VERSION%" == "" (
set TORCHRL_BUILD_VERSION=0.12.0
) else (
set TORCHRL_BUILD_VERSION=%BUILD_VERSION%
)
echo TORCHRL_BUILD_VERSION is set to %TORCHRL_BUILD_VERSION%

@echo on
Expand Down
99 changes: 99 additions & 0 deletions .github/unittest/helpers/assert_torch_tensordict_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env bash
# Assert that the installed PyTorch and TensorDict builds match the CI mode.
#
# Usage:
# bash assert_torch_tensordict_versions.sh nightly [auto|main|nightly|stable]
# bash assert_torch_tensordict_versions.sh stable [auto|main|nightly|stable]
#
# By default (auto), nightly PyTorch expects TensorDict from main/git and stable
# PyTorch expects a stable TensorDict release. Some jobs intentionally pin stable
# PyTorch while testing TensorDict main; pass "main" explicitly for those jobs.
# Nightly wheel jobs install the dated TensorDict nightly package; pass "nightly"
# explicitly for those jobs.
set -euo pipefail

expected_torch="${1:?Usage: assert_torch_tensordict_versions.sh nightly|stable [auto|main|nightly|stable]}"
expected_tensordict="${2:-auto}"

PYTHON="${PYTHON:-$(command -v python3 || command -v python)}"

"$PYTHON" - "$expected_torch" "$expected_tensordict" <<'PY'
from __future__ import annotations

import importlib.metadata
import re
import sys

import tensordict
import torch

expected_torch = sys.argv[1]
expected_tensordict = sys.argv[2]

if expected_torch not in {"nightly", "stable"}:
raise RuntimeError(
"Expected PyTorch mode must be 'nightly' or 'stable', "
f"got {expected_torch!r}."
)

if expected_tensordict == "auto":
expected_tensordict = "main" if expected_torch == "nightly" else "stable"
elif expected_tensordict not in {"main", "nightly", "stable"}:
raise RuntimeError(
"Expected TensorDict source must be 'auto', 'main', 'nightly', or "
"'stable', "
f"got {expected_tensordict!r}."
)

torch_version = torch.__version__
torch_is_nightly = "dev" in torch_version
expected_torch_is_nightly = expected_torch == "nightly"
if torch_is_nightly != expected_torch_is_nightly:
raise RuntimeError(
f"PyTorch version mismatch: expected {expected_torch} but got "
f"torch {torch_version}."
)

try:
tensordict_version = tensordict.__version__
except AttributeError:
tensordict_version = importlib.metadata.version("tensordict")

try:
tensordict_dist = importlib.metadata.distribution("tensordict")
tensordict_direct_url = tensordict_dist.read_text("direct_url.json") or ""
except importlib.metadata.PackageNotFoundError:
tensordict_direct_url = ""

tensordict_from_main = bool(
re.search(r"(?:\.dev|\+g|dev)", tensordict_version)
or "github.com/pytorch/tensordict" in tensordict_direct_url
)
tensordict_from_nightly = bool(re.match(r"^\d{4}\.\d{2}\.\d{2}", tensordict_version))

if expected_tensordict == "main" and not tensordict_from_main:
raise RuntimeError(
"TensorDict source mismatch: expected TensorDict from main/git but got "
f"tensordict {tensordict_version}."
)

if expected_tensordict == "nightly" and not tensordict_from_nightly:
raise RuntimeError(
"TensorDict source mismatch: expected a TensorDict nightly release but "
f"got tensordict {tensordict_version}."
)

if expected_tensordict == "stable" and (
tensordict_from_main or tensordict_from_nightly
):
raise RuntimeError(
"TensorDict source mismatch: expected a stable TensorDict release but got "
f"tensordict {tensordict_version}."
)

print(f"PyTorch version check OK: torch {torch_version} (expected {expected_torch})")
print(
"TensorDict source check OK: "
f"tensordict {tensordict_version} (expected {expected_tensordict})"
)
PY
9 changes: 5 additions & 4 deletions .github/unittest/linux/scripts/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ uv_pip_install \
# labmaze (dm_control dependency) doesn't have Python 3.13+ wheels
if [[ "$PYTHON_VERSION" != "3.13" && "$PYTHON_VERSION" != "3.14" ]]; then
echo "installing dm_control"
uv_pip_install dm_control
uv_pip_install "dm_control>=1.0.41" "mujoco>=3.8.1,<3.9.0"
fi

# Install ray for Python < 3.14 (ray doesn't support Python 3.14 yet)
Expand All @@ -158,7 +158,7 @@ fi
# Install mujoco for Python < 3.14 (mujoco doesn't have Python 3.14 wheels yet)
if [[ "$PYTHON_VERSION" != "3.14" ]]; then
echo "installing mujoco"
uv_pip_install "mujoco>=3.3.7"
uv_pip_install "mujoco>=3.8.1,<3.9.0"
fi

# Install gymnasium
Expand All @@ -168,9 +168,9 @@ if [[ "$PYTHON_VERSION" == "3.14" ]]; then
uv_pip_install "gymnasium>=1.1"
elif [[ "$PYTHON_VERSION" == "3.12" ]]; then
uv_pip_install ale-py sympy
uv_pip_install "gymnasium[mujoco]>=1.1" "mo-gymnasium[mujoco]"
uv_pip_install "gymnasium[mujoco]>=1.1" "mo-gymnasium[mujoco]" "mujoco>=3.8.1,<3.9.0"
else
uv_pip_install "gymnasium[atari,mujoco]>=1.1" "mo-gymnasium[mujoco]"
uv_pip_install "gymnasium[atari,mujoco]>=1.1" "mo-gymnasium[mujoco]" "mujoco>=3.8.1,<3.9.0"
fi

# sanity check
Expand Down Expand Up @@ -325,6 +325,7 @@ export PYTORCH_TEST_WITH_SLOW='1'
python -m torch.utils.collect_env

bash "${root_dir}/.github/unittest/helpers/assert_torch_version.sh" "$TORCH_VERSION"
bash "${root_dir}/.github/unittest/helpers/assert_torch_tensordict_versions.sh" "$TORCH_VERSION"

Xvfb :99 -screen 0 1024x768x24 &

Expand Down
1 change: 1 addition & 0 deletions .github/unittest/linux/scripts/run_setup_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@ else
fi

bash "${root_dir}/.github/unittest/helpers/assert_torch_version.sh" "$TORCH_VERSION"
bash "${root_dir}/.github/unittest/helpers/assert_torch_tensordict_versions.sh" "$TORCH_VERSION"

pytest -q test/test_setup.py -vv
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_ataridqn/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fi
python -c "import functorch;import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

# smoke test
python -c "import torchrl"
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_botorch/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pip install git+https://github.com/pytorch/tensordict.git --progress-bar off
python -c "import functorch;import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

# smoke test
python -c "import torchrl"
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_brax/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pip install git+https://github.com/pytorch/tensordict.git --progress-bar off
python -c "import functorch;import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

# smoke test
python -c "import torchrl"
1 change: 1 addition & 0 deletions .github/unittest/linux_libs/scripts_brax/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
bash ${this_dir}/setup_env.sh
bash ${this_dir}/install.sh
PYTHON=./env/bin/python bash "$(git rev-parse --show-toplevel)/.github/unittest/helpers/assert_torch_version.sh" "$TORCH_VERSION"
PYTHON=./env/bin/python bash "$(git rev-parse --show-toplevel)/.github/unittest/helpers/assert_torch_tensordict_versions.sh" "$TORCH_VERSION"
bash ${this_dir}/run_test.sh
bash ${this_dir}/post_process.sh
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_chess/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fi
python -c "import functorch;import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

# smoke test
python -c "import torchrl"
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_d4rl/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fi
python -c "import functorch;import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

# smoke test
python -c "import torchrl"
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_envpool/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ else
fi

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_gen-dgrl/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fi
python -c "import functorch;import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

# smoke test
python -c "import torchrl"
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_genesis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fi
python -c "import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

python -c "import torchrl"

Expand Down
4 changes: 2 additions & 2 deletions .github/unittest/linux_libs/scripts_gym/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ export pybind11_DIR
printf "* Installing tensordict\n"
if [[ "$RELEASE" == 0 ]]; then
# Install tensordict dependencies (since we use --no-deps)
uv pip install cloudpickle packaging importlib_metadata orjson "pyvers>=0.1.0,<0.2.0"
uv pip install cloudpickle packaging importlib_metadata numpy orjson "pyvers>=0.2.0,<0.3.0"
uv pip install --no-build-isolation --no-deps git+https://github.com/pytorch/tensordict.git
else
uv pip install cloudpickle packaging importlib_metadata orjson "pyvers>=0.1.0,<0.2.0"
uv pip install cloudpickle packaging importlib_metadata numpy orjson "pyvers>=0.2.0,<0.3.0"
uv pip install --no-deps tensordict
fi

Expand Down
12 changes: 6 additions & 6 deletions .github/unittest/linux_libs/scripts_habitat/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ git submodule sync && git submodule update --init --recursive

printf "Installing PyTorch with %s\n" "${CU_VERSION}"
if [[ "$TORCH_VERSION" == "nightly" ]]; then
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128 -U
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/"${CU_VERSION}" -U
elif [[ "$TORCH_VERSION" == "stable" ]]; then
pip3 install torch --index-url https://download.pytorch.org/whl/cu128
pip3 install torch --index-url https://download.pytorch.org/whl/"${CU_VERSION}"
fi

# install tensordict
# install tensordict
pip3 install cloudpickle packaging importlib_metadata numpy orjson "pyvers>=0.2.0,<0.3.0"
if [[ "$RELEASE" == 0 ]]; then
pip3 install git+https://github.com/pytorch/tensordict.git
pip3 install --no-deps git+https://github.com/pytorch/tensordict.git
else
pip3 install tensordict
pip3 install --no-deps tensordict
fi

# smoke test
python -c "import functorch;import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

# smoke test
python -c "import torchrl"
16 changes: 12 additions & 4 deletions .github/unittest/linux_libs/scripts_habitat/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ set -euxo pipefail
set -v


apt-get update && apt-get upgrade -y
apt-get update
apt-get install -y vim git wget cmake ninja-build

# OpenGL/EGL dependencies for headless rendering
apt-get install -y libglfw3 libglfw3-dev libgl1-mesa-glx libosmesa6 libosmesa6-dev libglew-dev
apt-get install -y libxinerama-dev libxcursor-dev libxi-dev libxrandr-dev libxxf86vm-dev
apt-get install -y libglvnd0 libgl1 libglx0 libegl1 libgles2
apt-get install -y libegl1-mesa-dev libgles2-mesa-dev

Expand All @@ -19,16 +20,23 @@ apt-get install -y pkg-config

#apt-get upgrade -y libstdc++6
#apt-get install -y libgcc
apt-get dist-upgrade -y

this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# from cudagl docker image
cp $this_dir/10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json

bash ${this_dir}/setup_env.sh
bash ${this_dir}/install.sh

PYTHON=./env/bin/python bash "$(git rev-parse --show-toplevel)/.github/unittest/helpers/assert_torch_version.sh" "$TORCH_VERSION"
# habitat-lab currently resolves a stable PyTorch build after habitat-sim is
# installed. Keep validating TensorDict source, but accept stable PyTorch in
# this workflow even on non-release branches.
if [[ "$RELEASE" == 0 ]]; then
TENSORDICT_EXPECTATION=main
else
TENSORDICT_EXPECTATION=stable
fi
PYTHON=./env/bin/python bash "$(git rev-parse --show-toplevel)/.github/unittest/helpers/assert_torch_version.sh" stable
PYTHON=./env/bin/python bash "$(git rev-parse --show-toplevel)/.github/unittest/helpers/assert_torch_tensordict_versions.sh" stable "$TENSORDICT_EXPECTATION"

bash ${this_dir}/run_test.sh
bash ${this_dir}/post_process.sh
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_habitat/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ conda env update --file "${this_dir}/environment.yml" --prune

# 5. Install habitat-sim from source (conda packages don't support Python 3.10+)
# Install build dependencies
pip3 install ninja numpy
pip3 install ninja numpy scikit-build-core

# Clone and build habitat-sim from source
cd "${root_dir}"
Expand Down
2 changes: 1 addition & 1 deletion .github/unittest/linux_libs/scripts_jumanji/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi
python -c "import functorch;import tensordict"

printf "* Installing torchrl\n"
python -m pip install -e . --no-build-isolation
python -m pip install -e . --no-build-isolation --no-deps

# smoke test
python -c "import torchrl"
Loading
Loading