Skip to content

feat(logging): add W&B worker GPU system metrics#1428

Open
EazyReal wants to merge 4 commits into
areal-project:mainfrom
EazyReal:feat/wandb-worker-system-metrics
Open

feat(logging): add W&B worker GPU system metrics#1428
EazyReal wants to merge 4 commits into
areal-project:mainfrom
EazyReal:feat/wandb-worker-system-metrics

Conversation

@EazyReal

@EazyReal EazyReal commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description

In single-controller training, the controller owns the primary W&B run while actor/rollout/critic workers own the CUDA devices. Controller-only W&B logging can miss worker GPU utilization. This PR adds opt-in worker-side W&B shared-mode clients for system metrics.

Key behavior:

  • Disabled by default under stats_logger.wandb.system_metrics.enabled.
  • Requires stats_logger.wandb.mode: shared; existing disabled, offline, and online runs keep current behavior.
  • Worker clients attach to the same run as non-primary clients, labeled by role/rank, with x_update_finish_state=False so workers cannot finalize the primary run.
  • roles defaults to train/rollout roles; roles: null enables every non-service worker role while skipping *-data and *-guard service workers.
  • Worker init/finish is idempotent, lock-protected, and warning-only on W&B worker init failures.
  • English/Chinese docs and generated CLI references cover the config.
stats_logger:
  wandb:
    mode: shared
    system_metrics:
      enabled: true
      roles: [actor, rollout]
      gpu_device_ids: null

Validation

  • uv run pytest -q tests/test_wandb_system_metrics.py
  • uv run ruff check areal/api/cli_args.py areal/utils/wandb_system_metrics.py docs/generate_cli_docs.py tests/test_wandb_system_metrics.py
  • uv run ruff format --check areal/api/cli_args.py areal/utils/wandb_system_metrics.py docs/generate_cli_docs.py tests/test_wandb_system_metrics.py
  • uv run python docs/generate_cli_docs.py
  • git diff --check

Related Issue

Supersedes detached-fork #1338.

Type of Change

  • New feature
  • Documentation update
  • Test coverage improvement

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces worker-side Weights & Biases (W&B) system metrics collection, allowing GPU worker processes to attach to the same shared W&B run as the controller. It adds a new WandBSystemMetricsConfig configuration, integrates initialization and cleanup hooks across RPC servers and schedulers, and adjusts trainer initialization order to ensure the controller's primary run is established first. Feedback on the changes suggests resolving a type mismatch in WandBSystemMetricsConfig.roles where a tuple is used as a default value for a list-annotated field, recommending the use of default_factory instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread areal/api/cli_args.py Outdated
@EazyReal
EazyReal marked this pull request as ready for review June 21, 2026 17:47
@EazyReal EazyReal changed the title feat: add W&B worker GPU system metrics feat(logging): add W&B worker GPU system metrics Jun 25, 2026
@EazyReal
EazyReal force-pushed the feat/wandb-worker-system-metrics branch from cdc9c77 to 7d84c33 Compare June 30, 2026 08:39
@EazyReal

Copy link
Copy Markdown
Contributor Author

@garrett4wade @nuzant @sitabulaixizawaluduo @rchardx @fishcrap @HwVanICI @guozhihao-224 Could I get a quick review on this W&B metrics PR? It adds worker GPU system metrics without changing training behavior.

EazyReal added 4 commits July 7, 2026 01:39
In single-controller training the controller may run on a CPU node while
actor/rollout workers run on GPU nodes. With ``wandb.mode=online`` only the
controller's process metrics are recorded — worker GPU utilisation is missing.

This change introduces an opt-in worker-side W&B system metrics client using
W&B shared mode:

- Controller initialises the primary run with ``x_primary=True``.
- Selected worker processes attach a non-primary client with a role/rank label,
  ``x_primary=False`` and ``x_update_finish_state=False`` so they contribute
  system metrics only and never finalise the run.
- Worker init is locked, exception-tolerant, and silently skips when disabled.
- ``stats_logger.wandb.system_metrics`` exposes ``enabled``, ``roles`` and
  ``gpu_device_ids``; the WandBConfig validator requires ``mode='shared'``.

Key changes:
- areal/api/cli_args.py: WandBSystemMetricsConfig dataclass + WandBConfig wiring
- areal/utils/wandb_system_metrics.py: worker init/finish + configure hook
- areal/utils/stats_logger.py: controller becomes the primary shared-mode client
- areal/utils/logging.py: register WandBSystemMetrics logger color
- areal/infra/rpc/{rpc_server,ray_rpc_server}.py: register worker hooks
- areal/infra/scheduler/{local,slurm,ray}.py: pre-resolve wandb run id
- areal/trainer/*: init StatsLogger before worker /configure
- docs/{en,zh}: metrics_tracking guide + regenerated CLI reference
- tests/test_wandb_system_metrics.py: unit tests for config and init/finish
Treat roles=null as all non-service worker roles and ignore service guard roles such as data-data or *-guard. This keeps worker W&B clients from starting before the controller primary run exists while preserving the opt-in telemetry path for model workers.
@EazyReal
EazyReal force-pushed the feat/wandb-worker-system-metrics branch from 7d84c33 to f678558 Compare July 7, 2026 08:39
@EazyReal

EazyReal commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@garrett4wade if you have bandwidth, would appreciate a review on the W&B worker metrics config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant