awslabs/homomorphic-implementors-toolkit

Give options for simpler evaluation API

Opened this issue · 0 comments

Currently, operations require inputs to be at specific levels, and outputs must sometimes be relinearized and or rescaled depending on the operation. Keeping track of all this is difficult, and it results in messy circuit implementations. It would be pretty easy to fix this situation for the LinearAlgebra API: we could add two boolean flags to the class constructor auto_level and auto_maintenance. The first flag would allow you to pass in CTs of arbitrary levels to all API functions, and the API would reduce the inputs to the appropriate level prior to doing the operation. The second flag would automatically apply relinearization and rescaling if needed. It's less clear how we could achieve the same features in the base evaluator class in a clean way.

It's worth keeping these as options rather than always automatically handling these two tasks: for HE levels, managing it yourself forces you to understand what's happening in the circuit. I've found several bugs by being forced to manage this myself. For maintenance operations, it's not always optimal from a performance or noise perspective to automatically apply these operations. Even though it can be a pain to track what needs to be done, it can increase performance or reduce noise to do it manually.