Skip to content

Commit 3b89ab9

Browse files
committed
Simplify the TorchRL PPO runner
Let ClipPPOLoss own the GAE estimator, sum whichever loss_* terms the loss returns instead of naming them, build the networks in two small module-level helpers, and collapse logging into one dictionary. Activations are named by their torch.nn class so no lookup table is needed.
1 parent f7260b0 commit 3b89ab9

3 files changed

Lines changed: 107 additions & 205 deletions

File tree

source/isaaclab_rl/isaaclab_rl/torchrl/ppo_cfg.py

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,86 +12,53 @@
1212

1313
@configclass
1414
class TorchRlMlpModelCfg:
15-
"""Configuration of an MLP used by :class:`~isaaclab_rl.torchrl.TorchRlPpoRunner`."""
15+
"""MLP used for the actor and the critic of :class:`~isaaclab_rl.torchrl.TorchRlPpoRunner`."""
1616

1717
hidden_dims: list[int] = MISSING
1818
"""Sizes of the hidden layers."""
1919

20-
activation: str = "elu"
21-
"""Activation function, one of ``"elu"``, ``"relu"``, ``"tanh"``, ``"selu"``, ``"gelu"`` or ``"silu"``."""
20+
activation: str = "ELU"
21+
"""Name of a :mod:`torch.nn` activation class, e.g. ``"ELU"``, ``"ReLU"`` or ``"Tanh"``."""
2222

2323

2424
@configclass
2525
class TorchRlPpoAlgorithmCfg:
26-
"""Configuration of the PPO update, mapped onto :class:`torchrl.objectives.ClipPPOLoss`."""
26+
"""PPO hyper-parameters, mapped onto :class:`torchrl.objectives.ClipPPOLoss` and GAE."""
2727

2828
num_learning_epochs: int = MISSING
29-
"""Number of passes over the collected batch per iteration."""
30-
3129
num_mini_batches: int = MISSING
32-
"""Number of mini-batches the collected batch is split into per epoch."""
33-
3430
learning_rate: float = MISSING
35-
"""Adam learning rate."""
36-
3731
gamma: float = MISSING
38-
"""Discount factor."""
39-
4032
lam: float = MISSING
41-
"""GAE lambda."""
42-
4333
clip_param: float = 0.2
44-
"""PPO clipping range for the probability ratio."""
45-
4634
entropy_coef: float = 0.0
47-
"""Weight of the entropy bonus. ``0`` disables it."""
48-
35+
"""Weight of the entropy bonus; ``0`` disables it."""
4936
value_loss_coef: float = 1.0
50-
"""Weight of the value loss."""
51-
5237
max_grad_norm: float = 1.0
53-
"""Gradient norm clipping threshold."""
54-
5538
normalize_advantage: bool = True
56-
"""Whether to normalize advantages within each mini-batch."""
39+
"""Normalize advantages within each mini-batch."""
5740

5841

5942
@configclass
6043
class TorchRlPpoRunnerCfg:
6144
"""Configuration of :class:`~isaaclab_rl.torchrl.TorchRlPpoRunner`."""
6245

6346
seed: int = 42
64-
"""Seed for the environment and the networks."""
65-
6647
device: str = "cuda:0"
67-
"""Device the networks and the collected batches live on."""
68-
6948
num_steps_per_env: int = MISSING
7049
"""Environment steps collected from every environment per iteration."""
71-
7250
max_iterations: int = MISSING
73-
"""Number of training iterations."""
74-
7551
save_interval: int = MISSING
7652
"""Iterations between checkpoints."""
77-
7853
experiment_name: str = MISSING
7954
"""Name of the experiment folder under ``logs/torchrl``."""
80-
8155
run_name: str = ""
82-
"""Optional suffix appended to the timestamped run folder."""
83-
56+
"""Optional suffix of the timestamped run folder."""
8457
clip_actions: float | None = None
85-
"""Clipping range applied to actions before they reach the environment. ``None`` disables clipping."""
86-
58+
"""Clipping range applied to actions before they reach the environment; ``None`` disables it."""
8759
init_noise_std: float = 1.0
8860
"""Initial standard deviation of the Gaussian policy."""
89-
9061
actor: TorchRlMlpModelCfg = MISSING
91-
"""Actor network."""
92-
9362
critic: TorchRlMlpModelCfg = MISSING
94-
"""Critic network. It reads the ``"critic"`` observation group when the task defines one, else ``"policy"``."""
95-
63+
"""Reads the ``"critic"`` observation group when the task defines one, else ``"policy"``."""
9664
algorithm: TorchRlPpoAlgorithmCfg = MISSING
97-
"""PPO hyper-parameters."""

0 commit comments

Comments
 (0)