-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(integer): do sum by safe chunk sizes #1512
Conversation
tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs
Outdated
Show resolved
Hide resolved
96d9842
to
1644cad
Compare
9f109de
to
3e72c87
Compare
uint32_t max_value = total_modulus - 1; | ||
uint32_t max_value = (total_modulus - 1) / (params.message_modulus - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agnesLeroy this is fine as is for our set of parameters dedicated to the blockchain but ideally we need to take the min with the noise level see the tfhe/src/integer/server_key/mod.rs file for the final min with noise level
integer test failure https://github.com/zama-ai/tfhe-rs/actions/runs/10813176643/job/29996656992 |
Parameters are made with with assumptions on the number of leveled add/sub/scalar_mul operations are made, so that the noise level before doing a PBS has a correct level and everything is safe, secure and correct. So the lib implementation has to uphold these assumptions in order to keep the error probability failure correct. In the comparisons, at some point we had a vector of ciphertexts with a degree == 1, so we greedily summed them (e.g with 2_2 params we summed them by chunks of 15), while it is correct with regards to the carry and message space it is however less correct with regards to the noise level. Noise wise, doing this huge sum is correct as long as the noise of each ciphertext is independent from the others in the same chunk. While it may generally be the case we are in, its not guaranteed, and since we do not track that information we have to take the safer approach of assuming the worst case: all noise are dependent. So to fix the issue we compute the correct size of sum chunk by also taking into account the max noise level.
3e72c87
to
0e1fc50
Compare
Parameters are made with with assumptions on the number of leveled add/sub/scalar_mul operations are made, so that the noise level before doing a PBS has a correct level and everything is safe, secure and correct.
So the lib implementation has to uphold these assumptions in order to keep the error probability failure correct.
In the comparisons, at some point we had a vector of ciphertexts with a degree == 1, so we greedily summed them (e.g with 2_2 params we summed them by chunks of 15), while it is correct with regards to the carry and message space it is however less correct with regards to the noise level.
Noise wise, doing this huge sum is correct as long as the noise of each ciphertext is independent from the others in the same chunk.
While it may generally be the case we are in, its not guaranteed, and since we do not track that information we have to take the safer approach of assuming the worst case: all noise are dependent.
So to fix the issue we compute the correct size of sum chunk by also taking into account the max noise level.