nvflare.app_opt.pt.recipes.cyclic module
- class CyclicRecipe(*, name: str = 'cyclic', model: Any | dict[str, Any] | None = None, initial_ckpt: str | None = None, num_rounds: int = 2, min_clients: int = 2, train_script: str, train_args: str = '', launch_external_process: bool = False, command: str = 'python3 -u', framework: FrameworkType = FrameworkType.PYTORCH, server_expected_format: ExchangeFormat = ExchangeFormat.NUMPY, params_transfer_type: TransferType = TransferType.FULL, server_memory_gc_rounds: int = 1, client_memory_gc_rounds: int = 0, cuda_empty_cache: bool = False)[source]
Bases:
CyclicRecipePyTorch-specific Cyclic federated learning recipe.
- Parameters:
name – Name identifier for the federated learning job. Defaults to “cyclic”.
model – Starting model object to begin training. Can be: - nn.Module instance - Dict config: {“path”: “module.ClassName”, “args”: {“param”: value}} - PTModel instance (already wrapped) - None: no initial model
initial_ckpt – Path to a pre-trained checkpoint file. Can be: - Relative path: file will be bundled into the job’s custom/ directory. - Absolute path: treated as a server-side path, used as-is at runtime. Note: PyTorch requires model when using initial_ckpt (for architecture).
num_rounds – Number of complete training rounds to execute. Defaults to 2.
min_clients – Minimum number of clients required to participate. Must be >= 2.
train_script – Path to the client training script to execute.
train_args – Additional command-line arguments to pass to the training script.
launch_external_process – Whether to run training in a separate process. Defaults to False.
command – Shell command to execute the training script. Defaults to “python3 -u”.
framework – ML framework type for compatibility. Defaults to FrameworkType.PYTORCH.
server_expected_format – Data exchange format between server and clients.
params_transfer_type – Method for transferring model parameters.
server_memory_gc_rounds – Run memory cleanup every N rounds on server. Defaults to 1.
This is base class of a recipe. Recipes are implemented by jobs. A concrete recipe must provide the job for recipe implementation.
- Parameters:
job – the job that implements the recipe.