rlightning.buffer.utils.storage¶
Storage backend for buffer data and episode handling.
- class rlightning.buffer.utils.storage.ActiveEpisodeBuffer(env_meta_list: List[EnvMeta], auto_truncate_episode: bool, postprocess_fn: Callable, device: MockModule('torch.device'))[source]¶
Bases:
objectA helper class to manage active episode buffers for multiple environments.
- add_transition(env_id: str, transition: Dict[str, Any]) None[source]¶
Add a transition to the episode buffer for a given environment ID.
- class rlightning.buffer.utils.storage.BufferView(data: MockModule('tensordict.TensorDict'))[source]¶
Bases:
objectA read-only, buffer-like view of a TensorDict for dataset creation.
- class rlightning.buffer.utils.storage.DataContainer(capacity: int, mode: Literal['circular', 'fixed'], unit: Literal['transition', 'episode'], device: str | MockModule('torch.device'))[source]¶
Bases:
object
- class rlightning.buffer.utils.storage.Storage(capacity: int, mode: Literal['circular', 'standard'], unit: Literal['transition', 'episode'], env_meta_list: List[EnvMeta], device: str | MockModule('torch.device'), obs_preprocessor: Callable, reward_preprocessor: Callable, env_ret_preprocess_fn: Callable, policy_resp_preprocess_fn: Callable, preprocess_fn: Callable, postprocess_fn: Callable, auto_truncate_episode: bool)[source]¶
Bases:
objectActual storage for data buffer to support shard or unshard storage
- add_data_async(item: EnvRet | PolicyResponse) None[source]¶
Add a single EnvRet or PolicyResponse to the storage. It is usually used in async rollout that cannot collect env_ret and policy_resp pair at the same time.
- Parameters:
item (Union[EnvRet, PolicyResponse]) – The EnvRet or PolicyResponse to add
- add_episode(episode: Dict | MockModule('tensordict.TensorDict'), num_envs: int = 1) None[source]¶
Add a complete episode to the storage.
- Parameters:
episode (Dict | TensorDict) – The episode to add.
num_envs (int) – Number of parallel environments represented in the episode.
- add_transition(env_ret: EnvRet, policy_resp: PolicyResponse) None[source]¶
Add a transition with an env_ret and policy_resp pair to the storage.
- Parameters:
env_ret (EnvRet) – The environment return.
policy_resp (PolicyResponse) – The policy response.