Skip to content

Training Backends

RoboSmith uses a universal trainer interface so the pipeline can call SB3, CleanRL, rl_games, imitation learning, offline RL, or future backends through the same contract.

from robosmith.trainers.registry import TrainerRegistry
registry = TrainerRegistry()
trainer = registry.get_trainer(algorithm="ppo", backend="sb3")
BackendClassParadigmAlgorithms
sb3SB3TrainerrlPPO, SAC, TD3, A2C, DQN
cleanrlCleanRLTrainerrlPPO
rl_gamesRLGamesTrainerrlPPO
il_trainerILTrainerilBC, DAgger
offline_rl_trainerOfflineRLTraineroffline_rlTD3+BC, CQL, IQL

Check local availability:

Terminal window
robosmith trainers
from robosmith.trainers.base import TrainingConfig, LearningParadigm
config = TrainingConfig(
task_description="A quadruped walks forward",
algorithm="ppo",
paradigm=LearningParadigm.REINFORCEMENT_LEARNING,
env_id="Ant-v5",
total_timesteps=50_000,
time_limit_seconds=300,
seed=42,
device="auto",
extra={"n_steps": 2048},
)

Fields are intentionally broad enough for multiple learning paradigms:

FieldMeaning
env_id, env_entryEnvironment identity and registry entry.
reward_fnCustom reward function for RL.
demo_paths, num_demosDemonstration data for imitation learning.
dataset_pathStatic dataset for offline RL or VLA-style methods.
total_timesteps, total_epochsBudget by training style.
artifacts_dirWhere checkpoints and logs should be written.
extraBackend-specific options.

Every trainer returns TrainingResult.

result = trainer.train(config)
if result.success:
print(result.model_path)
print(result.final_mean_reward)
else:
print(result.error)

Important fields:

FieldMeaning
model_pathPath to the saved model or checkpoint.
algorithmAlgorithm actually used.
paradigmLearning paradigm.
total_timestepsCompleted environment steps.
training_time_secondsWall-clock training time.
final_mean_reward, final_std_rewardFinal reward metrics.
convergedBackend-specific convergence signal.
metrics_historyTime series or backend metrics.
errorError string when training failed.

select_policy_approach() picks a learning paradigm, algorithm, and backend from task context.

from robosmith.trainers.selector import select_policy_approach
approach = select_policy_approach(
task_description="Pick and place a cube",
env_entry=entry,
available_backends=["sb3", "cleanrl"],
)
print(approach.algorithm)
print(approach.reason)

Selection rules:

SignalTypical choice
Many demonstrationsImitation learning with BC.
Large static datasetOffline RL with IQL.
Discrete action spacePPO.
Classic controlPPO.
LocomotionPPO, rl_games if GPU and available.
General manipulationSAC.
Dexterous manipulationTD3, with SAC as an alternative.
Terminal window
robosmith run --task "..." --backend sb3
robosmith run --task "..." --backend cleanrl
robosmith run --task "..." --algo sac

When a backend is forced, TrainerRegistry.get_trainer() verifies it exists and that its dependencies are installed.