Adjusting Parameters for "Approximation Error Too High" Error

I’m doing some more complex FHE calculations with CKKS, and I sometimes get this error:

openfhe-development-1.2.3/src/pke/lib/encoding/ckkspackedencoding.cpp:l.541:Decode(): The decryption failed because the approximation error is too high. Check the parameters. 

My question is, what parameters can I change to make this error go away?

For example, if I have

    int ring_dim = 1 << 16;
    int num_slots = ring_dim / 2;

    // Set up encryption parameters for CKKS
    CCParams<CryptoContextCKKSRNS> parameters;
    parameters.SetSecurityLevel(HEStd_NotSet);
    parameters.SetMultiplicativeDepth(20);
    parameters.SetScalingModSize(40);
    parameters.SetRingDim(ring_dim);
    parameters.SetBatchSize(num_slots);

what else could I try increasing (and how)? I’ve also dabbled with modifying the scale parameter, but that hasn’t worked for me either.

Increase the firstModSize to the max (set it to 60).
Use FLEXIBLEAUTOEXT ScalingTechnique.
Increase a bit the multiplicative depth (keep adding 1).

Make sure your computation does not grow too large or vanishes too small.

Note that, you can always decrypt and check before any homomorphic computation to see where the code fails.

1 Like

Thank you for the response. Will do.