src/pqc_federated_learning/aggregators/base.py
538 B · 20 lines · python Raw
1 """Aggregator strategy interface."""
2
3 from __future__ import annotations
4
5 from abc import ABC, abstractmethod
6
7 from pqc_federated_learning.update import ClientUpdate, GradientTensor
8
9
10 class Aggregator(ABC):
11 name: str = ""
12
13 @abstractmethod
14 def aggregate(self, updates: list[ClientUpdate]) -> list[GradientTensor]:
15 """Produce a single aggregated tensor list from many client updates.
16
17 Implementations MUST raise ShapeMismatchError if tensors across updates
18 have inconsistent shapes or names.
19 """
20