Hello! I’m trying to understand how to compute the RAM consumption of an application that uses OpenFHE CKKS implementation.
In particular, I want to know the requiered RAM (in MB) of the following:
- Public/secret keys
- Keyswitching keys
- Automorphism keys
- Fresh ciphertext
My first idea was to just use theoretical estimates to get those values but I would rather have more accurate numbers than relying on estimates.
My second approach has been to run the code in simple-real-numbers-serial.cpp and take the sizes of the generated files. However I do not know how well these values actually represent the real RAM consumption. After using htop I don’t think they are that far but I want to verify that somehow.
Any help on this would be much appreciated.
TLDR: Any thoughts on how to obtain precise RAM requirements for a given application in CKKS without using estimates?
Theoretical estimates are typically quite accurate (almost exact). This is what I use in most of the cases for the single-threaded execution. In multithreaded cases, the RAM consumption is typically higher.
The use of the size of serialized ciphertexts/keys is good when computing the communication requirements. There are some differences between the binary-serialized objects and RAM utilization (although they are typically within a factor of 2 from each other).
The theoretical estimation is more precise as you can exactly compute the RAM needed for individual polynomials and keys.
Thank you for your advice Yuriy.
Regarding the theoretical estimates, I’m using N\log_2(Q_L) / 4 bytes for public keys and fresh ciphertext and N d_\text{num} \log_2(Q_L P) / 4 bytes for key switching keys and automorphishm keys (I’m assume I use hybrid key-switching). Do you recommend these estimates or do you know of some more fine-grained ones that fit better the RNS implementation of CKKS in OpenFHE?
I use more refined (RNS-based) estimates, i.e., 2 \times 64 N k / 8 = 16 N k for the public key and 2 \times 64 N d_{num} (k + k’) /8 = 16 N d_{num} (k + k’). Here, k is the number of RNS limbs in Q and k’ the number of RNS limbs in P.
Thank you for your reply Yuriy!