Skip to content

Commit

Permalink
[BugFix] Fix displaying of tensor sizes in buffers
Browse files Browse the repository at this point in the history
ghstack-source-id: 511609a169996b680dccbd272e3d5b5710618558
Pull Request resolved: #2456
  • Loading branch information
vmoens committed Sep 26, 2024
1 parent ca3a595 commit 8542d2e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion torchrl/data/replay_buffers/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
TensorDict,
TensorDictBase,
)
from tensordict.base import _NESTED_TENSORS_AS_LISTS
from tensordict.memmap import MemoryMappedTensor
from torch import multiprocessing as mp
from torch.utils._pytree import tree_flatten, tree_map, tree_unflatten
Expand Down Expand Up @@ -1120,7 +1121,12 @@ def max_size_along_dim0(data_shape):
out = out.memmap_like(prefix=self.scratch_dir, existsok=self.existsok)
if torchrl_logger.isEnabledFor(logging.DEBUG):
for key, tensor in sorted(
out.items(include_nested=True, leaves_only=True), key=str
out.items(
include_nested=True,
leaves_only=True,
is_leaf=_NESTED_TENSORS_AS_LISTS,
),
key=str,
):
try:
filesize = os.path.getsize(tensor.filename) / 1024 / 1024
Expand Down

1 comment on commit 8542d2e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'CPU Benchmark Results'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 8542d2e Previous: ca3a595 Ratio
benchmarks/test_replaybuffer_benchmark.py::test_rb_sample[TensorDictPrioritizedReplayBuffer-LazyMemmapStorage-None-10000] 602.8129041282227 iter/sec (stddev: 0.034841014791745756) 1640.1903839954064 iter/sec (stddev: 0.000027888923420017905) 2.72

This comment was automatically generated by workflow using github-action-benchmark.

CC: @vmoens

Please sign in to comment.