mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Async execution causes errors in distributed computation.

Open mcxkarakoc opened this issue 9 years ago • 3 comments

bind_exec() method in python/module/executor_group.py may cause libzmq communication errors in distributed computation since output arrays of executors are tried to be read before they are filled completely. To my findings, the related code part may be fixed as below.

        if self.for_training:
            self.grad_arrays = [[exec_.grad_arrays[i] for exec_ in self.execs]
                                for i, name in enumerate(self.arg_names)
                                if  exec_.grad_arrays[i].wait_to_read() or name in self.param_names]
        else:
            self.grad_arrays = None

        data_names = [x[0] for x in data_shapes]
        if self.inputs_need_grad:
            self.input_grad_arrays = [[exec_.grad_arrays[i] for exec_ in self.execs]
                                      for i, name in enumerate(self.arg_names)
                                      if exec_.grad_arrays[i].wait_to_read() or name in data_names]

mcxkarakoc avatar Jan 09 '17 01:01 mcxkarakoc

Not sure anymore :) Depending on -n parameter of launch.py, different errors are raised. Examining.

mcxkarakoc avatar Jan 09 '17 02:01 mcxkarakoc

I'm much more sure now :) The second sentence in my previous comment was due to MxNet version conflict. Please forget it. However, my first comment seems true but my solution is syntactically incorrect, semantically correct :) The correct solution, to me of course, is as below:

        if self.for_training:
            self.grad_arrays = [[exec_.grad_arrays[i] for exec_ in self.execs if exec_.grad_arrays[i].wait_to_read() or True]
                                for i, name in enumerate(self.arg_names)
                                if name in self.param_names]
        else:
            self.grad_arrays = None

        data_names = [x[0] for x in data_shapes]
        if self.inputs_need_grad:
            self.input_grad_arrays = [[exec_.grad_arrays[i] for exec_ in self.execs if exec_.grad_arrays[i].wait_to_read() or True]
                                      for i, name in enumerate(self.arg_names)
                                      if name in data_names]

mcxkarakoc avatar Jan 09 '17 10:01 mcxkarakoc

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

yajiedesign avatar Sep 28 '17 08:09 yajiedesign