Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytorch_lightning/accelerators/accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def backward(self, closure_loss, optimizer, opt_idx, *args, **kwargs):
)
else:
# do backward pass
model = self.trainer.get_model()
model = self.trainer.model
Copy link
Contributor

Choose a reason for hiding this comment

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

ummm... this will break the other accelerators no?
DP will be wrapped, and so will the ddp one?

Copy link
Contributor Author

@ananthsub ananthsub Oct 28, 2020

Choose a reason for hiding this comment

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

The motivating factor is skipping parameter syncs in DDP (#4301). While accumulating gradients,

  • training_step_and_backward calls training_loop backward
  • training_loop backward calls accelerator backward here
  • accelerator backward reaches into the DP/DDP model and extracts the module inside and calls backward on that
  • which ignores the flags here:

How should we respect those settings in the backwards pass here?

model.backward(closure_loss, optimizer, opt_idx, *args, **kwargs)

# once backward has been applied, release graph
Expand Down