Homomorphic Encryption #234
-
Hi all, I am trying to add Homomorphic Encryption to my FL pipeline, but I keep getting errors that there is no tenseal context. My implementation is based on the HE part of the cifar example. Does anyone know what I am missing? Here is the whole error on the client side:
My server train configuration looks like this:
and my client config looks like this:
|
Beta Was this translation helpful? Give feedback.
Replies: 15 comments 10 replies
-
From the error message in the log LoadResult.NO_SUCH_CONTENT, I am guessing your system did not have tenseal context file. Please check if you have server_context.tenseal in the server's startup folder and client_context.tenseal in all clients' startup folder. |
Beta Was this translation helpful? Give feedback.
-
Please follow the instructions for creating "secure" workspace using the provisioning tools. You can also refer to the example here. |
Beta Was this translation helpful? Give feedback.
-
I think the model is not being built when using "name" in the model persistor config. You should be using path as shown here. |
Beta Was this translation helpful? Give feedback.
-
Great, thanks for the explanations @holgerroth It seems like the encryption on the client-side works:
On the server side I am getting the following error. It seems like all shareables are skipped, since only WEIGHT_DIFF type DXO's are supported and this is why the final layers in the end are empty. I've remove the argument of expected_data_kind within the aggregator of my server, but it did not change anything.
|
Beta Was this translation helpful? Give feedback.
-
Ah. Thank you for reporting this issue. The current HE aggregator expects the dxo to contain weight differences. But that should be not required. You can make a custom copy of the HE aggregator and replace this block with
Your custom aggregator can be used using "path" instead of "name" in your config. You can either provide inside the custom folder of your app or put it in your PYTHONPATH. I will create an issue and we will fix it in the repo soon. |
Beta Was this translation helpful? Give feedback.
-
FYI, the fixing PR is here #292 |
Beta Was this translation helpful? Give feedback.
-
Great, thank you! After adding this, the encryption seems to work, but another error occurs within the model persistor:
|
Beta Was this translation helpful? Give feedback.
-
Hi @LSnyd, I cannot reproduce this error with the cifar10 example and nvflare 2.0.14. I'm using the virtual environment setup described here. It looks like there could be some version conflict in your miniconda environment. @IsaacYangSLA might have more suggestions. |
Beta Was this translation helpful? Give feedback.
-
My environment looks like this Have you tried running the HE experiment in the cifar10 example? Do you get the same error? |
Beta Was this translation helpful? Give feedback.
-
My environment looks the same. I can't get the HE experiment in the cifar10 example running. I followed the description and did not alter any config files. It doesn't give me the same error as before. It seems like the encryption works and the clients are able to send their encrypted weights to the server, but the server doesn't move forward. The error "no task currently for client" repeats at this stage over and over und I stop the process. Server log:
|
Beta Was this translation helpful? Give feedback.
-
The configured number is 8, so you must have at least 8 sites. Otherwise the server will wait for that many updates forever (since the train_timeout of ScatterAndGather is set to 0 in the config). |
Beta Was this translation helpful? Give feedback.
-
Hi @holgerroth, |
Beta Was this translation helpful? Give feedback.
-
I see. Let me try the MONAI Trainer with HE on my side to see if I can reproduce the issue. |
Beta Was this translation helpful? Give feedback.
-
I was able to reproduce the model saving issue in 2.0.6. Opened an issue #323 |
Beta Was this translation helpful? Give feedback.
-
I provided a fix #326 You can use this version of HEModelShareableGenerator (import using "path") for a temporary to work with full WEIGHTS. |
Beta Was this translation helpful? Give feedback.
The configured number is 8, so you must have at least 8 sites. Otherwise the server will wait for that many updates forever (since the train_timeout of ScatterAndGather is set to 0 in the config).