From 6c6992238ea6c8d9a612e7a19180642fbc623a35 Mon Sep 17 00:00:00 2001 From: Vincent Moens Date: Mon, 10 Mar 2025 16:32:13 +0000 Subject: [PATCH 1/2] Update [ghstack-poisoned] --- .github/scripts/td_script_agnostic.sh | 6 +++ .github/workflows/build-wheels-agnostic.yml | 48 +++++++++++++++++++++ setup.py | 19 ++++++++ 3 files changed, 73 insertions(+) create mode 100644 .github/scripts/td_script_agnostic.sh create mode 100644 .github/workflows/build-wheels-agnostic.yml diff --git a/.github/scripts/td_script_agnostic.sh b/.github/scripts/td_script_agnostic.sh new file mode 100644 index 00000000000..001d6c1ca88 --- /dev/null +++ b/.github/scripts/td_script_agnostic.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +export TORCHRL_BUILD_VERSION=0.8.0 +export NO_CPP_BINARIES=1 + +pip install git+https://github.com/pytorch/tensordict.git -U diff --git a/.github/workflows/build-wheels-agnostic.yml b/.github/workflows/build-wheels-agnostic.yml new file mode 100644 index 00000000000..748c4b8e9e5 --- /dev/null +++ b/.github/workflows/build-wheels-agnostic.yml @@ -0,0 +1,48 @@ +name: Build Linux Wheels + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + tags: + # NOTE: Binary build pipelines should only get triggered on release candidate builds + # Release candidate tags look like: v1.11.0-rc1 + - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ + workflow_dispatch: + +permissions: + id-token: write + contents: read + +jobs: + generate-matrix: + uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main + with: + package-type: wheel + os: linux + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build: + needs: generate-matrix + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/rl + smoke-test-script: test/smoke_test.py + package-name: torchrl + name: pytorch/rl + uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main + with: + repository: ${{ matrix.repository }} + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + package-name: ${{ matrix.package-name }} + smoke-test-script: ${{ matrix.smoke-test-script }} + trigger-event: ${{ github.event_name }} + env-var-script: .github/scripts/td_script_agnostic.sh diff --git a/setup.py b/setup.py index 711b48f5247..9d1b3b079c2 100644 --- a/setup.py +++ b/setup.py @@ -118,7 +118,26 @@ def run(self): # return None +def strtobool(val): + """Convert a string representation of truth to true (1) or false (0). + + True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values + are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if + 'val' is anything else. + """ + val = val.lower() + if val in (1, True, "y", "yes", "t", "true", "on", "1"): + return 1 + elif val in (0, False, "n", "no", "f", "false", "off", "0"): + return 0 + else: + raise ValueError("invalid truth value {!r}".format(val)) + + def get_extensions(): + no_cpp = strtobool(os.getenv("NO_CPP_BINARIES", "0")) + if no_cpp: + return [] extension = CppExtension extra_link_args = [] From 17224b7e7f8e8f4ecc7844c6ce0173631324f73b Mon Sep 17 00:00:00 2001 From: Vincent Moens Date: Mon, 10 Mar 2025 16:37:34 +0000 Subject: [PATCH 2/2] Update [ghstack-poisoned] --- .github/workflows/build-wheels-agnostic.yml | 2 +- setup.py | 2 +- torchrl/_extension.py | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-wheels-agnostic.yml b/.github/workflows/build-wheels-agnostic.yml index 748c4b8e9e5..cf0604e5797 100644 --- a/.github/workflows/build-wheels-agnostic.yml +++ b/.github/workflows/build-wheels-agnostic.yml @@ -1,4 +1,4 @@ -name: Build Linux Wheels +name: Build Agnostic Wheels on: pull_request: diff --git a/setup.py b/setup.py index 9d1b3b079c2..236f8884246 100644 --- a/setup.py +++ b/setup.py @@ -131,7 +131,7 @@ def strtobool(val): elif val in (0, False, "n", "no", "f", "false", "off", "0"): return 0 else: - raise ValueError("invalid truth value {!r}".format(val)) + raise ValueError(f"invalid truth value {val!r}") def get_extensions(): diff --git a/torchrl/_extension.py b/torchrl/_extension.py index d84d73cca4a..d1a38f039d6 100644 --- a/torchrl/_extension.py +++ b/torchrl/_extension.py @@ -52,8 +52,10 @@ def _is_nightly(version): else: EXTENSION_WARNING = ( - "Failed to import torchrl C++ binaries. Some modules (eg, prioritized replay buffers) may not work with your installation. " - "This is likely due to a discrepancy between your package version and the PyTorch version. Make sure both are compatible. " - "Usually, torchrl majors follow the pytorch majors within a few days around the release. " + "Failed to import torchrl C++ binaries. Some modules (e.g., prioritized replay buffers) may not work with your installation. " + "This could be because you are using a platform-agnostic version of TorchRL, which does not include C++ binaries. " + "If a more specific version is available for your platform, consider installing it for full functionality. " + "Additionally, ensure that your TorchRL version is compatible with your PyTorch version. " + "TorchRL major versions typically align with PyTorch major versions shortly after their release. " "For instance, TorchRL 0.5 requires PyTorch 2.4.0, and TorchRL 0.6 requires PyTorch 2.5.0." )