rlightning.engine.base_engine¶
Base engine module for reinforcement learning training loops.
This module defines the abstract base class for all RL engines, providing the common interface for training, rollout, and weight updates.
- class rlightning.engine.base_engine.BaseEngine(config: MainConfig, env_group: EnvGroup | None = None, policy_group: PolicyGroup | None = None, buffer: DataBuffer | None = None)[source]¶
Bases:
ABCAbstract base class for reinforcement learning engines.
This class defines the common interface for all RL engines, including methods for warm-up, training, rollout, weight updates, and timing.
- buffer: DataBuffer¶
- abstractmethod evaluate(*args: Any, **kwargs: Any) None[source]¶
User defined evaluation to collect experience.
- Parameters:
*args – Variable positional arguments.
**kwargs – Variable keyword arguments.
- iter_epochs(num_epochs: int) iter[source]¶
An iterator that yields epoch numbers up to num_epochs.
- Parameters:
num_epochs (int) – The number of epochs to iterate through.
- Returns:
An iterator over epoch numbers.
- Return type:
iter
- print_timing_summary(reset: bool = False) None[source]¶
Print timing summary for profiling.
- Parameters:
reset – If True, reset timing statistics after printing.
- abstractmethod rollout(*args: Any, **kwargs: Any) None[source]¶
User defined rollout to collect experience.
- Parameters:
*args – Variable positional arguments.
**kwargs – Variable keyword arguments.
- abstractmethod run() None[source]¶
Run the RL training flow.
This method should execute the complete RL training flow, coordinating rollout, training, and weight updates.
- sync_weights() None[source]¶
sync weights from train policy to eval policy.
- Parameters:
policy_group – Policy group containing train and eval policies.
- abstractmethod train() None[source]¶
User defined training on collected experience.
- Parameters:
*args – Variable positional arguments.
**kwargs – Variable keyword arguments.