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

Fix DDP Reduction in PyTorch 1.7 when the model has unused parameters #586

Merged
merged 3 commits into from
Feb 8, 2021

Conversation

erikwijmans
Copy link
Contributor

Motivation and Context

PyTorch 1.7 slightly changed the way Reducer should be used when the model has unused parameters, leading to DD-PPO breaking when the model does, why this is certainly an edge case, it is a problem.

This PR solve this and attempts to solve future issues by using a wrapper to interface with DDP's forward call instead of using the undocumented Reducer APIs. While I am not sure if this won't cause it's own issues since it is kinda hacky, this seems like it has the potential to be better.

How Has This Been Tested

Tested on a model with unused parameters. I will write a test for this before merging this, but don't have time today.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 4, 2021
habitat_baselines/rl/ddppo/algo/ddppo.py Outdated Show resolved Hide resolved
@@ -152,6 +152,13 @@ def update(self, rollouts: RolloutStorage) -> Tuple[float, float, float]:

return value_loss_epoch, action_loss_epoch, dist_entropy_epoch

def evaluate_actions(
Copy link
Contributor

Choose a reason for hiding this comment

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

Doc string will be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add a little doc string and made it internal since it just exists to be overridden with inheritance.

@erikwijmans erikwijmans requested a review from mathfac February 5, 2021 23:34
@erikwijmans
Copy link
Contributor Author

@mathfac @Skylion007 does this test look reasonable? It's a little ugly but I wanted it to be as close to testing the actual code path used in training as possible.

@erikwijmans erikwijmans merged commit 1e057da into master Feb 8, 2021
@erikwijmans erikwijmans deleted the ddppo-1.7-fix-unused-params branch February 8, 2021 23:05
@mathfac
Copy link
Contributor

mathfac commented Feb 9, 2021

Yes, looks good.

dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jul 8, 2024
…facebookresearch#586)

* Hacky thing to interface with ddp.forward

* State guard

* Add unit test and comment in readme about it.
HHYHRHY pushed a commit to SgtVincent/EMOS that referenced this pull request Aug 31, 2024
…facebookresearch#586)

* Hacky thing to interface with ddp.forward

* State guard

* Add unit test and comment in readme about it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants