flip.nvflare.controllers.scatter_and_gather_ldm
Classes
Two-phase (autoencoder → diffusion model) FedAvg controller for latent diffusion. |
Module Contents
- class flip.nvflare.controllers.scatter_and_gather_ldm.ScatterAndGatherLDM(model_id: str = '', min_clients: int = 1, num_rounds_ae: int = 5, num_rounds_dm: int = 5, start_round: int = 0, model_locator_id: str = '', wait_time_after_min_received: int = 10, aggregator_id=AppConstants.DEFAULT_AGGREGATOR_ID, persistor_id=AppConstants.DEFAULT_PERSISTOR_ID, shareable_generator_id=AppConstants.DEFAULT_SHAREABLE_GENERATOR_ID, train_task_name=AppConstants.TASK_TRAIN, train_timeout: int = 0, ignore_result_error: bool = True, fatal_error_delay: int = 5, task_check_period: float = 0.5, persist_every_n_rounds: int = 1, memory_gc_rounds: int = 1)
Bases:
flip.nvflare.controllers.scatter_and_gather.ScatterAndGatherTwo-phase (autoencoder → diffusion model) FedAvg controller for latent diffusion.
Subclasses FLIP’s
ScatterAndGather(itself a thin subclass of stock NVFLARE ScatterAndGather). Each instance runs a single phase — the job wires one controller per phase (train_task_nametrain_aethentrain_dm) and NVFLARE runs them sequentially — so the round loop itself is stock’s, inherited verbatim (with its per-roundaggregator.reset, failed-client tracking,memory_gc_roundsallocator cleanup, and any future upstream fixes), alongside all the shared FLIP hooks (_accept_train_result, the metrics relay,FlipEvents.ABORTED). Only what is genuinely LDM-specific is overridden:__init__()— two per-phase round counts (num_rounds_ae/num_rounds_dm) and a server-sidemodel_locatorfor the phase-1 → phase-2 weight handoff. Delegates the shared FedAvg wiring/validation to the base, passingnum_rounds = ae + dmso the inherited persist/state code sees a valid total before a phase starts.start_controller()— resolves themodel_locatorand applies the appconfig.jsonper-phase round-count overrides, then delegates component validation and initial-model loading to stock.control_flow()— pointsself._num_roundsat this phase’s round count (stock’s loop,NUM_ROUNDSprop/header and last-round persist all key off it); fortrain_dmfirst loads the phase-1 autoencoder weights via the persistor/model-locator; then delegates the round loop to stock.stop_controller()— cancels outstanding tasks (stock only flips the phase).
- _num_rounds_ae = 5
- _num_rounds_dm = 5
- _fatal_error_delay = 5
- model_locator_id = ''
- model_locator = None
- start_controller(fl_ctx: nvflare.apis.fl_context.FLContext) None
- control_flow(abort_signal: nvflare.apis.signal.Signal, fl_ctx: nvflare.apis.fl_context.FLContext) None
- stop_controller(fl_ctx: nvflare.apis.fl_context.FLContext) None