PPOActivationMonitor
python
PPOActivationMonitor(*, metrics: MetricsTracker, device: torch.device, interval_rollouts: int | None, max_observations: int) -> NoneLogs per-layer activation health from the learner, every N rollouts.
Green Beret run 15 lost the last hidden layer to dead ReLUs (11% dead at 130M, 90% at 297M) with no loss metric moving; the policy lost the wave as the layer's effective rank fell through ~20. This gauge makes that visible on the graph while the run is live, instead of at the post-mortem.
Initialize the monitor.
Parameters:
metrics(MetricsTracker) – Metrics tracker to write to.device(device) – Device the model's forward passes run on.interval_rollouts(int | None) – Log every this many rollouts;Nonedisables the monitor.max_observations(int) – Observations used per measurement (the first rows of the minibatch given).
Properties
enabled
python
enabled: boolWhether the monitor logs anything.
Methods
is_due
python
is_due(rollouts_collected: int) -> boolWhether a measurement is due after this many rollouts.
Parameters:
rollouts_collected(int) – Rollouts consumed so far, including the one just trained on.
Returns:
bool–Trueon everyinterval_rollouts-th rollout; alwaysFalsewhen disabled.
maybe_log
python
maybe_log(model: torch.nn.Module, observations: torch.Tensor, *, actor_steps: int, rollouts_collected: int) -> boolMeasure and log activation health if a measurement is due.
The caller holds the model lock; the measurement runs the model forward in eval mode with no grad and restores the training mode afterwards.
Parameters:
model(Module) – The learner model.observations(Tensor) – Observations from the current rollout,(N, *observation_shape), in the model's input dtype.actor_steps(int) – The current actor step count, used as the metric step.rollouts_collected(int) – Rollouts consumed so far, including the one just trained on.
Returns:
bool–Trueif metrics were logged.