[logging] Publish the training loop phase as a Prometheus gauge#1923
Open
eicherseiji wants to merge 3 commits into
Open
[logging] Publish the training loop phase as a Prometheus gauge#1923eicherseiji wants to merge 3 commits into
eicherseiji wants to merge 3 commits into
Conversation
Adds skyrl/train/utils/phase_metrics.py with TrainingPhaseGauge, which sets a skyrl_training_phase gauge to 1.0 for the active macro-phase and 0.0 for the rest via ray.util.metrics. Ray exports it to the same Prometheus that scrapes node GPU metrics, so phase windows join GPU utilization on one wall-clock axis without correlating the experiment tracker by hand. The async loop sets the phase at each existing Timer boundary. Best-effort: the gauge silently no-ops when Ray metrics are unavailable, so it never breaks training or tests.
This was referenced Jul 17, 2026
SumanthRH
marked this pull request as ready for review
July 17, 2026 23:00
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a TrainingPhaseGauge to publish the training loop's current macro-phase (such as eval, training, weight synchronization, and checkpointing) to Prometheus via Ray metrics. This allows training loop phases to be overlaid with cluster-wide GPU utilization metrics. The feedback suggests validating phase names against the defined list of allowed phases to prevent developer typos and silent failures, along with adding a corresponding unit test for this validation.
- Emit only the two changed series per transition instead of sweeping all phases; the full sweep runs once at construction to seed every series for PromQL selectors. - Warn and keep the current phase on an unknown phase name instead of silently zeroing everything. - Rename phases to match their paired Timer keys so wandb timing/* keys and the Prometheus phase label share one vocabulary. - Construct the gauge in __init__ behind trainer.enable_training_phase_gauge, matching the RayGpuMonitor lifecycle. - Deduplicate docstrings and comments; add unknown-phase and disabled-by-flag tests.
The gauge writes two in-process values per phase transition with no thread or I/O, so there is nothing an operator needs to switch off. Construct it unconditionally; it already no-ops without Ray.
eicherseiji
added a commit
to eicherseiji/SkyRL
that referenced
this pull request
Jul 18, 2026
ScalarGauges had no functional dependency on TrainingPhaseGauge; the stack existed only because both classes shared phase_metrics.py. Move ScalarGauges to its own module (scalar_gauges.py, one module per concern) and revert the phase-gauge content from this branch's tree, so this PR is independently mergeable and its diff is buffer-only. Forward revert, no history rewrite; NovaSky-AI#1923 still owns the phase gauge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Publishes which macro-phase the fully async training loop is in as a Prometheus gauge. Today, joining "what was the loop doing" to "how busy were the GPUs" means hand-correlating the experiment tracker against Prometheus by wall-clock.
New metric:
skyrl_training_phase{phase=...}: 1.0 for the active phase, 0.0 for the rest. Phases match the loop'sTimer()keys (wait_for_generation_buffer,convert_to_training_input,run_training,sync_weights,eval,save_checkpoints) plus the defaultgenerating, so the wandbtiming/*keys and the Prometheus label share one vocabulary.Ray exports it to the same Prometheus that scrapes node GPU metrics, so per-phase GPU utilization is a single-store query:
Prometheus also survives a cluster restart, when the tracker may be unreachable.
How
New module
skyrl/train/utils/phase_metrics.pywithTrainingPhaseGauge, following the one-module-per-concern layout ofray_gpu_monitor.py. The trainer constructs it in__init__and sets the phase at each existingTimer()boundary. Each transition writes only the two changed series; construction seeds all series so PromQL selectors never hit a missing one. Best-effort: it no-ops when Ray metrics are unavailable and warns on unknown phase names, so it never breaks training or tests.Tests
tests/train/utils/test_phase_metrics.py(new): exactly one phase active, context-manager restore, unknown-phase rejection, no-op when Ray is unavailable. 5 passed.