Skip to content

Conversation

@yuchongzhang
Copy link
Collaborator

PR Type

[Feature | Fix | Documentation | Other() ]
Feature

Short Description

The main goal of this PR is to redesign the parameter packing component of the parameter exchanger. The packing component is now its own module parameter_packer, and is decoupled from the exchanger itself. I used Generics to support better typing for the packer class. I also used the packers to refactor the strategies.

Tests Added

N/A

def __init__(self, parameter_packer: ParameterPacker[T]) -> None:
super().__init__()
self.parameter_packer = parameter_packer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By default, ParameterExchangerWithPacking exchanges all parameters like FullParameterExchanger. We can create subclasses of it if we wish to use different exchanging methods. e.g.: NormDriftLayerExchanger

class NormDriftLayerExchanger(ParameterExchangerWithPacking[List[str]]):
def __init__(self, threshold: Scalar) -> None:
"""
self.initial_model represents each client's local model at the beginning of each round of training.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest editing this comment a bit so that it better reflects the new structure of the class.

initial_model_states = self.initial_model.state_dict()
initial_model_states = initial_model.state_dict()
model_states = model.state_dict()
for layer_name in model_states:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I realized we forgot to reformat this for loop in the previous PR, so I'd suggest we do it here.

for layer_name, layer_param in model_states.items():

Then you don't need to do the extra indexing step in line 58 below.

Copy link
Collaborator

@emersodb emersodb left a comment

Choose a reason for hiding this comment

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

Two small comments from me. Otherwise, this is a really great change in my opinion.

@yuchongzhang
Copy link
Collaborator Author

Good catch! I have fixed the comments and reformatted the for loop.

Copy link
Contributor

@jewelltaylor jewelltaylor left a comment

Choose a reason for hiding this comment

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

Everything looks good from my end! Decoupling the Parameter Packer from the exchanger and adding generic typing makes the code much cleaner. I will leave it to David for the final approval to make sure he is happy with how you addressed his suggestions (which seems to be the case but not for me to say)

Copy link
Collaborator

@fatemetkl fatemetkl left a comment

Choose a reason for hiding this comment

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

I also reviewed the PR to make sure that I am updated with the changes. Looks good!

Copy link
Collaborator

@emersodb emersodb left a comment

Choose a reason for hiding this comment

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

Good to merge

@yuchongzhang yuchongzhang merged commit 8cf5a00 into main Jun 30, 2023
@yuchongzhang yuchongzhang deleted the exchanger-refactor branch June 30, 2023 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants