tff.program.ProgramStateManager

An interface for saving and loading program state in a federated program.

A tff.program.ProgramStateManager is used to implement fault tolerance in a federated program. The structure or type of the program state that is saved is unknown at construction time and can change as the program runs.

Methods

get_versions

View source

Returns a list of saved versions or None.

Returns
A list of saved versions or None if there is no saved program state.

load

View source

Returns the saved program state for the given version.

Args
version A integer representing the version of a saved program state.
structure The structure of the saved program state for the given version used to support serialization and deserailization of user-defined classes in the structure.

Raises
ProgramStateNotFoundError If there is no program state for the given version.

load_latest

View source

Returns the latest saved program state and version or (None, 0).

Args
structure The structure of the saved program state for the given version used to support serialization and deserailization of user-defined classes in the structure.

Returns
A tuple of the latest saved (program state, version) or (None, 0) if there is no latest saved program state.

save

View source

Saves program_state for the given version.

Args
program_state A tff.program.ProgramStateStructure to save.
version A strictly increasing integer representing the version of a saved program_state.

Raises
ProgramStateExistsError If there is already program state for the given version.