Skip to content
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

Improve log readability #122

Merged
merged 3 commits into from
Mar 7, 2025
Merged

Improve log readability #122

merged 3 commits into from
Mar 7, 2025

Conversation

H-Huang
Copy link
Member

@H-Huang H-Huang commented Mar 5, 2025

Couple of changes to logging:

  • Use a different logging crate
  • Allow log level to be set with RUST_LOG env
  • Add log_if_changed to lighthouse.rs so it will only log if there is a message change. The quorum tick is pretty frequent by default
  • Preprend replica_id to manager.rs logs by adding a new logging macro info_with_replica

Open to suggestion / changes.

Previous log example:
image

full paste: P1747150901

New log example:
image

full paste: P1747151799

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 5, 2025
@H-Huang H-Huang requested a review from d4l3k March 5, 2025 20:23
@@ -191,7 +190,7 @@ def __init__(

if replica_id is None:
replica_id = ""
replica_id = replica_id + str(uuid.uuid4())
Copy link
Member Author

Choose a reason for hiding this comment

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

Wasn't sure why uuid was added to the replica_id, is this needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

ye, I was wondering the same thing. TorchTitan has to keep the original replicate_id because this change every time due to uuid4.

Copy link
Member

Choose a reason for hiding this comment

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

We do this as a simplification for the quorum algorithm -- if a worker restarts quickly with the same name we may not detect that the quorum has changed and thus no-reconfiguration of the PGs will occur. Adding a random UUID to the worker means that we will always detect processes restart and thus correctly trigger a reconfiguration

@H-Huang can you add this back and if it's convenient also add a comment explaining why this is the case? Also it would be nice to add a : to it so replica_01234-1234 shows up as replica_0:1234-1234 . I've been meaning to fix this but haven't had a chance

@fegin
Copy link
Contributor

fegin commented Mar 6, 2025

Allow log level to be set with RUST_LOG env
^
This is super useful !

@@ -191,7 +190,7 @@ def __init__(

if replica_id is None:
replica_id = ""
replica_id = replica_id + str(uuid.uuid4())
Copy link
Member

Choose a reason for hiding this comment

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

We do this as a simplification for the quorum algorithm -- if a worker restarts quickly with the same name we may not detect that the quorum has changed and thus no-reconfiguration of the PGs will occur. Adding a random UUID to the worker means that we will always detect processes restart and thus correctly trigger a reconfiguration

@H-Huang can you add this back and if it's convenient also add a comment explaining why this is the case? Also it would be nice to add a : to it so replica_01234-1234 shows up as replica_0:1234-1234 . I've been meaning to fix this but haven't had a chance

src/manager.rs Outdated
($replica_id:expr, $($arg:tt)*) => {
info!(
"[Replica {}] {}",
$replica_id,
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this macro access self.replica_id instead of taking it as a parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

We would have to move compute_quorum_results() (

fn compute_quorum_results(
) into Manager class if we want to pass in the self instance, should we do that?

Copy link
Member

Choose a reason for hiding this comment

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

ahh this is fine then -- was just curious if we could clean it up a bit but this is fine

Copy link
Member

@d4l3k d4l3k left a comment

Choose a reason for hiding this comment

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

LGTM

@H-Huang H-Huang merged commit 8dd6a09 into pytorch:main Mar 7, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants