Pysyft: One-worker Bug

Created on 25 Jul 2019  路  4Comments  路  Source: OpenMined/PySyft

Describe the bug
When we set only one client/work in federated learning task, the corresponding _FederatedDataLoader_ does not work:

"....\syft\frameworks\torch\federated\dataloader.py", line 245, in __next__
iterator = self.iterators[0]
IndexError: list index out of range

I checked the code of dataloader.py and found the probable problem here:

        if iter_per_worker:
            self.num_iterators = len(self.workers)
        else:
            # You can't have more iterators than n - 1 workers, because you always
            # need a worker idle in the worker switch process made by iterators
            self.num_iterators = min(num_iterators, len(self.workers) - 1)

where the num_iterators is set to 1, making the last statement of the codes above yields 0 (because min(1, 1-1) = 0) when len(self.workers) = 1. Consequently, no iterators available and thus the dataloader fails to work.

I wanted to test one-work FL for some reason and this bug appeared.

Most helpful comment

Close this issue :) ?

All 4 comments

I'll look into this

@wentaiwu92 you can use iter_per_worker=True while calling FederatedDataLoader. That will allow you to have one iterator for one worker.
I hope that will help if not let me know I would be happy to help :)

Close this issue :) ?

Thanks ShivamSRS and kamathhrishi, PySyft is really helpful for FL.

Was this page helpful?
0 / 5 - 0 ratings