facebookresearch/FLSim

How to use the framework with local Differential Privacy

fraboeni opened this issue · 2 comments

How can I use the LDP implementation of the framework?

Thank you very much for the great library. I was trying to use the LDP implementation inside my code. However, I cannot figure out how to really integrate the DP parts into the workflow.

Would it be possible to provide a minimal example that I can use as a starting point to understand how I can pass the parameters to the clients, how I can change the clients to use the DP Optimizer etc.

Thank you very much for your help!

Hi you can do do local DP by using DPClient and pass in the base_dp_client to the config

{
  "config": {
    "trainer": {
      "_base_": "base_sync_trainer",
      "epochs": 1,
      "server": {
        "_base_": "base_sync_server",
        "server_optimizer": {
          "_base_": "base_fed_avg_with_lr",
          "lr": 2.13,
          "momentum": 0.9
        },
        "active_user_selector": {
          "_base_": "base_uniformly_random_active_user_selector"
        }
      },
      "client": {
        "_base_": "base_dp_client",
        "epochs": 1,
        "optimizer": {
          "_base_": "base_optimizer_sgd",
          "lr": 0.0138,
          "momentum": 0
        },
        "privacy_setting": {
             "noise_multiplier": 1,
             "clipping": {
                "clipping_value": 1
             }
         }
      },
      "users_per_round": 10,
      "train_metrics_reported_per_epoch": 1,
      "always_keep_trained_model": false,
      "report_train_metrics": true,
      "eval_epoch_frequency": 1,
      "do_eval": true,
      "report_train_metrics_after_aggregation": true
    },
    "data": {
      "local_batch_size": 32,
      "examples_per_user": 500
    }
  }
}

Thank you very much @JohnlNguyen!