[misc,trainer,rollout] feat: add Prometheus metrics logging to experiment tracking#5291
Open
guillemgt wants to merge 6 commits intoverl-project:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a PrometheusClient to query and log metrics from Prometheus to experiment tracking backends. The implementation is well-structured, including features like Ray head node discovery, caching, and retry logic. However, I've identified two critical issues in the error handling within prometheus_utils.py. One issue in the Ray head node discovery defaults to localhost on any failure, which is problematic in a distributed setting. The other issue is in the metric querying loop, which silently swallows all exceptions. Addressing these will significantly improve the robustness and debuggability of this new feature.
b1e6d83 to
3a60c25
Compare
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?
Adds the ability to query Prometheus metrics and log them to experiment tracking backends (WandB, TensorBoard, MLflow, etc.) during training. This allows users to correlate infrastructure metrics (GPU cache usage, throughput) with training metrics in a unified view.
Checklist Before Starting
[{modules}] {type}: {description}Test
Testing was performed locally/internally during development. The feature has been validated to work correctly with:
Due to the complexity of mocking Ray and Prometheus infrastructure, comprehensive unit tests are not included in this PR. The feature can be validated end-to-end by configuring
metrics_to_logand verifying metrics appear in experiment tracking backends.Test
Tested with the example config below. Metric was successfully logged to
rollout/vllm_generation_tokens_totalin tensorboard over a 20 iteration run on 2 nodes.API and Usage Example
Design & Code Changes
verl/workers/config/rollout.py: Addmetrics_to_logfield toPrometheusConfigverl/experimental/agent_loop/prometheus_utils.py: AddPrometheusClientclass (~180 lines)verl/trainer/ppo/ray_trainer.py: Initialize client and query metrics before loggingChecklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.