-
Notifications
You must be signed in to change notification settings - Fork 158
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
add noise level #651
add noise level #651
Conversation
@slab-ci cpu_fast_test |
9fcdd3f
to
5a5ae33
Compare
@slab-ci cpu_fast_test |
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.
Missing tests
5a5ae33
to
92cfa11
Compare
@slab-ci cpu_fast_test |
tfhe/src/shortint/ciphertext/mod.rs
Outdated
@@ -83,6 +123,7 @@ impl Degree { | |||
pub struct Ciphertext { | |||
pub ct: LweCiphertextOwned<u64>, | |||
pub degree: Degree, | |||
pub noise_level: NoiseLevel, |
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.
So as we know adding this field breaks deserialization
Do we plan to do something to mitigate that ?
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.
with the 0.5.0 we will do the semver trick, we will most likely provide a way to load old ciphertext and set the noise to the max for that ciphertext or do a bootstrapping right away I would say
for 0.5.0 I would try to break as many things as possible
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.
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.
@mayeul-zama didn't we say we want the noise level to be private to be able to crash with a given feature if the noise level exceeds a valid noise level ?
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.
I don't remember that
I don't see how it's needed to have this crash feature
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.
it might make identifying the faulty operation harder though if you have a chain of adds, so... not sure I like it much
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.
Yes, and if you too many linear operations without a PBS after, the assert won't be triggered
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.
Yeah its less precise and uses the fact that in practive you are very limited in the number of leveled operation you can do
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.
But making it private forces the use of a constructor instead of a normal struct construction which is less ergonomic IMO
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.
yes but that's a very small price to pay, even though it crossed my mind
92cfa11
to
b074a5c
Compare
@slab-ci cpu_fast_test |
#[test] | ||
fn test_noise_level_propagation() { |
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.
one function per operator being tested please, with corner cases (i.e. 0 and other values for scalars)
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.
and when I say per operator, it includes, default, checked, smart and unchecked with assign versions to be sure we cover all of the paths
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.
there should be a way to re use the CPU test executor from Thomas to reuse a test for all variants
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.
except smart versions because of the mutable references potentially but it would automate most of the rest to check all paths
b074a5c
to
925bdb4
Compare
@slab-ci cpu_fast_test |
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.
Some minor stuff on testing (naming) and some randomized tests
let test_fn = |f: &dyn Fn(&ServerKey, &Ciphertext) -> Ciphertext, | ||
g: &dyn Fn(NoiseLevel) -> NoiseLevel| { |
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.
dyn is required so the closure works for everything ?
also better naming for f and g please
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.
Renamed op
and predicate
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS; | ||
use crate::shortint::{Ciphertext, ServerKey}; | ||
|
||
fn test_1_ct_noise_level_propagation(sk: &ServerKey, ct: &Ciphertext) { |
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.
test_unary_op_... ? it's a proposal but I think it's the notation we use in the C api IIRC, the end of the name is good 👍 , nitpick
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.
Done
); | ||
} | ||
|
||
fn test_2_ct_assign_noise_level_propagation(sk: &ServerKey, ct1: &Ciphertext, ct2: &Ciphertext) { |
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.
binary_op_assign
thanks for the base of the testing infrastructure, some improvements can be made I believe but we are nearly there |
925bdb4
to
de2978b
Compare
@slab-ci cpu_fast_test |
@slab-ci cpu_fast_test |
1 similar comment
@slab-ci cpu_fast_test |
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.
Minor details, next one should be good to merge
pub fn set_noise_level(&mut self, noise_level: NoiseLevel) { | ||
self.noise_level = noise_level | ||
} |
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.
should we require a max_noise_level right away ? it would mean needing to put it on the ServerKey, or maybe wait a bit more, we will probably require to re optimize all parameters sets and rework parameter sets to have the norm2 in there
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.
I plan to add it in a subsequent PR
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.
ok ! follow up issue please :)
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.
bd320da
to
7df4a9d
Compare
@slab-ci cpu_fast_test |
Changes looks good to me |
7df4a9d
to
494a71c
Compare
@slab-ci cpu_fast_test |
Pull Request has been approved 🎉 |
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.
Looks good thanks !
No description provided.