EDIT: This post has been updated after more debugging. See the end for more details.
Hi,
I have been developing a machine learning model with OpenFHE’s CKKSRNS implementation, but there’s a strange bug I am encountering in my code: There is one operation (a matrix multiplication I implemented) where the decrypted output doesn’t match the expected output (even though the decrypted inputs are correct). The numbers (which are all between -2 and 2) are off by significant enough margin that something is clearly wrong. Strangely, if I decrypt and then encrypt those exact same values which include errors from previous operations, the output matches with the expected output. I understand that as operations accumulate, the errors should slowly increase, and that’s what I have observed with other linear and non linear operations, but not the order of magnitude of error increase in one step that I am observing. I’ve isolated it to only change on whether to decrypt and decode the plaintext, followed by encode and encrypt the same data, and it somehow works when I choose to do so.
I’ve tried everything I know of to fix this bug - increasing parameters such as the multiplicative depth, Scaling Modulus Size, Bootstrapping, Ring Dimension, even native integer size, but all give me the same significant, consistent increase in error that I don’t see elsewhere. Does anyone have any ideas where I might be going wrong? I think it may be my code somewhere that is wrong - and I’m blind to it, but I’m just wondering if someone knows something I don’t about this.
EDIT after more debugging: The bug has nothing to do with OpenFHE or CKKS, but my code. Thanks again for the help.