Thanks for your reply!
As you told me, I separated the key generation step before the encryption. The first latency is significantly faster, this is because the key was generated in the first latency, right?
However, since I already discarded the first 20 latencies before computing the mean, it didn’t affect the results.
Actually, I printed the statistics already for some splits of the model, I just didn’t know what to look for. I’ll post one for each case (Conv2d, AvgPool, ReLU outputs), it could be useful to compare them. I tried to format it in a way that is easier to read:
- Conv2d output (client executed all layers except the last 3,
encrypted_MB=0.57 -> t_encrypt= approx. 19 sec
)
{'size_of_secret_keys': 347056, 'size_of_bootstrap_keys': 4668260352, 'size_of_keyswitch_keys': 1039138816,
'p_error': 7.726075413135422e-08, 'global_p_error': 0.002014900278258791, 'complexity': 22134345773056.0,
'size_of_inputs': 602112, 'size_of_outputs': 2621520,
'programmable_bootstrap_count': 27136, 'programmable_bootstrap_count_per_parameter': {
BootstrapKeyParam(polynomial_size=8192, glwe_dimension=1, input_lwe_dimension=903, level=2, base_log=15, variance=4.70197740328915e-38): 25088,
BootstrapKeyParam(polynomial_size=8192, glwe_dimension=1, input_lwe_dimension=593, level=2, base_log=15, variance=4.70197740328915e-38): 1536,
BootstrapKeyParam(polynomial_size=32768, glwe_dimension=1, input_lwe_dimension=926, level=4, base_log=9, variance=4.70197740328915e-38): 512},
'programmable_bootstrap_count_per_tag': {}, 'programmable_bootstrap_count_per_tag_per_parameter': {},
'key_switch_count': 27136, 'key_switch_count_per_parameter': {
KeyswitchKeyParam(level=4, base_log=4, variance=4.372764418454018e-13): 25088,
KeyswitchKeyParam(level=5, base_log=2, variance=2.7338004748751887e-08): 1536,
KeyswitchKeyParam(level=10, base_log=2, variance=1.9271833105393818e-13): 512},
'key_switch_count_per_tag': {}, 'key_switch_count_per_tag_per_parameter': {},
'packing_key_switch_count': 0, 'packing_key_switch_count_per_parameter': {},
'packing_key_switch_count_per_tag': {}, 'packing_key_switch_count_per_tag_per_parameter': {},
'clear_addition_count': 28672, 'clear_addition_count_per_parameter': {
LweSecretKeyParam(dimension=8192): 28672},
'clear_addition_count_per_tag': {}, 'clear_addition_count_per_tag_per_parameter': {},
'encrypted_addition_count': 12851712, 'encrypted_addition_count_per_parameter': {
LweSecretKeyParam(dimension=8192): 12846592,
LweSecretKeyParam(dimension=32768): 5120},
'encrypted_addition_count_per_tag': {}, 'encrypted_addition_count_per_tag_per_parameter': {},
'clear_multiplication_count': 12851712, 'clear_multiplication_count_per_parameter': {
LweSecretKeyParam(dimension=8192): 12846592,
LweSecretKeyParam(dimension=32768): 5120},
'clear_multiplication_count_per_tag': {}, 'clear_multiplication_count_per_tag_per_parameter': {},
'encrypted_negation_count': 1536, 'encrypted_negation_count_per_parameter': {
LweSecretKeyParam(dimension=8192): 1536},
'encrypted_negation_count_per_tag': {}, 'encrypted_negation_count_per_tag_per_parameter': {}}
- AvgPool output (client executed all layers except the last 6,
encrypted_MB=0.57 -> t_encrypt= approx. 5 sec
)
{'size_of_secret_keys': 294552, 'size_of_bootstrap_keys': 20278640640, 'size_of_keyswitch_keys': 1730142208,
'p_error': 9.473756358082791e-08, 'global_p_error': 0.006167934496865424, 'complexity': 1210812549475840.0,
'size_of_inputs': 602112, 'size_of_outputs': 2621520,
'programmable_bootstrap_count': 453632, 'programmable_bootstrap_count_per_parameter': {
BootstrapKeyParam(polynomial_size=512, glwe_dimension=5, input_lwe_dimension=611, level=2, base_log=16, variance=4.70197740328915e-38): 402944,
BootstrapKeyParam(polynomial_size=32768, glwe_dimension=1, input_lwe_dimension=880, level=21, base_log=2, variance=4.70197740328915e-38): 50688},
'programmable_bootstrap_count_per_tag': {}, 'programmable_bootstrap_count_per_tag_per_parameter': {},
'key_switch_count': 503808, 'key_switch_count_per_parameter': {
KeyswitchKeyParam(level=5, base_log=2, variance=1.4397555853147048e-08): 402944,
KeyswitchKeyParam(level=18, base_log=1, variance=9.921769535221788e-13): 50688,
KeyswitchKeyParam(level=2, base_log=21, variance=4.70197740328915e-38): 50176},
'key_switch_count_per_tag': {}, 'key_switch_count_per_tag_per_parameter': {},
'packing_key_switch_count': 0, 'packing_key_switch_count_per_parameter': {},
'packing_key_switch_count_per_tag': {}, 'packing_key_switch_count_per_tag_per_parameter': {},
'clear_addition_count': 906752, 'clear_addition_count_per_parameter': {
LweSecretKeyParam(dimension=2560): 906752},
'clear_addition_count_per_tag': {}, 'clear_addition_count_per_tag_per_parameter': {},
'encrypted_addition_count': 244464128, 'encrypted_addition_count_per_parameter': {
LweSecretKeyParam(dimension=2560): 244459008,
LweSecretKeyParam(dimension=32768): 5120},
'encrypted_addition_count_per_tag': {}, 'encrypted_addition_count_per_tag_per_parameter': {},
'clear_multiplication_count': 244464128, 'clear_multiplication_count_per_parameter': {
LweSecretKeyParam(dimension=2560): 244459008,
LweSecretKeyParam(dimension=32768): 5120},
'clear_multiplication_count_per_tag': {}, 'clear_multiplication_count_per_tag_per_parameter': {},
'encrypted_negation_count': 402944, 'encrypted_negation_count_per_parameter': {
LweSecretKeyParam(dimension=2560): 402944},
'encrypted_negation_count_per_tag': {}, 'encrypted_negation_count_per_tag_per_parameter': {}}
- ReLU output (client executed all layers except the last 12,
encrypted_MB=1.32 -> t_encrypt= approx. 73 sec
)
{'size_of_secret_keys': 470032, 'size_of_bootstrap_keys': 15955197952, 'size_of_keyswitch_keys': 4467261440,
'p_error': 8.338687633247801e-08, 'global_p_error': 0.014227299033742025, 'complexity': 1609237816835584.0,
'size_of_inputs': 1382400, 'size_of_outputs': 2621520,
'programmable_bootstrap_count': 892672, 'programmable_bootstrap_count_per_parameter': {
BootstrapKeyParam(polynomial_size=16384, glwe_dimension=1, input_lwe_dimension=906, level=6, base_log=6, variance=4.70197740328915e-38): 12544,
BootstrapKeyParam(polynomial_size=512, glwe_dimension=4, input_lwe_dimension=638, level=2, base_log=16, variance=8.442253112932959e-31): 754176,
BootstrapKeyParam(polynomial_size=32768, glwe_dimension=1, input_lwe_dimension=873, level=13, base_log=3, variance=4.70197740328915e-38): 100864,
BootstrapKeyParam(polynomial_size=4096, glwe_dimension=1, input_lwe_dimension=1041, level=5, base_log=8, variance=4.70197740328915e-38): 25088},
'programmable_bootstrap_count_per_tag': {}, 'programmable_bootstrap_count_per_tag_per_parameter': {},
'key_switch_count': 1005568, 'key_switch_count_per_parameter': {
KeyswitchKeyParam(level=9, base_log=2, variance=3.9295523001771657e-13): 12544,
KeyswitchKeyParam(level=3, base_log=12, variance=8.442253112932959e-31): 87808,
KeyswitchKeyParam(level=4, base_log=3, variance=5.502647693575897e-09): 754176,
KeyswitchKeyParam(level=18, base_log=1, variance=1.273169281266184e-12): 100864,
KeyswitchKeyParam(level=2, base_log=8, variance=3.204481389236339e-15): 25088,
KeyswitchKeyParam(level=2, base_log=17, variance=8.442253112932959e-31): 25088},
'key_switch_count_per_tag': {}, 'key_switch_count_per_tag_per_parameter': {},
'packing_key_switch_count': 0, 'packing_key_switch_count_per_parameter': {},
'packing_key_switch_count_per_tag': {}, 'packing_key_switch_count_per_tag_per_parameter': {},
'clear_addition_count': 1709568, 'clear_addition_count_per_parameter': {
LweSecretKeyParam(dimension=2048): 1709568},
'clear_addition_count_per_tag': {}, 'clear_addition_count_per_tag_per_parameter': {},
'encrypted_addition_count': 443913728, 'encrypted_addition_count_per_parameter': {
LweSecretKeyParam(dimension=16384): 12845056,
LweSecretKeyParam(dimension=2048): 418218496,
LweSecretKeyParam(dimension=32768): 12850176},
'encrypted_addition_count_per_tag': {}, 'encrypted_addition_count_per_tag_per_parameter': {},
'clear_multiplication_count': 443913728, 'clear_multiplication_count_per_parameter': {
LweSecretKeyParam(dimension=16384): 12845056,
LweSecretKeyParam(dimension=2048): 418218496,
LweSecretKeyParam(dimension=32768): 12850176},
'clear_multiplication_count_per_tag': {}, 'clear_multiplication_count_per_tag_per_parameter': {},
'encrypted_negation_count': 754176, 'encrypted_negation_count_per_parameter': {
LweSecretKeyParam(dimension=2048): 754176},
'encrypted_negation_count_per_tag': {}, 'encrypted_negation_count_per_tag_per_parameter': {}}
- ReLU output (client executed all layers except the last 14,
encrypted_MB=1.32 -> t_encrypt= approx. 9 sec
)
{'size_of_secret_keys': 469976, 'size_of_bootstrap_keys': 15995994112, 'size_of_keyswitch_keys': 5835653120,
'p_error': 9.837142123243636e-08, 'global_p_error': 0.020710787219196534, 'complexity': 2469920417048576.0,
'size_of_inputs': 1382400, 'size_of_outputs': 2621520,
'programmable_bootstrap_count': 1328384, 'programmable_bootstrap_count_per_parameter': {
BootstrapKeyParam(polynomial_size=512, glwe_dimension=4, input_lwe_dimension=611, level=2, base_log=16, variance=8.442253112932959e-31): 1132288,
BootstrapKeyParam(polynomial_size=32768, glwe_dimension=1, input_lwe_dimension=873, level=13, base_log=3, variance=4.70197740328915e-38): 158464,
BootstrapKeyParam(polynomial_size=16384, glwe_dimension=1, input_lwe_dimension=926, level=6, base_log=6, variance=4.70197740328915e-38): 12544,
BootstrapKeyParam(polynomial_size=4096, glwe_dimension=1, input_lwe_dimension=1041, level=5, base_log=8, variance=4.70197740328915e-38): 25088},
'programmable_bootstrap_count_per_tag': {}, 'programmable_bootstrap_count_per_tag_per_parameter': {},
'key_switch_count': 1441280, 'key_switch_count_per_parameter': {
KeyswitchKeyParam(level=5, base_log=2, variance=1.4397555853147048e-08): 1132288,
KeyswitchKeyParam(level=18, base_log=1, variance=1.273169281266184e-12): 158464,
KeyswitchKeyParam(level=10, base_log=2, variance=1.9271833105393818e-13): 12544,
KeyswitchKeyParam(level=3, base_log=12, variance=8.442253112932959e-31): 87808,
KeyswitchKeyParam(level=2, base_log=8, variance=3.204481389236339e-15): 25088,
KeyswitchKeyParam(level=2, base_log=17, variance=8.442253112932959e-31): 25088},
'key_switch_count_per_tag': {}, 'key_switch_count_per_tag_per_parameter': {},
'packing_key_switch_count': 0, 'packing_key_switch_count_per_parameter': {},
'packing_key_switch_count_per_tag': {}, 'packing_key_switch_count_per_tag_per_parameter': {},
'clear_addition_count': 2580992, 'clear_addition_count_per_parameter': {
LweSecretKeyParam(dimension=2048): 2580992},
'clear_addition_count_per_tag': {}, 'clear_addition_count_per_tag_per_parameter': {},
'encrypted_addition_count': 577002240, 'encrypted_addition_count_per_parameter': {
LweSecretKeyParam(dimension=2048): 551307008,
LweSecretKeyParam(dimension=32768): 25695232},
'encrypted_addition_count_per_tag': {}, 'encrypted_addition_count_per_tag_per_parameter': {},
'clear_multiplication_count': 577002240, 'clear_multiplication_count_per_parameter': {
LweSecretKeyParam(dimension=2048): 551307008,
LweSecretKeyParam(dimension=32768): 25695232},
'clear_multiplication_count_per_tag': {}, 'clear_multiplication_count_per_tag_per_parameter': {},
'encrypted_negation_count': 1132288, 'encrypted_negation_count_per_parameter': {
LweSecretKeyParam(dimension=2048): 1132288},
'encrypted_negation_count_per_tag': {}, 'encrypted_negation_count_per_tag_per_parameter': {}}
What should we be looking at in the statistics?