flip.nvflare.components.pt_model_persistor
Classes
Persistor that seeds the initial global model from a large backbone checkpoint |
Module Contents
- class flip.nvflare.components.pt_model_persistor.InitialCheckpointPTModelPersistor(model=None, model_id: str = '', **kwargs)
Bases:
nvflare.app_opt.pt.file_model_persistor.PTFileModelPersistorPersistor that seeds the initial global model from a large backbone checkpoint staged server-side, so the checkpoint never has to be bundled into the job app (bundling a ~759 MiB file collapses NVFLARE’s app-deploy to remote clients).
The backbone filename is declared in the job’s
config.jsonunderSERVER_CHECKPOINT. At load time it is resolved in this order:<app>/custom/<checkpoint>— a checkpoint bundled in the app. Used by the local simulator (which copies the file intocustom/) and any legacy bundling.<SERVER_CHECKPOINT_ROOT>/<model_id>/<checkpoint>— the de-bundled checkpoint the FL API staged on the hub-local shared volume (production). Read straight from disk; the checkpoint is intentionally NOT shipped in the app bundle, so it never reaches the clients. Mirrors the Flower backend’s/app/srcshared mount and the evalEvaluationPTModelLocator.
The resolved checkpoint is loaded (
strict=False) into theget_model()architecture so the round-0 global model that ScatterAndGather broadcasts carries the backbone plus freshly-initialised heads — a full state dict the clients can load. Clients therefore build only a bare architecture and receive all weights at round 0; they need no checkpoint file.When
config.jsondeclares noSERVER_CHECKPOINT(every other standard training job), this behaves exactly like the stockPTFileModelPersistor(initial weights from the model object), so it is a safe drop-in for the shared standard base app.- _model_id_arg = ''
- _resolve_backbone(fl_ctx: nvflare.apis.fl_context.FLContext)
Locate the declared backbone checkpoint, or
Noneif none is declared/found.
- load_model(fl_ctx: nvflare.apis.fl_context.FLContext) nvflare.app_common.abstract.model.ModelLearnable