Choosing the best "base_log" and "level" parameters in KeySwitch

Hello there,

I am quite interested in Key Switching feature. In order to maintain the best ratio between computational cost and accuracy in the result, I was wondering what criteria to follow when choosing the “base_log” and “level” parameters of the Key Switch method. I am trying some “random” combinations, but I always lose some bits of precision. I guess this is due to the precision-bits chosen in the encoder.
Following the recommendations of the documentation, it is advisable to keep the “level” parameter low.

Hope someone can help me. Thank you for your help and time.

Hello @ares,

Your question is a tricky one. Intuitive answer is that one should try to have the minimal
required precision during decomposition, as having a greater level will increase precision but also the cost at the same time.

A general rule of thumb is to let noise guide your choice: if as instance your noise is starting after the 25th bit, then the product base_log * level should be around 25.

Please note that, the crypto API is going to be rebuilt from scratch to better handle precision.

To help you on this topic (but beware that it is a very complex one) you could try to use
noise formula given in our papers (https://eprint.iacr.org/2021/729.pdf as instance). And for your information, it is one of the reason that motivate us to work on a compiler to hide this complexity from a user.