Allow unused params in distributed training
Summary: Context from https://fb.workplace.com/groups/1405155842844877/permalink/2785095451517569/: I am adding a model to pyspeech (formerly fairspeq) with the following `forward`: ``` def forward(self, src_tokens, src_lengths, prev_output_tokens, name): encoder_out = self.encoder(src_tokens, src_lengths) if name == Dataset.d1: decoder_out = self.decoder1(prev_output_tokens, encoder_out) elif name == Dataset.d2: decoder_out = self.decoder2(encoder_out) return decoder_out ``` When I run distributed training on this model, I get the following error: ``` RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by (1) passing the keyword argument `find_unused_parameters=True` to `torch.nn.parallel.DistributedDataParallel`; (2) making sure all `forward` function outputs participate in calculating loss. If you already have done the above two steps, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's `forward` function. Please include the loss function and the structure of the return value of `forward` of your module when reporting this issue (e.g. list, dict, iterable). (prepare_for_backward at caffe2/torch/csrc/distributed/c10d/reducer.cpp:410) ``` The recommended fix is to pass find_unused_parameters=True to DistributedDataParallel's initialization Reviewed By: myleott Differential Revision: D15439726 fbshipit-source-id: 7fd80d4a3f49ac90182dec723b49b14e6689406a
Showing
Please register or sign in to comment