nvflare.app_common.aggregators.dxo_aggregator module

class DXOAggregator(exclude_vars: str | None = None, aggregation_weights: Dict[str, Any] | None = None, expected_data_kind: DataKind = 'WEIGHT_DIFF', name_postfix: str = '', weigh_by_local_iter: bool = True)[source]

Bases: FLComponent

Perform accumulated weighted aggregation for one kind of corresponding DXO from contributors.

  • exclude_vars (str, optional) – Regex to match excluded vars during aggregation. Defaults to None.

  • aggregation_weights (Dict[str, Any], optional) – Aggregation weight for each contributor. Defaults to None.

  • expected_data_kind (DataKind) – Expected DataKind for this DXO.

  • name_postfix – optional postfix to give to class name and show in logger output.

  • weigh_by_local_iter (bool, optional) – Whether to weight the contributions by the number of iterations performed in local training in the current round. Defaults to True. Setting it to False can be useful in applications such as homomorphic encryption to reduce the number of computations on encrypted ciphertext. The aggregated sum will still be divided by the provided weights and aggregation_weights for the resulting weighted sum to be valid.

accept(dxo: DXO, contributor_name, contribution_round, fl_ctx: FLContext) bool[source]

Store DXO and update aggregator’s internal state :param dxo: information from contributor :param contributor_name: name of the contributor :param contribution_round: round of the contribution :param fl_ctx: context provided by workflow


The boolean to indicate if DXO is accepted.

aggregate(fl_ctx: FLContext) DXO[source]

Called when workflow determines to generate DXO to send back to contributors :param fl_ctx: context provided by workflow :type fl_ctx: FLContext


the weighted mean of accepted DXOs from contributors

Return type: