feat(logging): add W&B worker GPU system metrics#1428
Conversation
There was a problem hiding this comment.
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.
cdc9c77 to
7d84c33
Compare
|
@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. |
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.
7d84c33 to
f678558
Compare
|
@garrett4wade if you have bandwidth, would appreciate a review on the W&B worker metrics config. |
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:
stats_logger.wandb.system_metrics.enabled.stats_logger.wandb.mode: shared; existingdisabled,offline, andonlineruns keep current behavior.x_update_finish_state=Falseso workers cannot finalize the primary run.rolesdefaults to train/rollout roles;roles: nullenables every non-service worker role while skipping*-dataand*-guardservice workers.Validation
uv run pytest -q tests/test_wandb_system_metrics.pyuv run ruff check areal/api/cli_args.py areal/utils/wandb_system_metrics.py docs/generate_cli_docs.py tests/test_wandb_system_metrics.pyuv 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.pyuv run python docs/generate_cli_docs.pygit diff --checkRelated Issue
Supersedes detached-fork #1338.
Type of Change