Missed TensorFlow World? Check out the recap. Learn more

tff.framework.FederatedExecutor

View source on GitHub

Class FederatedExecutor

The federated executor orchestrates federated computations.

Inherits From: Executor

NOTE: This component is only available in Python 3.

The intrinsics currently implemented include: - federated_aggregate - federated_apply - federated_broadcast - federated_map - federated_mean - federated_reduce - federated_sum - federated_value - federated_weighted_mean - federated_zip

This executor is only responsible for handling federated types and federated operators, and a delegation of work to an underlying collection of target executors associated with individual system participants. This executor does not interpret lambda calculus and compositional constructs (blocks, etc.). It understands placements, selected intrinsics (federated operators), it can handle tuples, selections, and calls in a limited way (to the extent that it deals with intrinsics or lambda expressions it can delegate).

The initial implementation of the executor only supports the two basic types of placements (SERVER and CLIENTS), and does not have a built-in concept of intermediate aggregation, partitioning placements, clustering clients, etc.

The initial implementation also does not attempt at performing optimizations in case when the constituents of this executor are either located on the same machine (where marshaling/unmarshaling could be avoided), or when they have the all_equal property (and a single value could be shared by them all).

__init__

View source

__init__(target_executors)

Creates a federated executor backed by a collection of target executors.

Args:

  • target_executors: A dictionary mapping placements to executors or lists of executors associated with these placements. The keys in this dictionary can be either placement literals, or None to specify the executor for unplaced computations. The values can be either single executors (if there only is a single participant associated with that placement, as would typically be the case with tff.SERVER) or lists of target executors.

Raises:

  • ValueError: If the value is unrecognized (e.g., a nonexistent intrinsic).

Methods

create_call

View source

create_call(
    comp,
    arg=None
)

A coroutine that creates a call to comp with optional argument arg.

Args:

  • comp: The computation to invoke. It must have been first embedded in the executor by calling create_value() on it first.
  • arg: An optional argument of the call, or None if no argument was supplied. If it is present, it must have been embedded in the executor by calling create_value() on it first.

Returns:

An instance of executor_value_base.ExecutorValue that represents the constructed vall.

create_selection

View source

create_selection(
    source,
    index=None,
    name=None
)

A coroutine that creates a selection from source.

Args:

  • source: The source to select from. The source must have been embedded in this executor by invoking create_value() on it first.
  • index: An optional integer index. Either this, or name must be present.
  • name: An optional string name. Either this, or index must be present.

Returns:

An instance of executor_value_base.ExecutorValue that represents the constructed selection.

create_tuple

View source

create_tuple(elements)

A coroutine that creates a tuple of elements.

Args:

  • elements: An enumerable or dict with the elements to create a tuple from. The elements must all have been embedded in this executor by invoking create_value() on them first.

Returns:

An instance of executor_value_base.ExecutorValue that represents the constructed tuple.

create_value

View source

create_value(
    value,
    type_spec=None
)

A coroutine that creates embedded value from value of type type_spec.

This function is used to embed a value within the executor. The argument can be one of the plain Python types, a nested structure, a representation of a TFF computation, etc. Once embedded, the value can be further passed around within the executor. For functional values, embedding them prior to invocation potentally allows the executor to amortize overhead across multiple calls.

Args:

  • value: An object that represents the value to embed within the executor.
  • type_spec: An optional tff.Type of the value represented by this object, or something convertible to it. The type can only be omitted if the value is a instance of tff.TypedObject.

Returns:

An instance of executor_value_base.ExecutorValue that represents the embedded value.