Skip to content

Commit be7156f

Browse files
committed
[BugFix] Load on empty PRB (#3057)
1 parent 7e8f940 commit be7156f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

torchrl/data/replay_buffers/samplers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,13 @@ def loads(self, path):
738738
self._alpha = metadata["_alpha"]
739739
self._beta = metadata["_beta"]
740740
self._eps = metadata["_eps"]
741-
tree_map(
742-
lambda dest, orig: dest.copy_(orig),
741+
maxp = tree_map(
742+
lambda dest, orig: dest.copy_(orig) if dest is not None else orig,
743743
tuple(self._max_priority),
744744
tuple(metadata["_max_priority"]),
745745
)
746+
if all(x is None for x in self._max_priority):
747+
self._max_priority = maxp
746748
_max_capacity = metadata["_max_capacity"]
747749
if _max_capacity != self._max_capacity:
748750
raise RuntimeError(

0 commit comments

Comments
 (0)