nvflare.app_common.aggregators.weighted_aggregation_helper module
- class WeightedAggregationHelper(exclude_vars: str | None = None, weigh_by_local_iter: bool = True)[source]
Bases:
objectPerform weighted aggregation.
- Parameters:
exclude_vars (str, optional) – regex string to match excluded vars during aggregation. Defaults to None.
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.
- filter_aggregatable_metrics(metrics: Dict[str, Any] | None, warn_skipped: Callable[[str, str], None] | None = None, warned_metric_keys: Set[str] | None = None) Dict[str, Any][source]
Return metric entries that support weighted aggregation.
Note
Boolean metric values are included and aggregate as binary rates.
- Parameters:
metrics – Dict of metric name -> value.
warn_skipped – Optional callback invoked as warn_skipped(key, type_name) for skipped metrics.
warned_metric_keys – Optional set of keys already warned about. If provided, warnings are emitted at most once per key and newly warned keys are added to this set.