securefederatedai / openfl

An open framework for Federated Learning.
https://openfl.readthedocs.io/en/latest/index.html
Apache License 2.0
710 stars 189 forks source link

(Experimental Workflow Interface) Aggregator private attributes visible to Collaborators #1052

Open refai06 opened 3 days ago

refai06 commented 3 days ago

Describe the bug In the Experimental aggregator-based workflow, private attributes of the aggregator object are passed to the collaborator step. This behavior does not occur in LocalRuntime.

To Reproduce Steps to reproduce the behavior in the experimental setup:

  1. Create and set up the workspace with 301_torch_cnn_mnist_watermarking Path: openfl/openfl-workspace/experimental/301_torch_cnn_mnist_watermarking
  2. Modify the flow step: aggregated_model_validation as follows:
    @collaborator
    def aggregated_model_validation(self):
        """
        Perform Aggregated Model validation on Collaborators.
        """
        print(‘***************** Debug ****************’)
        print vars(self)
        print(‘***************** Debug ****************’)
        self.agg_validation_score = inference(self.model, self.test_loader)
        print(f"<Collab: {self.input}>"
              + f" Aggregated Model validation score = {self.agg_validation_score}"
              )

        self.next(self.train)
  1. Run Aggregator and Collaborator
  2. Observe that self of the collaborator contains the aggregator’s private attributes (as shown below):

Logs

{

.
.
.
.
.
aggregator_private_attribute:
'pretrain_epochs': 25,
'retrain_epochs': 25,
'watermark_acc_threshold': 0.98,
'watermark_data_loader': <torch.utils.data.dataloader.DataLoader object at 0x7ff088619610>,
'watermark_pretraining_completed': True
.
.
.
.

}

Expected behavior The aggregator’s private attributes should not be visible in the collaborator step.

MasterSkepticista commented 1 day ago

Is this solvable using the exclude keyword argument in a flow step?