You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MetaTensors is a special TorchRL class that tracks the metadata of tensors stored in the TensorDict.
Its main reason of existence is to avoid the overhead of loading tensors just to read an attribute. We already have a SavedTensordict class, for instance, that represents tensors saved on disk. If we had to load the whole tensordict from disk every time an attribute (shape, etc.) is gathered this could create an unecessary overhead.
We carefully choose which attribute should be part of MetaTensors. Some may not be easy to infer and are therefore not part of the metatensor.
It may be useful to implement a requires_grad attribute in MetaTensor. Its purpose would simply be to tell if a tensor is part of a graph or not.
In the tests, one should make sure that these aspects are accounted for:
For LazyStackTensorDict objects, the resulting tensors will require a gradient if a single tensor of the list requires a gradient. The respective MetaTensor should follow the same logic.
In theory, MemmapTensors and SavedTensorDicts are not compatible with gradients that are part of computational graphs. This means that when writing a tensor that has requires_grad in a SavedTensorDict, an error should be raised. Same if a regular TensorDict is cast using tensordict.to(SavedTensorDict) or tensordict.memmap_().
The text was updated successfully, but these errors were encountered:
MetaTensors is a special TorchRL class that tracks the metadata of tensors stored in the TensorDict.
Its main reason of existence is to avoid the overhead of loading tensors just to read an attribute. We already have a SavedTensordict class, for instance, that represents tensors saved on disk. If we had to load the whole tensordict from disk every time an attribute (shape, etc.) is gathered this could create an unecessary overhead.
We carefully choose which attribute should be part of MetaTensors. Some may not be easy to infer and are therefore not part of the metatensor.
It may be useful to implement a
requires_grad
attribute in MetaTensor. Its purpose would simply be to tell if a tensor is part of a graph or not.In the tests, one should make sure that these aspects are accounted for:
tensordict.to(SavedTensorDict)
ortensordict.memmap_()
.The text was updated successfully, but these errors were encountered: