Skip to content

Commit 74d6cbc

Browse files
authored
[CI] Fix SDL install (#2978)
1 parent 0bd30eb commit 74d6cbc

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

.github/unittest/linux/scripts/run_all.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ if [[ $OSTYPE != 'darwin'* ]]; then
1212
apt-get install -y vim git wget cmake
1313

1414
# Enable universe repository
15-
apt-get install -y software-properties-common
16-
add-apt-repository universe
17-
apt-get update
15+
# apt-get install -y software-properties-common
16+
# add-apt-repository universe
17+
# apt-get update
1818

19-
apt-get install -y libsdl2-dev libsdl2-2.0-0
19+
# apt-get install -y libsdl2-dev libsdl2-2.0-0
2020

2121
apt-get install -y libglfw3 libgl1-mesa-glx libosmesa6 libglew-dev
2222
apt-get install -y libglvnd0 libgl1 libglx0 libegl1 libgles2 xvfb

.github/unittest/linux_olddeps/scripts_gym_0_13/run_test.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ python .github/unittest/helpers/coverage_run_parallel.py -m pytest test/smoke_te
2828
export DISPLAY=:99
2929
Xvfb :99 -screen 0 1400x900x24 > /dev/null 2>&1 &
3030

31-
CKPT_BACKEND=torch MUJOCO_GL=egl python .github/unittest/helpers/coverage_run_parallel.py -m pytest --instafail -v --durations 200 --ignore test/test_distributed.py \
32-
--ignore test/test_rlhf.py \
33-
--ignore test/llm \
34-
--timeout=120 --mp_fork_if_no_cuda
31+
CKPT_BACKEND=torch MUJOCO_GL=egl python .github/unittest/helpers/coverage_run_parallel.py -m pytest \
32+
--instafail -v \
33+
--durations 200 \
34+
--ignore test/test_distributed.py \
35+
--ignore test/test_rlhf.py \
36+
--ignore test/llm \
37+
--mp_fork_if_no_cuda
3538

3639
#pytest --instafail -v --durations 200
3740
#python test/test_libs.py

test/test_specs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,8 +2537,8 @@ def test_stack_choice(self, input_type, shape, stack_dim):
25372537
choices = [NonTensorData("a"), NonTensorData("b"), NonTensorData("c")]
25382538
else:
25392539
choices = [
2540-
NonTensorStack("a").expand(shape + (1,)).squeeze(-1),
2541-
NonTensorStack("d").expand(shape + (1,)).squeeze(-1),
2540+
NonTensorData("a", batch_size=shape),
2541+
NonTensorData("d", batch_size=shape),
25422542
]
25432543

25442544
spec0 = Choice(choices)

test/test_transforms.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11616,7 +11616,7 @@ def _make_transform_env(self, out_key, base_env):
1161611616
transform = KLRewardTransform(actor, out_keys=out_key)
1161711617
return Compose(
1161811618
TensorDictPrimer(
11619-
sample_log_prob=Unbounded(shape=base_env.action_spec.shape[:-1]),
11619+
action_log_prob=Unbounded(shape=base_env.action_spec.shape[:-1]),
1162011620
shape=base_env.shape,
1162111621
),
1162211622
transform,
@@ -11640,7 +11640,7 @@ def test_transform_no_env(self, in_key, out_key):
1164011640
{
1164111641
"action": torch.randn(*batch, 7),
1164211642
"observation": torch.randn(*batch, 7),
11643-
"sample_log_prob": torch.randn(*batch),
11643+
"action_log_prob": torch.randn(*batch),
1164411644
},
1164511645
batch,
1164611646
)
@@ -11658,7 +11658,7 @@ def test_transform_compose(self):
1165811658
"action": torch.randn(*batch, 7),
1165911659
"observation": torch.randn(*batch, 7),
1166011660
"next": {t[0].in_keys[0]: torch.zeros(*batch, 1)},
11661-
"sample_log_prob": torch.randn(*batch),
11661+
"action_log_prob": torch.randn(*batch),
1166211662
},
1166311663
batch,
1166411664
)
@@ -11678,7 +11678,7 @@ def test_transform_env(self, out_key):
1167811678
base_env = self.envclass()
1167911679
torch.manual_seed(0)
1168011680
actor = self._make_actor()
11681-
# we need to patch the env and create a sample_log_prob spec to make check_env_specs happy
11681+
# we need to patch the env and create a action_log_prob spec to make check_env_specs happy
1168211682
env = TransformedEnv(
1168311683
base_env,
1168411684
Compose(
@@ -11711,7 +11711,7 @@ def update(x):
1171111711
@pytest.mark.parametrize("out_key", [None, "some_stuff", ["some_stuff"]])
1171211712
def test_single_trans_env_check(self, out_key):
1171311713
base_env = self.envclass()
11714-
# we need to patch the env and create a sample_log_prob spec to make check_env_specs happy
11714+
# we need to patch the env and create a action_log_prob spec to make check_env_specs happy
1171511715
env = TransformedEnv(base_env, self._make_transform_env(out_key, base_env))
1171611716
check_env_specs(env)
1171711717

@@ -11776,7 +11776,7 @@ def test_transform_model(self):
1177611776
"action": torch.randn(*batch, 7),
1177711777
"observation": torch.randn(*batch, 7),
1177811778
"next": {t.in_keys[0]: torch.zeros(*batch, 1)},
11779-
"sample_log_prob": torch.randn(*batch),
11779+
"action_log_prob": torch.randn(*batch),
1178011780
},
1178111781
batch,
1178211782
)
@@ -11796,7 +11796,7 @@ def test_transform_rb(self, rbclass):
1179611796
"action": torch.randn(*batch, 7),
1179711797
"observation": torch.randn(*batch, 7),
1179811798
"next": {t.in_keys[0]: torch.zeros(*batch, 1)},
11799-
"sample_log_prob": torch.randn(*batch),
11799+
"action_log_prob": torch.randn(*batch),
1180011800
},
1180111801
batch,
1180211802
)

torchrl/data/tensor_specs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6489,7 +6489,10 @@ def _stack_specs(list_of_spec, dim=0, out=None):
64896489
if dim < 0:
64906490
dim += len(shape) + 1
64916491
shape.insert(dim, len(list_of_spec))
6492-
return spec0.clone().unsqueeze(dim).expand(shape)
6492+
spec0 = spec0.clone()
6493+
spec0 = spec0.unsqueeze(dim)
6494+
spec0 = spec0.expand(shape)
6495+
return spec0
64936496
return Stacked(*list_of_spec, dim=dim)
64946497
else:
64956498
raise NotImplementedError

torchrl/envs/transforms/llm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ def _step(
232232
reward_key = self.in_keys[0]
233233
reward = next_tensordict.get(reward_key)
234234
curr_log_prob = tensordict.get(self.sample_log_prob_key)
235+
if curr_log_prob is None:
236+
raise KeyError(
237+
f"log_prob key {self.sample_log_prob_key} not found in tensordict with keys {list(tensordict.keys(True))}"
238+
)
235239
log_prob = log_prob.to(curr_log_prob.device)
236240
# We want the log-probs to have a similar dim to the reward
237241
curr_log_prob = curr_log_prob.unsqueeze(-1)

0 commit comments

Comments
 (0)