Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Isaac sim IsaacGymEnvs WandbAlgoObserver Logging

From Leeroopedia
Knowledge Sources
Domains Logging, Training
Last Updated 2026-02-15 00:00 GMT

Overview

Wrapper documentation for the WandbAlgoObserver and RLGPUAlgoObserver classes that handle experiment tracking and metrics logging during RL training.

Description

WandbAlgoObserver initializes a Weights & Biases run at the start of training and logs all metrics to the W&B dashboard. RLGPUAlgoObserver collects per-episode statistics from the GPU environment's infos dictionary (e.g., consecutive successes, goal distances, custom reward components) and writes them to TensorBoard. Both observers implement the AlgoObserver interface from rl_games and are composed via MultiObserver when multiple logging backends are active.

Type

Wrapper Doc

Usage

Use these observers when training on IsaacGymEnvs tasks and needing experiment tracking. RLGPUAlgoObserver is always active. WandbAlgoObserver is conditionally activated via the wandb_activate config flag.

Code Reference

Source Location

Signature

class WandbAlgoObserver(AlgoObserver):
    """Observer that logs training metrics to Weights & Biases."""

    def __init__(self, cfg):
        """Initialize with Hydra config containing W&B settings."""
        ...

    def before_init(self, base_name, config, experiment_name):
        """Initialize the W&B run with project/entity settings and
        log the full training config as W&B config."""
        ...

    def after_init(self, algo):
        """Capture reference to the training algo for metric extraction."""
        ...

    def process_infos(self, infos, done_indices):
        """Forward environment infos to W&B (delegated to RLGPUAlgoObserver)."""
        ...

    def after_print_stats(self, frame, epoch_num, total_time):
        """Log aggregated epoch metrics to W&B dashboard."""
        ...


class RLGPUAlgoObserver(AlgoObserver):
    """Observer that collects per-episode GPU environment metrics for TensorBoard."""

    def __init__(self):
        """Initialize empty metric collection buffers."""
        ...

    def after_init(self, algo):  # L135
        """Capture reference to the agent's TensorBoard SummaryWriter."""
        ...

    def process_infos(self, infos, done_indices):  # L143
        """Extract per-episode statistics from environment infos dict.
        Only processes entries for episodes that have terminated (done_indices).
        Accumulates metrics in internal buffers for later aggregation."""
        ...

    def after_print_stats(self, frame, epoch_num, total_time):  # L178
        """Write aggregated per-episode metrics to TensorBoard.
        Computes mean/sum of buffered metrics and writes them as scalars.
        Clears the buffers after writing."""
        ...

Import

from isaacgymenvs.utils.wandb_utils import WandbAlgoObserver
from isaacgymenvs.utils.rlgames_utils import RLGPUAlgoObserver, MultiObserver

I/O Contract

Inputs

Name Type Required Description
cfg DictConfig Yes (WandbAlgoObserver) Hydra config containing W&B settings (wandb_activate, wandb_project, wandb_entity)
infos dict Yes Environment info dictionary from env.step(), containing per-environment episode statistics as GPU tensors
done_indices Tensor Yes Indices of environments that completed an episode on this step
frame int Yes Current global frame count (total environment steps taken)
epoch_num int Yes Current training epoch number
total_time float Yes Wall-clock time elapsed since training began (seconds)

Key Config Parameters

Parameter Type Default Description
cfg.wandb_activate bool False Whether to enable W&B logging
cfg.wandb_project str required if active W&B project name for organizing runs
cfg.wandb_entity str None W&B team/user entity (uses default if None)
cfg.wandb_name str None Custom run name (auto-generated if None)
cfg.wandb_group str None W&B group for organizing related runs
cfg.wandb_tags list[str] [] Tags for filtering runs in the W&B dashboard
save_freq int 100 Checkpoint saving frequency (epochs between saves)

Outputs

Name Type Description
.pth checkpoint files files Saved in runs/<experiment>/nn/ directory, containing model state_dict, optimizer state, and epoch number
W&B dashboards web UI Training curves, hyperparameter comparisons, and run metadata on the W&B platform
TensorBoard event files files Scalar summaries written to runs/<experiment>/summaries/ for TensorBoard visualization

Usage Examples

Setting Up Observers for Training

from isaacgymenvs.utils.rlgames_utils import RLGPUAlgoObserver, MultiObserver
from isaacgymenvs.utils.wandb_utils import WandbAlgoObserver

# Always create the GPU observer
gpu_observer = RLGPUAlgoObserver()

# Conditionally add W&B observer based on config
observers = [gpu_observer]
if cfg.wandb_activate:
    wandb_observer = WandbAlgoObserver(cfg)
    observers.append(wandb_observer)

# Compose into MultiObserver for the Runner
algo_observer = MultiObserver(observers)

# Pass to Runner during initialization
runner = build_runner(algo_observer=algo_observer)

Enabling W&B via Hydra Config

# In the task config or via command-line overrides:
wandb_activate: True
wandb_project: "isaacgym-experiments"
wandb_entity: "my-team"
wandb_name: "ant-ppo-lr3e4"
wandb_group: "ant-sweep"
wandb_tags: ["ppo", "ant", "baseline"]

How RLGPUAlgoObserver Collects Episode Metrics

# Inside the training loop, the Runner calls:
algo_observer.process_infos(infos, done_indices)

# RLGPUAlgoObserver.process_infos extracts metrics like:
# infos = {
#     'consecutive_successes': tensor([...]),  # per-env success counts
#     'goal_dist': tensor([...]),              # per-env goal distances
#     'reward_components': {                   # custom reward breakdown
#         'forward_reward': tensor([...]),
#         'alive_reward': tensor([...]),
#     }
# }
# Only values at done_indices are collected (completed episodes).

# At epoch end, the Runner calls:
algo_observer.after_print_stats(frame, epoch_num, total_time)
# This writes mean values of collected metrics to TensorBoard.

Related Pages

Principle:Isaac_sim_IsaacGymEnvs_Checkpoint_Export_and_Logging

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment