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

checkpointing: use CheckpointTransport abstraction #81

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

d4l3k
Copy link
Member

@d4l3k d4l3k commented Jan 25, 2025

This is a major refactoring of the live checkpointing code.

New behavior:

  • Uses round robin recovery rather than all workers recovering from the primary (new logic in compute_quorum_result)

Key refactors:

  • made a new generalized CheckpointTransport which CheckpointServer implements. This abstraction is designed to be symmetric for recovery strategies that require both sender and receiver to be aware of the communication. This will allow for recovering via ProcessGroups/NCCL which can be significantly faster.
  • Made ManagerClient.quorum return a QuorumResult struct rather than a named tuple
  • Renamed checkpoint_address to checkpoint_metadata as not all transports will be using an address
  • Refactored recovery logic into compute_quorum_result method and added better unit tests for it
  • Added checkpoint_metadata tests (there were no checkpoint_address tests previously)

Test plan:

pytest
cargo test

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 25, 2025
@d4l3k d4l3k force-pushed the d4l3k/checkpoint_transport branch from e1a59f0 to 0105685 Compare January 25, 2025 00:30
@d4l3k d4l3k requested review from H-Huang and fegin January 25, 2025 00:30
@d4l3k d4l3k marked this pull request as ready for review January 25, 2025 00:31
@d4l3k d4l3k force-pushed the d4l3k/checkpoint_transport branch from 0105685 to 0e29ef9 Compare January 25, 2025 00:37
Copy link
Member

@H-Huang H-Huang left a comment

Choose a reason for hiding this comment

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

Overall looks good! Had some comments/questions but partly they are just to clarify my understanding of the changes

@@ -104,6 +104,7 @@ def __init__(
port: Optional[int] = None,
hostname: str = socket.gethostname(),
heartbeat_interval: timedelta = timedelta(milliseconds=100),
checkpoint_transport: Optional[CheckpointTransport[Dict[str, T]]] = None,
Copy link
Member

Choose a reason for hiding this comment

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

How do you envision the CheckpointTransport abstraction will be extended and provided by users?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not really anticipating users implementing one from scratch but I do want to provide two implementations here. One with CheckpointServer and another that's PG based

Advanced users can then use those by themselves or patch things like CheckpointServer to provide more robust implementations for their use cases

src/manager.rs Outdated
})
.collect();
let all_recovering_ranks_set = all_recovering_ranks.iter().collect::<HashSet<_>>();
let serving_ranks: Vec<usize> = participants
Copy link
Member

Choose a reason for hiding this comment

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

nit: I was initially confused by the name serving_ranks, maybe "stable_ranks" or "up_to_date_ranks" would also make sense?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

self._rank, timeout=self._timeout
)
if allow_heal:
if quorum.recovering_ranks:
Copy link
Member

Choose a reason for hiding this comment

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

the if recovering_ranks condition is always true if if heal is true as well right?

Copy link
Member Author

Choose a reason for hiding this comment

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

They're flipped, this checks if anyone will be requesting a checkpoint from this node where as heal below is whether this node will be requesting a checkpoint

heal == quroum.recover_rank is not None which is distinct from quorum.recovering_ranks


// Compute the details for workers at max step.
let max_step = participants.iter().map(|p| p.step).max().unwrap();
let max_participants: Vec<&QuorumMember> =
Copy link
Member

Choose a reason for hiding this comment

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

just checking, once we reach into compute_quorum_results will there always be a nonzero number of ranks at max_step in the quorum?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, there's always at least 1 member at max_step since it's defined as the maximum step of participating members and we'll always have at least 1 member

src/manager.rs Outdated
Ok(ManagerQuorumResponse {
quorum_id: quorum.quorum_id,
// address is used for looking up the checkpoint server address.
recover_manager_address: primary.address.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

how/why do we use the recover_manager_address if the checkpoint loading is done round robin?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch -- this shouldn't be the primary it should be the recover_replica manager address 🤦

src/lib.rs Outdated
replica_rank: 0,
replica_world_size: 1,
recover_manager_address: "".to_string(),
recover_rank: None,
Copy link
Member

@H-Huang H-Huang Jan 27, 2025

Choose a reason for hiding this comment

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

nit: maybe rename recover_rank to recovery_source_rank? Or add comment that clarifies this represents the rank from which the current replica will recover

Copy link
Member Author

Choose a reason for hiding this comment

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

renamed to recover_src_rank and recover_dst_ranks

@d4l3k d4l3k force-pushed the d4l3k/checkpoint_transport branch from 0e29ef9 to 0033713 Compare January 28, 2025 00:18
@d4l3k d4l3k merged commit ccf74d4 into main Jan 28, 2025
6 checks passed
@d4l3k d4l3k deleted the d4l3k/checkpoint_transport branch January 28, 2025 01:25
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.

3 participants