I have built my largest program in Concrete and for large parts it works great, but there seem to be some problems I want to debug using Concrete’s simulation feature and especially the overflow detection. Now to my problem:
As part of the program, I compute the following:
b = a % np.array([1, 2, 3]).reshape([-1, 1, 1])
where a is an encrypted 2D matrix.
It works perfectly fine and produces the correct outputs. The values in the inpuset for the compilation are much larger than the input used for the computation. When I run the simulation and values of a are negative, I get the following warning for the above code-line:
WARNING at loc(…): overflow happened during addition in simulation
When I try to model a similar computation as a LookupTable I get the same warning:
table = fhe.LookupTable([i % 3 for i in range(0, 100)] + [i % 3 for i in range(-100, 0)])
.
It seems to me that I always get the warning, when using negative inputs to LookupTables, but the documentation says that should work? My issue is, that I now get many warnings probably not relevant, and I have a hard time finding the real overflows.
Is there something I can do about that, or do I misunderstand something here?
Thank you so much for all the help in the forum!
Minimal example:
from concrete import fhe
import numpy as np
a = -np.random.randint(1, 10, (2, 2))
print(a)
print(a.shape)
table = fhe.LookupTable([i % 3 for i in range(0, 100)] + [i % 3 for i in range(-100, 0)])
def m(a):
b = a % np.array([1, 2, 3]).reshape([-1, 1, 1])
#b = table[a]
return b
print("CLEAR")
b = m(a)
print(b)
print("FHE")
compiler = fhe.Compiler(m, {"a": "encrypted"})
inputset = [
np.random.randint(-100, 100, (2, 2)) for _ in range(100)
]
circuit = compiler.compile(inputset, fhe_simulation=True, detect_overflow_in_simulation=True)
print(circuit)
b = circuit.simulate(a)
print(b)