Medoid#
Medoid aggregation rule, vector-level medoid.
- Reference:
Cong Xie, Oluwasanmi Koyejo, and Indranil Gupta. “Generalized Byzantine-tolerant SGD.” arXiv preprint arXiv:1802.10116 (2018).
- class krum.primitives.aggregators.medoid.Medoid[source]#
Bases:
AggregatorMedoid aggregation rule, vector-level medoid.
The medoid is the submitted gradient \(V_i\) that minimises \(\sum_j \|V_i - V_j\|\). Ties are broken by the smallest index. This is a vector-level operator (one of the submitted vectors is selected as-is) — distinct from the coordinate-wise median, which computes a median per coordinate, and from the true geometric median (
GeometricMedian), which is the unconstrained minimiser in \(\mathbb{R}^d\). The medoid carries no \((\alpha, f)\)-Byzantine-resilience guarantee; it is kept here as a literature baseline.- classmethod aggregate(gradients: Sequence[Tensor] | Tensor, /, out: Tensor | None = None, *, n: int, f: int, **specialized: Any) Tensor[source]#
Aggregate gradients by selecting the medoid.
- Parameters:
gradients – Sequence of 1-D tensors containing gradients from workers.
out – Optional pre-allocated tensor to write the result into.
n – Total number of workers.
f – Number of Byzantine workers to tolerate. \(f\) is accepted for API uniformity with other aggregators but is not consulted here (the medoid is defined for any \(n \ge 1\)).
**specialized – Additional keyword arguments.
- Returns:
Selected worker gradient of shape `` (d,)
- Raises:
ValueError – If \(n\), \(f\), or the gradients count is invalid.
See also
For the unconstrained geometric median, see GeometricMedian. For distance-based single-vector selection, see Krum. For the most-clumped subset, see Brute.