-
Notifications
You must be signed in to change notification settings - Fork 182
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
Add P2P distributed optimization to advanced examples #3189
base: main
Are you sure you want to change the base?
Add P2P distributed optimization to advanced examples #3189
Conversation
examples/advanced/distributed_optimization/nvdo/controllers/base.py
Outdated
Show resolved
Hide resolved
examples/advanced/distributed_optimization/nvdo/executors/base.py
Outdated
Show resolved
Hide resolved
examples/advanced/distributed_optimization/nvdo/executors/consensus.py
Outdated
Show resolved
Hide resolved
@chesterxgchen I implemented your suggested changes:
Let me know what you think. Now that it's moved to the core, I feel implementation part could be changed/improved by offloading to the user things like saving the results, storing losses via callbacks, monitoring, etc - perhaps it makes more sense to do that at a later stage though |
Tested locally and runs fine. The tutorial is great! Should consider adding some CI testing in a future PR. |
# Store the received value in the neighbors_values dictionary | ||
self.neighbors_values[iteration][sender] = self._from_message(data["value"]) | ||
# Check if all neighbor values have been received for the iteration | ||
if len(self.neighbors_values[iteration]) >= len(self.neighbors): |
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.
do we reset the neighbors_values once we have all of them for next round ?
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.
We need to maintain values per iteration and delete the values after they're consumed in the algorithm. More details in examples/advanced/distributed_optimization/README.md
neighbors_values
needs to maintain a dictionary of received values per iteration. This is because, different parts of a network may be at different iterations of the algorithm (plus or minus 1 at most) - this means that I could receive a message from a neighbor valid for iterationt+1
when I'm still at iterationt
. Since that message won't be sent again, I need to store it. To avoid theneighbors_values
to grow indefinitely, we'll delete its content at iterationt
after having consumed its values and moving to the next iteration in the algorithm. We'll see that in the next section.
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.
add a few more comments
implemented renaming of dist opt controllers and executors + added synchronization |
Description
This PR adds a new set of advanced examples in
examples/advanced/distributed_optimization
, showing how to use the lower-level APIs to build P2P distributed optimization algorithms.Types of changes