Skip to content

Commit 76213f7

Browse files
author
Vincent Moens
authored
[BugFix, CI] Set TD_GET_DEFAULTS_TO_NONE=1 in all CIs (#2363)
1 parent e76d8cb commit 76213f7

File tree

9 files changed

+73
-11
lines changed

9 files changed

+73
-11
lines changed

.github/workflows/benchmarks.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ jobs:
3030
python-version: 3.8
3131
- name: Setup Environment
3232
run: |
33-
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U
34-
python -m pip install git+https://github.com/pytorch/tensordict
35-
python setup.py develop
36-
python -m pip install pytest pytest-benchmark
33+
python3 -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U
34+
python3 -m pip install git+https://github.com/pytorch/tensordict
35+
python3 setup.py develop
36+
python3 -m pip install pytest pytest-benchmark
3737
python3 -m pip install "gym[accept-rom-license,atari]"
3838
python3 -m pip install dm_control
39+
export TD_GET_DEFAULTS_TO_NONE=1
3940
- name: Run benchmarks
4041
run: |
4142
cd benchmarks/
@@ -97,6 +98,7 @@ jobs:
9798
python3 -m pip install pytest pytest-benchmark
9899
python3 -m pip install "gym[accept-rom-license,atari]"
99100
python3 -m pip install dm_control
101+
export TD_GET_DEFAULTS_TO_NONE=1
100102
- name: check GPU presence
101103
run: |
102104
python -c """import torch

.github/workflows/benchmarks_pr.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ jobs:
2929
python-version: 3.8
3030
- name: Setup Environment
3131
run: |
32-
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U
33-
python -m pip install git+https://github.com/pytorch/tensordict
34-
python setup.py develop
35-
python -m pip install pytest pytest-benchmark
32+
python3 -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U
33+
python3 -m pip install git+https://github.com/pytorch/tensordict
34+
python3 setup.py develop
35+
python3 -m pip install pytest pytest-benchmark
3636
python3 -m pip install "gym[accept-rom-license,atari]"
3737
python3 -m pip install dm_control
38+
export TD_GET_DEFAULTS_TO_NONE=1
3839
- name: Setup benchmarks
3940
run: |
4041
echo "BASE_SHA=$(echo ${{ github.event.pull_request.base.sha }} | cut -c1-8)" >> $GITHUB_ENV
@@ -108,6 +109,7 @@ jobs:
108109
python3 -m pip install pytest pytest-benchmark
109110
python3 -m pip install "gym[accept-rom-license,atari]"
110111
python3 -m pip install dm_control
112+
export TD_GET_DEFAULTS_TO_NONE=1
111113
- name: check GPU presence
112114
run: |
113115
python -c """import torch

.github/workflows/test-linux-examples.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
5050
echo "PYTHON_VERSION: $PYTHON_VERSION"
5151
echo "CU_VERSION: $CU_VERSION"
52+
export TD_GET_DEFAULTS_TO_NONE=1
5253
5354
## setup_env.sh
5455
bash .github/unittest/linux_examples/scripts/run_all.sh

.github/workflows/test-linux-habitat.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ jobs:
4646
export CU_VERSION="cu${CUDA_ARCH_VERSION:0:2}${CUDA_ARCH_VERSION:3:1}"
4747
# Remove the following line when the GPU tests are working inside docker, and uncomment the above lines
4848
#export CU_VERSION="cpu"
49+
export TD_GET_DEFAULTS_TO_NONE=1
4950
5051
bash .github/unittest/linux_libs/scripts_habitat/run_all.sh

.github/workflows/test-linux-libs.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
export TAR_OPTIONS="--no-same-owner"
4545
export UPLOAD_CHANNEL="nightly"
4646
export TF_CPP_MIN_LOG_LEVEL=0
47+
export TD_GET_DEFAULTS_TO_NONE=1
4748
4849
bash .github/unittest/linux_libs/scripts_ataridqn/setup_env.sh
4950
bash .github/unittest/linux_libs/scripts_ataridqn/install.sh
@@ -81,6 +82,7 @@ jobs:
8182
export UPLOAD_CHANNEL="nightly"
8283
export TF_CPP_MIN_LOG_LEVEL=0
8384
export BATCHED_PIPE_TIMEOUT=60
85+
export TD_GET_DEFAULTS_TO_NONE=1
8486
8587
nvidia-smi
8688
@@ -114,6 +116,7 @@ jobs:
114116
export UPLOAD_CHANNEL="nightly"
115117
export TF_CPP_MIN_LOG_LEVEL=0
116118
export BATCHED_PIPE_TIMEOUT=60
119+
export TD_GET_DEFAULTS_TO_NONE=1
117120
118121
bash .github/unittest/linux_libs/scripts_d4rl/setup_env.sh
119122
bash .github/unittest/linux_libs/scripts_d4rl/install.sh
@@ -148,6 +151,7 @@ jobs:
148151
export UPLOAD_CHANNEL="nightly"
149152
export TF_CPP_MIN_LOG_LEVEL=0
150153
export BATCHED_PIPE_TIMEOUT=60
154+
export TD_GET_DEFAULTS_TO_NONE=1
151155
152156
bash .github/unittest/linux_libs/scripts_d4rl/setup_env.sh
153157
bash .github/unittest/linux_libs/scripts_d4rl/install.sh
@@ -181,6 +185,7 @@ jobs:
181185
export TAR_OPTIONS="--no-same-owner"
182186
export UPLOAD_CHANNEL="nightly"
183187
export TF_CPP_MIN_LOG_LEVEL=0
188+
export TD_GET_DEFAULTS_TO_NONE=1
184189
185190
bash .github/unittest/linux_libs/scripts_gen-dgrl/setup_env.sh
186191
bash .github/unittest/linux_libs/scripts_gen-dgrl/install.sh
@@ -216,6 +221,7 @@ jobs:
216221
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/work/mujoco-py/mujoco_py/binaries/linux/mujoco210/bin"
217222
export TAR_OPTIONS="--no-same-owner"
218223
export BATCHED_PIPE_TIMEOUT=60
224+
export TD_GET_DEFAULTS_TO_NONE=1
219225
220226
./.github/unittest/linux_libs/scripts_gym/setup_env.sh
221227
./.github/unittest/linux_libs/scripts_gym/batch_scripts.sh
@@ -251,6 +257,7 @@ jobs:
251257
export UPLOAD_CHANNEL="nightly"
252258
export TF_CPP_MIN_LOG_LEVEL=0
253259
export BATCHED_PIPE_TIMEOUT=60
260+
export TD_GET_DEFAULTS_TO_NONE=1
254261
255262
nvidia-smi
256263
@@ -285,6 +292,7 @@ jobs:
285292
export UPLOAD_CHANNEL="nightly"
286293
export TF_CPP_MIN_LOG_LEVEL=0
287294
export BATCHED_PIPE_TIMEOUT=60
295+
export TD_GET_DEFAULTS_TO_NONE=1
288296
289297
nvidia-smi
290298
@@ -321,6 +329,7 @@ jobs:
321329
export UPLOAD_CHANNEL="nightly"
322330
export TF_CPP_MIN_LOG_LEVEL=0
323331
export BATCHED_PIPE_TIMEOUT=60
332+
export TD_GET_DEFAULTS_TO_NONE=1
324333
325334
bash .github/unittest/linux_libs/scripts_minari/setup_env.sh
326335
bash .github/unittest/linux_libs/scripts_minari/install.sh
@@ -355,6 +364,7 @@ jobs:
355364
export UPLOAD_CHANNEL="nightly"
356365
export TF_CPP_MIN_LOG_LEVEL=0
357366
export BATCHED_PIPE_TIMEOUT=60
367+
export TD_GET_DEFAULTS_TO_NONE=1
358368
359369
bash .github/unittest/linux_libs/scripts_openx/setup_env.sh
360370
bash .github/unittest/linux_libs/scripts_openx/install.sh
@@ -387,6 +397,7 @@ jobs:
387397
export UPLOAD_CHANNEL="nightly"
388398
export TF_CPP_MIN_LOG_LEVEL=0
389399
export BATCHED_PIPE_TIMEOUT=60
400+
export TD_GET_DEFAULTS_TO_NONE=1
390401
391402
nvidia-smi
392403
@@ -423,6 +434,7 @@ jobs:
423434
export UPLOAD_CHANNEL="nightly"
424435
export TF_CPP_MIN_LOG_LEVEL=0
425436
export BATCHED_PIPE_TIMEOUT=60
437+
export TD_GET_DEFAULTS_TO_NONE=1
426438
427439
bash .github/unittest/linux_libs/scripts_robohive/setup_env.sh
428440
bash .github/unittest/linux_libs/scripts_robohive/install_and_run_test.sh
@@ -456,6 +468,7 @@ jobs:
456468
export UPLOAD_CHANNEL="nightly"
457469
export TF_CPP_MIN_LOG_LEVEL=0
458470
export BATCHED_PIPE_TIMEOUT=60
471+
export TD_GET_DEFAULTS_TO_NONE=1
459472
460473
bash .github/unittest/linux_libs/scripts_roboset/setup_env.sh
461474
bash .github/unittest/linux_libs/scripts_roboset/install.sh
@@ -491,6 +504,7 @@ jobs:
491504
export UPLOAD_CHANNEL="nightly"
492505
export TF_CPP_MIN_LOG_LEVEL=0
493506
export BATCHED_PIPE_TIMEOUT=60
507+
export TD_GET_DEFAULTS_TO_NONE=1
494508
495509
bash .github/unittest/linux_libs/scripts_sklearn/setup_env.sh
496510
bash .github/unittest/linux_libs/scripts_sklearn/install.sh
@@ -527,6 +541,7 @@ jobs:
527541
export UPLOAD_CHANNEL="nightly"
528542
export TF_CPP_MIN_LOG_LEVEL=0
529543
export BATCHED_PIPE_TIMEOUT=60
544+
export TD_GET_DEFAULTS_TO_NONE=1
530545
531546
nvidia-smi
532547
@@ -563,6 +578,7 @@ jobs:
563578
export UPLOAD_CHANNEL="nightly"
564579
export TF_CPP_MIN_LOG_LEVEL=0
565580
export BATCHED_PIPE_TIMEOUT=60
581+
export TD_GET_DEFAULTS_TO_NONE=1
566582
567583
bash .github/unittest/linux_libs/scripts_vd4rl/setup_env.sh
568584
bash .github/unittest/linux_libs/scripts_vd4rl/install.sh
@@ -599,6 +615,7 @@ jobs:
599615
export UPLOAD_CHANNEL="nightly"
600616
export TF_CPP_MIN_LOG_LEVEL=0
601617
export BATCHED_PIPE_TIMEOUT=60
618+
export TD_GET_DEFAULTS_TO_NONE=1
602619
603620
nvidia-smi
604621

.github/workflows/test-linux-rlhf.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
export TAR_OPTIONS="--no-same-owner"
4545
export UPLOAD_CHANNEL="nightly"
4646
export TF_CPP_MIN_LOG_LEVEL=0
47+
export TD_GET_DEFAULTS_TO_NONE=1
4748
4849
bash .github/unittest/linux_libs/scripts_rlhf/setup_env.sh
4950
bash .github/unittest/linux_libs/scripts_rlhf/install.sh

.github/workflows/test-linux.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,39 @@ jobs:
3838
export RELEASE=0
3939
export TORCH_VERSION=nightly
4040
fi
41+
export TD_GET_DEFAULTS_TO_NONE=1
42+
# Set env vars from matrix
43+
export PYTHON_VERSION=${{ matrix.python_version }}
44+
export CU_VERSION="cpu"
45+
46+
echo "PYTHON_VERSION: $PYTHON_VERSION"
47+
echo "CU_VERSION: $CU_VERSION"
48+
49+
## setup_env.sh
50+
bash .github/unittest/linux/scripts/run_all.sh
51+
52+
tests-cpu-oldget:
53+
# Tests that TD_GET_DEFAULTS_TO_NONE=0 works fine as this will be the default for TD up to 0.7
54+
strategy:
55+
matrix:
56+
python_version: ["3.12"]
57+
fail-fast: false
58+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
59+
with:
60+
runner: linux.12xlarge
61+
repository: pytorch/rl
62+
docker-image: "nvidia/cuda:12.2.0-devel-ubuntu22.04"
63+
timeout: 90
64+
script: |
65+
if [[ "${{ github.ref }}" =~ release/* ]]; then
66+
export RELEASE=1
67+
export TORCH_VERSION=stable
68+
else
69+
export RELEASE=0
70+
export TORCH_VERSION=nightly
71+
fi
72+
export TD_GET_DEFAULTS_TO_NONE=0
73+
4174
# Set env vars from matrix
4275
export PYTHON_VERSION=${{ matrix.python_version }}
4376
export CU_VERSION="cpu"
@@ -75,6 +108,8 @@ jobs:
75108
export RELEASE=0
76109
export TORCH_VERSION=nightly
77110
fi
111+
export TD_GET_DEFAULTS_TO_NONE=1
112+
78113
# Remove the following line when the GPU tests are working inside docker, and uncomment the above lines
79114
#export CU_VERSION="cpu"
80115
@@ -110,6 +145,7 @@ jobs:
110145
export TORCH_VERSION=nightly
111146
fi
112147
export TF_CPP_MIN_LOG_LEVEL=0
148+
export TD_GET_DEFAULTS_TO_NONE=1
113149
114150
115151
bash .github/unittest/linux_olddeps/scripts_gym_0_13/setup_env.sh
@@ -149,6 +185,7 @@ jobs:
149185
150186
echo "PYTHON_VERSION: $PYTHON_VERSION"
151187
echo "CU_VERSION: $CU_VERSION"
188+
export TD_GET_DEFAULTS_TO_NONE=1
152189
153190
## setup_env.sh
154191
bash .github/unittest/linux_optdeps/scripts/run_all.sh
@@ -187,6 +224,7 @@ jobs:
187224
188225
echo "PYTHON_VERSION: $PYTHON_VERSION"
189226
echo "CU_VERSION: $CU_VERSION"
227+
export TD_GET_DEFAULTS_TO_NONE=1
190228
191229
## setup_env.sh
192230
bash .github/unittest/linux/scripts/run_all.sh

.github/workflows/test-windows-optdepts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
export RELEASE=0
4343
export TORCH_VERSION=nightly
4444
fi
45+
export TD_GET_DEFAULTS_TO_NONE=1
4546
4647
## setup_env.sh
4748
./.github/unittest/windows_optdepts/scripts/setup_env.sh

torchrl/data/tensor_specs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
TensorDictBase,
3939
unravel_key,
4040
)
41+
from tensordict.base import NO_DEFAULT
4142
from tensordict.utils import _getitem_batch_size, NestedKey
4243
from torchrl._utils import _make_ordinal_device, get_binary_env_var
4344

@@ -79,8 +80,6 @@
7980
" an issue at https://github.com/pytorch/rl/issues"
8081
)
8182

82-
NO_DEFAULT = object()
83-
8483

8584
def _default_dtype_and_device(
8685
dtype: Union[None, torch.dtype],
@@ -4121,7 +4120,7 @@ def is_in(self, val: Union[dict, TensorDictBase]) -> bool:
41214120
for key, item in self._specs.items():
41224121
if item is None or (isinstance(item, CompositeSpec) and item.is_empty()):
41234122
continue
4124-
val_item = val[key]
4123+
val_item = val.get(key, NO_DEFAULT)
41254124
if not item.is_in(val_item):
41264125
return False
41274126
return True

0 commit comments

Comments
 (0)