MCPcopy Index your code
hub / github.com/pytorch/pytorch / MultiNodeCheckpointManager

Class MultiNodeCheckpointManager

caffe2/python/checkpoint.py:432–634  ·  view source on GitHub ↗

Coordinates checkpointing and checkpointing across multiple nodes. Each of `init`, `load` and `save` will build TaskGroups which will trigger checkpointing on each of the nodes involved in a distributed job. Args: db_prefix: The prefix used to construct full db name. Since

Source from the content-addressed store, hash-verified

430
431
432class MultiNodeCheckpointManager:
433 """
434 Coordinates checkpointing and checkpointing across multiple nodes.
435 Each of `init`, `load` and `save` will build TaskGroups which will
436 trigger checkpointing on each of the nodes involved in a distributed job.
437
438 Args:
439 db_prefix: The prefix used to construct full db name. Since `absolute_path`
440 is set to True, this will be used as db_name in SaveOp.
441 db_type: Type of database to use for storing checkpoint.
442 metadata_handler: An optional object capable of reading/writing
443 checkpoint info in storage of choice.
444 """
445 def __init__(self, db_prefix, db_type, metadata_handler=None):
446 self._node_managers = None
447 self._db_prefix = db_prefix
448 self._db_type = db_type
449 self._metadata_handler = metadata_handler
450 self._path_prefix = None
451 self._path_type = None
452
453 def _task_group(self, func, *args, **kw):
454 assert self._node_managers is not None, 'init must be called first.'
455 with TaskGroup(WorkspaceType.GLOBAL) as task_group:
456 for node, manager in self._node_managers:
457 with Node(node):
458 func(manager, *args, **kw)
459 return task_group
460
461 """
462 Args:
463 nodes: An array of nodes where this checkpoint manager is running.
464 retrieve_from_epoch: Set to a number to load blobs from this epoch.
465 path_prefix: Used to construct db name or path where checkpoint files are
466 stored.
467 path_type: Indicate the type of path where checkpoint files are stored.
468 """
469 def init(
470 self, nodes, retrieve_from_epoch=None, path_prefix=None, path_type=None
471 ):
472 if self._node_managers is not None:
473 assert [node for node, _ in self._node_managers] == nodes
474 return TaskGroup(WorkspaceType.GLOBAL)
475 self._node_managers = []
476 for node in nodes:
477 with Node(node):
478 manager = CheckpointManager(
479 db_prefix=self._db_prefix,
480 node_name=str(node),
481 db_type=self._db_type)
482 self._node_managers.append((node, manager))
483 return self._task_group(
484 CheckpointManager.init,
485 nodes=[node],
486 retrieve_from_epoch=retrieve_from_epoch,
487 path_prefix=path_prefix,
488 path_type=path_type)
489

Calls

no outgoing calls

Tested by 5

builderMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…