nvflare.edge.assessors.buff_device_manager module¶
- class BuffDeviceManager(device_selection_size: int, min_hole_to_fill: int = 1, device_reuse: bool = True)[source]¶
Bases:
DeviceManagerInitialize the BuffDeviceManager. BuffDeviceManager is responsible for managing the selection of devices for model training. It maintains a list of available devices, tracks the current selection, and refills the selection as needed. The device_selection_size determines how many “concurrent” devices can be selected for the training session. The min_hole_to_fill determines how many empty slots should be created before refilling.
An empty slot is created when any device reports its update back.
To fill a slot, a new device is selected from the available device pool.
The device_reuse flag indicates whether devices can be reused across different model versions, if False, we will always select new devices when filling holes. :param device_selection_size: Number of devices to select for each model update round. :type device_selection_size: int :param min_hole_to_fill: Minimum number of empty slots in device selection before refilling. Defaults to 1 - once received an update, immediately sample a new device and send the current task to it. :type min_hole_to_fill: int :param device_reuse: Whether to allow reusing devices across different model versions. Defaults to True. :type device_reuse: bool
- fill_selection(current_model_version: int, fl_ctx) None[source]¶
Fill the device selection sampled from available devices. update self.current_selection
- Parameters:
current_model_version (int) – Current version of the model
fl_ctx – FLContext object
Returns – none
- get_active_model_versions(fl_ctx) Set[int][source]¶
Get the active model versions that is associated with the current selection.
- Parameters:
fl_ctx – FLContext object
- Returns:
Set of active model versions
- has_enough_devices(fl_ctx) bool[source]¶
Check if there are enough devices available to start task distribution.
- Parameters:
fl_ctx – FLContext object
- Returns:
True if there are enough devices to start task distribution, False otherwise
- Return type:
bool
- remove_devices_from_selection(devices: Set[str], fl_ctx) None[source]¶
Remove devices from the current selection. update self.current_selection
- Parameters:
devices – Set of devices to remove
fl_ctx – FLContext object
Returns – none
- remove_devices_from_used(devices: Set[str], fl_ctx) None[source]¶
Remove devices from the used device set. update self.used_devices
- Parameters:
devices – Set of devices to remove
fl_ctx – FLContext object
Returns – none