-
Notifications
You must be signed in to change notification settings - Fork 24
metric logger - backend (1/N) #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
f570456
to
9f13bfb
Compare
felipemello1
commented
Sep 23, 2025
felipemello1
commented
Sep 23, 2025
src/forge/observability/metrics.py
Outdated
return reduced_metrics | ||
|
||
|
||
class LoggerBackend(ABC): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempted to move all backend related things to logger_backends.py
allenwang28
reviewed
Sep 24, 2025
allenwang28
approved these changes
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
Ritesh1905
pushed a commit
that referenced
this pull request
Sep 29, 2025
* metric logger simple example * it works * delete old files * refactoring + docstrings * docstring * comments * update method name * no circular import * update command * update arg name * move metric actor out of asyncio lock * fix deregister * lint * docstring * fix result extraction and add logger shutdown * fix shutdown order * simplification + docstrings * bug fix + register if respawn * it works * use procmesh as key * docstring * remove protected imports * create get_metric_logger * call became fanout * upstream changes --------- Co-authored-by: Felipe Mello <[email protected]>
casteryh
added a commit
that referenced
this pull request
Sep 29, 2025
* dcp efficiency and weight cleanup * await! * key error * metric logger - backend (1/N) (#191) * metric logger simple example * it works * delete old files * refactoring + docstrings * docstring * comments * update method name * no circular import * update command * update arg name * move metric actor out of asyncio lock * fix deregister * lint * docstring * fix result extraction and add logger shutdown * fix shutdown order * simplification + docstrings * bug fix + register if respawn * it works * use procmesh as key * docstring * remove protected imports * create get_metric_logger * call became fanout * upstream changes --------- Co-authored-by: Felipe Mello <[email protected]> * Generalize the policy update integration test to sanity check on any model config (for Titan + vLLM) (#241) * commit * flag * format * nit * nit * dcp efficiency and weight cleanup * await! * key error * import at top --------- Co-authored-by: Felipe Mello <[email protected]> Co-authored-by: Felipe Mello <[email protected]> Co-authored-by: Jiyue Wang <[email protected]>
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.
Implemented it on a toy script. Will add real metrics to grpo main.py.
To log from anywhere:
Testing
TLDR 3 ways of doing wandb distributed training
https://docs.wandb.ai/guides/track/log/distributed-training/
a) Track a single process:
Pros:
Cons:
b) Track multiple processes:
Pros:
Cons:
c) Track all processes to a single wandb run ID (experimental):
pros:
Cons:
Requirements:
1) Every process should log to the same train step
For each train_step we have 3 generation steps. They should all belong to the same train_step x-axis.
2) We need a local reduction per train step
If we want the mean
time_generation_step
per train_step, we have to reduce it ourselves. wandb only keeps the latests3) We need a global and a local logger
Local loggers are responsible for:
i) per-rank wandb instantiation;
ii) collecting local data.
Global loggers are responsible for communicating:
i) train step + flush command: necessary for all 3 wandb modes;
ii) shared wandb run_id: necessary for option C;
iii) optionally collecting and reducing to rank 0: Necessary for option A
Q1: Can we get rid of local_logger and just use global_logger for everything?
A1: Probably not. For options (b,c) we need to instantiate per rank. Perhaps we could instantiate N instances in a single rank, but this doesn’t make much sense to me. For option (a), we could use just a global logger, but it seems easier to manage it per rank.
4) User must have easy access to a dashboard with a general view of the system
This means that we should NOT require internal tools or external infra setup for basic metric logging. WandB seems to be the best fit for this.
Recommendation
We should support (a) Track a single process with wandb and (b) Track multiple processes with jsonl dump per rank.
Design
These 3 steps are independent:
a) collecting metrics
b) reducing metrics (we can decide to reduce, log per rank, log only on rank 0)
c) flushing metrics to wandb, scuba, jsonl, etc
Controller has a GlobalLoggingActor, every rank has a LocalFetcherActor + MetricLoggerSingleton
a. When a service is spawned, we also spawn a LocalFetcherActor per rank.
b. After every training step, a GlobalLoggingActor calls every LocalFetcherActor which calls MetricLoggerSingleton.
Why?
Each rank can just call the singleton anywhere. This is easy and clean, but a bit counterintuitive at first, i.e. "push metrics to where?" The singleton buffers per-key/train_step, applies local reduction on fetch call.
Other alternative is to instantiate a class at every actor and pass it around. But I am not sure how to fetch it from GlobalLoggingActor.
Q1 : Why not just use the
LocalFetcherActor
and drop the Singleton?A1: Because i couldn't find a way to find the
LocalFetcherActor
for each rank from the contextQ2: And how is the
GlobalMetricLogger
aware ofLocalFetcherActor
andLocalLoggingSingleton
?A2: in
get_proc_mesh
Then in the main loop: