Skip to content

Commit 1363d36

Browse files
committed
[Setup] Make platform-agnostic wheels
ghstack-source-id: 4889c03adeb9950a162d12963eda48e9b6d88513 Pull Request resolved: #2847
1 parent 3d2bad7 commit 1363d36

File tree

4 files changed

+78
-3
lines changed

4 files changed

+78
-3
lines changed

.github/scripts/td_script_agnostic.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
export TORCHRL_BUILD_VERSION=0.8.0
4+
export NO_CPP_BINARIES=1
5+
6+
pip install git+https://github.com/pytorch/tensordict.git -U
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build Agnostic Wheels
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
tags:
11+
# NOTE: Binary build pipelines should only get triggered on release candidate builds
12+
# Release candidate tags look like: v1.11.0-rc1
13+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
14+
workflow_dispatch:
15+
16+
permissions:
17+
id-token: write
18+
contents: read
19+
20+
jobs:
21+
generate-matrix:
22+
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
23+
with:
24+
package-type: wheel
25+
os: linux
26+
test-infra-repository: pytorch/test-infra
27+
test-infra-ref: main
28+
build:
29+
needs: generate-matrix
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
include:
34+
- repository: pytorch/rl
35+
smoke-test-script: test/smoke_test.py
36+
package-name: torchrl
37+
name: pytorch/rl
38+
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
39+
with:
40+
repository: ${{ matrix.repository }}
41+
ref: ""
42+
test-infra-repository: pytorch/test-infra
43+
test-infra-ref: main
44+
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
45+
package-name: ${{ matrix.package-name }}
46+
smoke-test-script: ${{ matrix.smoke-test-script }}
47+
trigger-event: ${{ github.event_name }}
48+
env-var-script: .github/scripts/td_script_agnostic.sh

setup.py

+19
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,26 @@ def run(self):
118118
# return None
119119

120120

121+
def strtobool(val):
122+
"""Convert a string representation of truth to true (1) or false (0).
123+
124+
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
125+
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
126+
'val' is anything else.
127+
"""
128+
val = val.lower()
129+
if val in (1, True, "y", "yes", "t", "true", "on", "1"):
130+
return 1
131+
elif val in (0, False, "n", "no", "f", "false", "off", "0"):
132+
return 0
133+
else:
134+
raise ValueError(f"invalid truth value {val!r}")
135+
136+
121137
def get_extensions():
138+
no_cpp = strtobool(os.getenv("NO_CPP_BINARIES", "0"))
139+
if no_cpp:
140+
return []
122141
extension = CppExtension
123142

124143
extra_link_args = []

torchrl/_extension.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ def _is_nightly(version):
5252

5353
else:
5454
EXTENSION_WARNING = (
55-
"Failed to import torchrl C++ binaries. Some modules (eg, prioritized replay buffers) may not work with your installation. "
56-
"This is likely due to a discrepancy between your package version and the PyTorch version. Make sure both are compatible. "
57-
"Usually, torchrl majors follow the pytorch majors within a few days around the release. "
55+
"Failed to import torchrl C++ binaries. Some modules (e.g., prioritized replay buffers) may not work with your installation. "
56+
"This could be because you are using a platform-agnostic version of TorchRL, which does not include C++ binaries. "
57+
"If a more specific version is available for your platform, consider installing it for full functionality. "
58+
"Additionally, ensure that your TorchRL version is compatible with your PyTorch version. "
59+
"TorchRL major versions typically align with PyTorch major versions shortly after their release. "
5860
"For instance, TorchRL 0.5 requires PyTorch 2.4.0, and TorchRL 0.6 requires PyTorch 2.5.0."
5961
)

0 commit comments

Comments
 (0)