Server pull weights from clients. Namely clients push weights to the server. It is the gather process.
(self)
| 116 | return self.weights |
| 117 | |
| 118 | def pull(self) -> None: |
| 119 | """Server pull weights from clients. |
| 120 | |
| 121 | Namely clients push weights to the server. It is the gather process. |
| 122 | """ |
| 123 | # open space to collect weights from clients |
| 124 | datas = [proto.WeightsExchange() for _ in range(self.num_clients)] |
| 125 | weights = defaultdict(list) |
| 126 | # receive weights sequentially |
| 127 | for i in range(self.num_clients): |
| 128 | datas[i] = utils.receive_message(self.conns[i], datas[i]) |
| 129 | for k, v in datas[i].weights.items(): |
| 130 | weights[k].append(utils.deserialize_tensor(v)) |
| 131 | # aggregation |
| 132 | self.aggregate(weights) |
| 133 | |
| 134 | def push(self) -> None: |
| 135 | """Server push weights to clients. |