fl4health.privacy.fl_accountants module

class ClientLevelAccountant(noise_multiplier, moment_orders=None)[source]

Bases: ABC

abstract get_delta(server_updates, epsilon)[source]
Return type:

float

abstract get_epsilon(server_updates, delta)[source]
Return type:

float

class FlClientLevelAccountantFixedSamplingNoReplacement(n_total_clients, n_clients_sampled, noise_multiplier, moment_orders=None)[source]

Bases: ClientLevelAccountant

__init__(n_total_clients, n_clients_sampled, noise_multiplier, moment_orders=None)[source]

This accountant should be used when applying FL with Fixed Sampling with No Replacement and measuring client-level privacy

NOTE: The above values can be lists, where they are treated as sequences of training with the respective parameters

Parameters:
  • n_total_clients (int) – total number of clients to be sampled from

  • n_clients_sampled (int | list[int]) – number of clients sampled in a given round

  • noise_multiplier (float | list[float]) – multiplier of noise std. dev. on clipping bound

  • moment_orders (list[float] | None, optional) – Moments orders to be used in computing the approximate epsilon value. Defaults to None. Defaults to None.

get_delta(server_updates, epsilon)[source]

Compute the delta value for the provided epsilon and the number of server updates performed

Parameters:
  • server_updates (int | list[int]) – number of central server updates performed

  • epsilon (float) – Epsilon value from which to compute delta

Returns:

delta

Return type:

float

get_epsilon(server_updates, delta)[source]

Compute the epsilon value for the provided delta and the number of server updates performed

Parameters:
  • server_updates (int | list[int]) – number of central server updates performed

  • delta (float) – Delta value from which to compute epsilon

Returns:

epsilon

Return type:

float

class FlClientLevelAccountantPoissonSampling(client_sampling_rate, noise_multiplier, moment_orders=None)[source]

Bases: ClientLevelAccountant

__init__(client_sampling_rate, noise_multiplier, moment_orders=None)[source]

This accountant should be used when applying FL with Poisson client sampling and measuring client-level privacy

NOTE: The above values can be lists, where they are treated as sequences of training with the respective parameters

Parameters:
  • client_sampling_rate (float | list[float]) – probability that each client will be included in a round

  • noise_multiplier (float | list[float]) – multiplier of noise std. dev. on clipping bound

  • moment_orders (list[float] | None, optional) – Moments orders to be used in computing the approximate epsilon value. Defaults to None. Defaults to None.

get_delta(server_updates, epsilon)[source]

Compute the delta value for the provided epsilon and the number of server updates performed

Parameters:
  • server_updates (int | list[int]) – number of central server updates performed

  • epsilon (float) – Epsilon value from which to compute delta

Returns:

delta

Return type:

float

get_epsilon(server_updates, delta)[source]

Compute the epsilon value for the provided delta and the number of server updates performed

Parameters:
  • server_updates (int | list[int]) – number of central server updates performed

  • delta (float) – Delta value from which to compute epsilon

Returns:

epsilon

Return type:

float

class FlInstanceLevelAccountant(client_sampling_rate, noise_multiplier, epochs_per_round, client_batch_sizes, client_dataset_sizes, moment_orders=None)[source]

Bases: object

__init__(client_sampling_rate, noise_multiplier, epochs_per_round, client_batch_sizes, client_dataset_sizes, moment_orders=None)[source]

This accountant should be used when applying FL and measuring instance-level privacy

NOTE: This class assumes that all sampling is done via Poisson sampling (client and data point level). Further it assumes that the sampling ratio of clients and noise multiplier are fixed throughout training

Parameters:
  • client_sampling_rate (float) – probability that each client will be included in a round

  • noise_multiplier (float) – multiplier of noise std. dev. on clipping bound

  • epochs_per_round (int) – number of epochs each client will complete per server round

  • client_batch_sizes (list[int]) – batch size per client, if a single value it is assumed to be constant across clients

  • client_dataset_sizes (list[int]) – size of full dataset on a client, if a single value it is assumed to be constant across clients.

  • moment_orders (list[float] | None, optional) – Moments orders to be used in computing the approximate epsilon value. Defaults to None.

get_delta(server_updates, epsilon)[source]

Compute the delta value for the provided epsilon and the number of server updates performed

Parameters:
  • server_updates (int) – number of central server updates performed

  • epsilon (float) – Epsilon value from which to compute delta

Returns:

delta

Return type:

float

get_epsilon(server_updates, delta)[source]

Compute the epsilon value for the provided delta and the number of server updates performed

Parameters:
  • server_updates (int) – number of central server updates performed

  • delta (float) – Delta value from which to compute epsilon

Returns:

Epsilon

Return type:

float