MP-SPDZ
MP-SPDZ copied to clipboard
Online Batch Inference of HiNet
I want to perform a benchmark of two party batch inference (not training) of HiNet (based on this code). I want to run it using SPDZ2k. I wanted to make sure if I am using the right code and steps to get the numbers.
This is the code I am using:
program.options_from_args()
program.use_edabit(True)
program.use_trunc_pr = False
sfix.set_precision(16, 31)
from Compiler import ml
tf = ml
tf.set_n_threads(4)
bs = 100
test_samples = MultiArray([bs, 32, 32, 3], sfix)
layers = [
tf.keras.layers.Conv2D(64, 5, 1, 1),
tf.keras.layers.MaxPooling2D(3, 2, 0),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Conv2D(64, 5, 1, 1),
tf.keras.layers.MaxPooling2D(3, 2, 0),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Conv2D(64, 5, 1, 1),
tf.keras.layers.MaxPooling2D(3, 2, 0),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(10)
]
model = tf.keras.models.Sequential(layers)
model.build(test_samples.sizes, bs)
start = 0
for var in model.trainable_variables:
var.assign_all(0)
opt = model.opt
opt.time_layers = True
start_timer(5)
opt.forward(bs)
stop_timer(5)
I compile it using:
python3 compile.py -R 64
And run it using:
./spdz2k-party.x -N 2 --verbose -h 172.31.42.195 -F hinet -p 0
Also, I have commented out this line as I don't need to calculate softmax. The MP-SPDZ code was compiled with -DINSECURE flag.
Would you be able to verify if this this the most optimal way to run this task?
Thanks