Hello,
I am trying to benchmark the NTT implementation of OpenFHE in the CKKS scheme. I am trying to replicate the benchmarks used in this paper . They vary N,K,Q and log(pq). K is how many special prime moduli p_i we have in the Key Switching, I believe.
I know how to set N, but how can I change the other parameters to match them? I think that in examples they are normally set by the library.
Thank you
I think \log(qp) refers to the moduli chain. In that case, it depends.
\log(q) is set when defining the circuit depth and the values of \Delta and q_i's. In particular each level adds a factor q_i to \log(q).
Consider that, for the basic CKKS setting, the modulus Q at level 0 is Q=q_1 \cdot q_2 \cdot ... \cdot q_l.
Refer to this thread that shows a block of code which prints all the moduli q_i's
Pay attention that, when using Hybrid Key Switching (HKS), the moduli chain becomes larger (as it becomes \log(q) + log(p)), it is possible to control this increase by changing the value of d_{num} (set using parameters.SetNumLargeDigits()
): smaller values (i.e. d_{num} = 2 or 3), add less bits, but generate larger automorphism keys.
I would wait for an expert confirm, but in general this is the idea.
Hello, thank you for answering.
So, log(qp) refers to log(q_{0} \times p_{0}) ?
By setting q_{0} using SetfirstModSize
(not sure if this is the correct name, but is something like that), I can control log(q_{0}).
I am currently trying to understand HKS at a high level, so I am familiar that the moduli chain gets bigger during the calculations until we perform the ModDown.
However, I didn’t understand how d_{num} affects the number of bits in the moduli p_{i} nor how K is chosen. Sorry to ask, but do you understand how that part works?
Thank you
\log{}qp (better to use capital letters for these parameters to avoid confusion) refers to the entire moduli chain in q and p, both are large integers composed of the product of a chain of prime numbers, say q=q_0 \cdot q_1 \cdot \cdots q_{k-1} and p=p_0 \cdot p_1 \cdot \cdots p_{k'-1}.
To control \log{q}, keep changing the multiplicative depth until you get something close to what you want. Note that changing q might change N automatically by the library unless it is hard set.
I suggest you read this paper (including the appendices) which describes HKS in detail along with all the parameters you are asking about.