tff.program.FilteringReleaseManager

A tff.program.ReleaseManager that filters values before releasing them.

Inherits From: ReleaseManager

A tff.program.FilteringReleaseManager is a utility for filtering values before releasing the values and is used to release values from platform storage to customer storage in a federated program.

Values are filtered using a filter_fn and released to the release_manager.

The filter_fn is a Callable that has a single parameter path and returns a bool, and is used to filter values before they are released. A path is a tuple of indices and/or keys which uniquely identifies the position of the corresponding item in the value; path matches the expectations of the tree library.

The filter_fn is applied to the items in the structure but not the structure itself. If all the items in a structure are filtered out, then the structure will be filtered out as well.

For example:

filtering_manager = tff.program.FilteringReleaseManager(
    release_manager=...,
    filter_fn=...,
)

value = {
  'loss': 1.0,
  'accuracy': 0.5,
}
await filtering_manager.release(value, ...)

If filter_fn is:

  • lambda _: True then the entire structure is released.
  • lambda _: False then nothing is released.
  • lambda path: path == ('loss',) then {'loss': 1.0} is released.

release_manager A tff.program.ReleaseManager used to release values to.
filter_fn A Callable used to filter values before they are released, this function has a single parameter path and returns a bool.

Methods

release

View source

Releases value from a federated program.

Args
value A tff.program.ReleasableStructure to release.
type_signature The tff.Type of value.
key A value used to reference the released value.

Raises
NotFilterableError If the value cannot be filtered.