Creates common worlds (up to max_concurrent_context) and manage the sequential execution of collectives that shares the same context with cyclic control inputs.
| 1305 | |
| 1306 | |
| 1307 | class CollectivesConcurrencyControl: |
| 1308 | """ |
| 1309 | Creates common worlds (up to max_concurrent_context) and manage the |
| 1310 | sequential execution of collectives that shares the same context with |
| 1311 | cyclic control inputs. |
| 1312 | """ |
| 1313 | def __init__( |
| 1314 | self, |
| 1315 | name, |
| 1316 | max_concurrent_context, |
| 1317 | param_init_net, |
| 1318 | rendezvous |
| 1319 | ): |
| 1320 | self.name = name |
| 1321 | self.param_init_net = param_init_net |
| 1322 | self.max_concurrent_context = max_concurrent_context |
| 1323 | self.counter = 0 |
| 1324 | self.common_worlds = [] |
| 1325 | self.control_inputs = [] |
| 1326 | self.rendezvous = rendezvous |
| 1327 | |
| 1328 | def get_control_and_context(self, control_output_blob): |
| 1329 | common_world, control_input = [None, None] |
| 1330 | current_slot = self.counter % self.max_concurrent_context |
| 1331 | if len(self.common_worlds) < self.max_concurrent_context: |
| 1332 | common_world = _CreateOrCloneCommonWorld( |
| 1333 | self.param_init_net, |
| 1334 | "{}_{}_cw".format(self.name, current_slot), |
| 1335 | rendezvous=self.rendezvous, |
| 1336 | ) |
| 1337 | self.common_worlds.append(common_world) |
| 1338 | self.control_inputs.append(control_output_blob) |
| 1339 | else: |
| 1340 | common_world = self.common_worlds[current_slot] |
| 1341 | control_input = self.control_inputs[current_slot] |
| 1342 | self.control_inputs[current_slot] = control_output_blob |
| 1343 | self.counter += 1 |
| 1344 | return common_world, control_input |
| 1345 | |
| 1346 | |
| 1347 | def _AllReduceBlobsDistributed( |
no outgoing calls
no test coverage detected
searching dependent graphs…