tff.aggregators.EncodedSumFactory

UnweightedAggregationFactory for encoded sum.

Inherits From: UnweightedAggregationFactory

Used in the notebooks

Used in the tutorials

The created tff.templates.AggregationProcess aggregates values placed at CLIENTS according to the provided GatherEncoder objects, and outputs the result placed at SERVER.

A GatherEncoder defines encode and decode methods, which are applied by CLIENTS before aggregation and by SERVER after aggregation. Usually these are such that the encoded representation communicated from CLIENTS to SERVER is smaller than communicating the original value, possibly at a cost of communicating slightly inaccurate values. A common example is to apply quantization. In addition, GatherEncoder enables the decoding logic to be split based on which part of its decode part commutes with sum, which is automatically utilized by the implementation.

encoder_fn A one-arg callable, mapping a tf.TensorSpec, to a GatherEncoder.

Methods

create

View source

Creates a tff.aggregators.AggregationProcess without weights.

The provided value_type is a non-federated tff.Type, that is, not a tff.FederatedType.

The returned tff.aggregators.AggregationProcess will be created for aggregation of values matching value_type placed at tff.CLIENTS. That is, its next method will expect type <S@SERVER, {value_type}@CLIENTS>, where S is the unplaced return type of its initialize method.

Args
value_type A non-federated tff.Type.

Returns
A tff.templates.AggregationProcess.

quantize_above_threshold

View source

Quantization of values with at least threshold elements.

Given a value_type in the create method, this classmethod configures the EncodedSumFactory to apply uniform quantization to all instances of tff.TensorType in the value_type which have more than threshold elements.

Precisely, for each tensor t, this operation corresponds to t = round((t - min(t)) / (max(t) - min(t)) * (2**quantizaton_bits - 1)).

If a type does not have more than threshold elements, it is summed directly without being modified.

Args
quantization_bits A integer specifying the quantization bitwidth.
threshold A non-negative integer. Only tensors with more than this number of elements are quantized.
**kwargs Keyword arguments.

Returns
An EncodedSumFactory.