data61 / MP-SPDZ

Versatile framework for multi-party computation
Other
943 stars 280 forks source link

Federated Learning with Secure Aggregation using MPC #614

Closed jaredweinfurtner closed 2 years ago

jaredweinfurtner commented 2 years ago

Hello, I wanted to provide a demonstration of federated learning using MPC to perform the secure aggregation. I started with this blog entry of demonstrating federated learning of the MNIST handwritten digit dataset using the corresponding repo.

In that codebase contains a function that performs the aggregation:

import tensorflow as tf
...
def sum_scaled_weights(scaled_weight_list):
    '''Return the sum of the listed scaled weights. The is equivalent to scaled avg of the weights'''
    avg_grad = list()
    #get the average grad accross all client gradients
    for grad_list_tuple in zip(*scaled_weight_list):
        layer_mean = tf.math.reduce_sum(grad_list_tuple, axis=0)
        avg_grad.append(layer_mean)

    return avg_grad

That is what I wanted to execute in an mpc program, but not sure where to start. The scaled_weight_list is a large numpy.ndarray of floating point numbers. Should I convert those to integer by multiplying by a fixed 1n? Does the reduce_sum function work on secret shares?

Thanks in advance for any guidance you provide.

mkskeller commented 2 years ago

I don't think TensorFlow and MP-SPDZ mix that easily. MP-SPDZ is more designed for continuous secure computation rather than than this use case where secure aggregation is interleaved with local training. The following page has an overview of how to get information in and out of MP-SPDZ secure computation: https://mp-spdz.readthedocs.io/en/latest/io.html