nvflare.edge.assessors.buff_model_manager module
- class BuffModelManager(num_updates_for_model: int, max_model_history: int | None = None, global_lr: float = 1.0, staleness_weight: bool = False)[source]
Bases:
ModelManagerInitialize the ModelManager. The aggregation scheme and weights are calculated following FedBuff paper “Federated Learning with Buffered Asynchronous Aggregation”. The staleness_weight can be enabled to apply staleness weighting to model updates.
Special cases for max_model_history: - If None: Keep every model versions, only remove a version when all devices processing it reports back (version no longer related with any device_id in the current_selection from device_manager).
- Parameters:
num_updates_for_model (int) – Number of updates required before generating a new model version.
max_model_history (int) – Maximum number of historical model versions to keep in memory. - None (default): keep every version until all devices processing a particular version report back. - positive integer: keep only the latest n versions
global_lr (float) – Global learning rate for model aggregation, default is 1.0.
staleness_weight (bool) – Whether to apply staleness weighting to model updates, default is False.
- generate_new_model(fl_ctx: FLContext) None[source]
Generate a new model version based on accumulated updates.
- Parameters:
fl_ctx – FLContext object
Returns – none
- initialize_model(model: DXO, fl_ctx: FLContext)[source]
Initialize the model manager with an initial model.
- Parameters:
model – The initial model
fl_ctx – FLContext object
Returns – none
- process_updates(model_updates: Dict[int, ModelUpdate], fl_ctx: FLContext) bool[source]
Process incoming model updates from clients.
- Parameters:
model_updates – updates collected from clients
fl_ctx – FLContext object
- Returns:
Whether the updates were successfully processed
- Return type:
bool