Standardized representation of logic deployable to MapReduce-like systems.

This class docstring describes the purpose of MapReduceForm as a data structure; for a discussion of the conceptual content of an instance mrf of MapReduceForm, including how precisely it maps to a single federated round, see the package-level docstring.

This standardized representation can be used to describe a range of iterative processes representable as a single round of MapReduce-like processing, and deployable to MapReduce-like systems that are only capable of executing plain TensorFlow code.

Non-iterative processes, or processes that do not originate at the server can be described by MapReduceForm, as well as degenerate cases like computations which use exclusively one of the two possible aggregation paths.

Instances of this class can be generated by TFF's transformation pipeline and consumed by a variety of backends that have the ability to orchestrate their execution in a MapReduce-like fashion. The latter can include systems that run static data pipelines such Apache Beam or Hadoop, but also platforms like that which has been described in the following paper:

"Towards Federated Learning at Scale: System Design"

It should be noted that not every computation that proceeds in synchronous rounds is representable as an instance of this class. In particular, this representation is not suitable for computations that involve multiple phases of processing, and does not generalize to arbitrary static data pipelines. Generalized representations that can take advantage of the full expressiveness of Apache Beam-like systems may emerge at a later time, and will be supported by a separate set of tools, with a more expressive canonical representation.

The requirement that the variable constituents of the template be in the form of pure TensorFlow code (not arbitrary TFF constructs) reflects the intent for instances of this class to be easily converted into a representation that can be compiled into a system that does not have the ability to interpret the full TFF language (as defined in computation.proto), but that does have the ability to run TensorFlow. Client-side logic in such systems could be deployed in a number of ways, e.g., as shards in a MapReduce job, to mobile or embedded devices, etc.

The individual TensorFlow computations that constitute an iterative process in this form are supplied as constructor arguments. Generally, this class will not be instantiated by a programmer directly but targeted by a sequence of transformations that take a tff.templates.IterativeProcess and produce the appropriate pieces of logic.

initialize The computation that produces the initial server state.
prepare The computation that prepares the input for the clients.
work The client-side work computation.
zero The computation that produces the initial state for accumulators.
accumulate The computation that adds a client update to an accumulator.
merge The computation to use for merging pairs of accumulators.
report The computation that produces the final server-side aggregate for the top level accumulator (the global update).
bitwidth The computation that produces the bitwidth for secure sum.
update The computation that takes the global update and the server state and produces the new server state, as well as server-side output.
server_state_label Optional string label for the server state.
client_data_label Optional string label for the client data.

TypeError If the Python or TFF types of the arguments are invalid or not compatible with each other.
AssertionError If the manner in which the given TensorFlow computations are represented by TFF does not match what this code is expecting (this is an internal error that requires code update).








securely_aggregates_tensors Whether the MapReduceForm uses secure aggregation.






View source

Prints a string summary of the MapReduceForm.

print_fn Print function to use. It will be called on each line of the summary in order to capture the string summary.