nvflare.job_config.base_fed_job module

class BaseFedJob(name: str = 'fed_job', min_clients: int = 1, mandatory_clients: List[str] | None = None, key_metric: str = 'accuracy', validation_json_generator: ValidationJsonGenerator | None = None, model_selector: FLComponent | None = None, convert_to_fed_event: ConvertToFedEvent | None = None, analytics_receiver: AnalyticsReceiver | None = None)[source]

Bases: FedJob

Unified BaseFedJob that supports PyTorch, TensorFlow, and Scikit-learn frameworks.

This class consolidates the previously separate PT and TF BaseFedJob implementations into a single unified interface that can handle all frameworks.

Note: This class is framework-agnostic and does not contain framework-specific logic. Framework-specific model setup should be handled by child classes (e.g., PT/TF wrappers) or by the calling code (e.g., recipes).

Unified BaseFedJob for PyTorch, TensorFlow, and Scikit-learn.

Configures ValidationJsonGenerator, model selector, AnalyticsReceiver, ConvertToFedEvent. Framework-specific model setup should be handled by child classes or calling code (recipes).

User must add controllers and executors.

Parameters:
  • name – Name of the job. Defaults to “fed_job”.

  • min_clients – The minimum number of clients for the job. Defaults to 1.

  • mandatory_clients – Mandatory clients to run the job. Default None.

  • key_metric – Metric used to determine if the model is globally best. If metrics are a dict, key_metric can select the metric used for global model selection. Defaults to “accuracy”. Only used if model_selector is not provided.

  • validation_json_generator – A component for generating validation results. If not provided, a ValidationJsonGenerator will be configured.

  • model_selector

    A component for selecting the best model during training. This event-driven component evaluates and tracks model performance across training rounds, determining which model is globally best based on validation metrics. It handles workflow events such as BEFORE_AGGREGATION and BEFORE_CONTRIBUTION_ACCEPT. Common implementations:

    • IntimeModelSelector: selects based on a specified key metric

    • SimpleIntimeModelSelector: simplified version for basic selection

    If not provided and key_metric is specified, an IntimeModelSelector will be configured automatically.

  • convert_to_fed_event – A component to convert certain events to fed events. If not provided, a ConvertToFedEvent object will be created.

  • analytics_receiver – Receive analytics. If not provided, framework-specific child classes may provide defaults (e.g., TBAnalyticsReceiver for PT/TF).

set_up_client(target: str)[source]

Setup client components.