Cheb_analysis not working

Hello,
I am trying to run the cheb_analsysis but I cannot due to “Moduli size is not sufficient! Must be increased.” . When I increase, I get “FirstPrime math exception”. I am using NATIVEINT 68 and multiplicative depth 10. scalingModSize was set to 59 (I think this is what was supposed to be changed ). Could you suggest a ScalingModSize that works?

Thank you

Could you include the full code sample? I am not sure what NATIVESIZE 68 means. Typically we have 32, 64, and 128.

Sorry for the mistake, I confused myself with 64 and 128 and ended up mixing both when writing, I actually used 64

Could you include the code used to generated the crypto context? What parameters are you passing? It sounds like the scalingModSize or firstModSize is set to something small. Should be easy to detect when you include the code.

Hello, here is the code snippet of the variables:

double LOWER_BOUND = -16;
double UPPER_BOUND = -LOWER_BOUND;
long double STEP = 0.001;
uint32_t POLY_DEGREE = 59;

int main() {
uint32_t multDepth = 10;

uint32_t ringDimension = 1 << 18;
parameters.SetSecurityLevel(lbcrypto::HEStd_NotSet);
parameters.SetRingDim(ringDimension);
std::cout << "Batch size: " << ringDimension / 2 << std::endl;
parameters.SetBatchSize(ringDimension / 2);
#if NATIVEINT == 128
usint scalingModSize = 85;
usint firstModSize = 89;
#else
usint scalingModSize = 59;
usint firstModSize = 60;
#endif
parameters.SetScalingModSize(scalingModSize);
parameters.SetFirstModSize(firstModSize);
parameters.SetMultiplicativeDepth(multDepth);
lbcrypto::CryptoContextlbcrypto::DCRTPoly cc = GenCryptoContext(parameters);
cc->Enable(PKE);
cc->Enable(KEYSWITCH);
cc->Enable(LEVELEDSHE);
// We need to enable Advanced SHE to use the Chebyshev approximation.
cc->Enable(ADVANCEDSHE);

Thanks. I was able to recreate the problem. The ring dimension is very large (256K; we typically do not use values larger than 128K), and this causes an issue when using the FLEXIBLEAUTOEXT scaling technique (it cannot find a small modulus). I’ve created an issue for it: FLEXIBLEAUTOEXT does not work for the ring dimension of 256K and higher · Issue #595 · openfheorg/openfhe-development · GitHub

In the meantime, you can fix your code by adding the following line to the code (before calling GenCryptoContext):

parameters.SetScalingTechnique(FLEXIBLEAUTO);
1 Like

Thank you very much, it worked