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.
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.
Most helpful comment
Close this issue :) ?