wopwopwop

This commit is contained in:
Quentin Bourgerie
2025-12-19 16:18:34 +01:00
parent 9eb40bca5a
commit 7c0fe5dce0
3 changed files with 141 additions and 37 deletions

View File

@@ -217,7 +217,12 @@ fn update_state_with_best_decompositions(
let input_lwe_dimension = glwe_params.sample_extract_lwe_dimension();
let safe_variance_bound = consts.safe_variance;
let norm = consts.noise_factor;
//let norm = consts.noise_factor;
// assert that all precisions are the same
assert!(precisions.iter().all(|&p| p == precisions[0]));
// the norm is (2 ^(2*p) - 1) / (2^p - 1)
let norm = (2u64.pow(2 * precisions[0] as u32) - 1) as f64
/ (2u64.pow(precisions[0] as u32) - 1) as f64;
let variance_modulus_switching = estimate_modulus_switching_noise_with_binary_key(
internal_dim,

View File

@@ -0,0 +1,95 @@
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
Compiling concrete-optimizer v0.1.0 (/home/yundsi/code/concrete/compilers/concrete-optimizer/concrete-optimizer)
warning: struct `ParameterCount` is never constructed
--> concrete-optimizer/src/global_parameters.rs:6:8
|
6 | struct ParameterCount {
| ^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
warning: field `operators` is never read
--> concrete-optimizer/src/optimization/dag/solo_key/analyze.rs:117:9
|
116 | pub struct OperationDag {
| ------------ field in this struct
117 | pub operators: Vec<Op>,
| ^^^^^^^^^
|
= note: `OperationDag` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis
warning: fields `precision` and `nb_luts` are never read
--> concrete-optimizer/src/optimization/dag/solo_key/analyze.rs:129:9
|
128 | pub struct VariancesAndBound {
| ----------------- fields in this struct
129 | pub precision: Precision,
| ^^^^^^^^^
130 | pub safe_variance_bound: f64,
131 | pub nb_luts: u64,
| ^^^^^^^
|
= note: `VariancesAndBound` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis
warning: hiding a lifetime that's elided elsewhere is confusing
--> concrete-optimizer/src/utils/cache/persistent.rs:121:29
|
121 | fn own_or_clone_content(&self) -> (RwLockWriteGuard<Arc<ROC>>, ROC) {
| ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
= note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
|
121 | fn own_or_clone_content(&self) -> (RwLockWriteGuard<'_, Arc<ROC>>, ROC) {
| +++
Compiling v0-parameters v0.1.0 (/home/yundsi/code/concrete/compilers/concrete-optimizer/v0-parameters)
warning: `concrete-optimizer` (lib) generated 4 warnings (run `cargo fix --lib -p concrete-optimizer` to apply 1 suggestion)
warning: function `experiments_9_bits` is never used
--> v0-parameters/src/bin/woppbs-parameters.rs:60:4
|
60 | fn experiments_9_bits() -> Vec<ExperimentParameters> {
| ^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
warning: function `experiments_11_bits` is never used
--> v0-parameters/src/bin/woppbs-parameters.rs:90:4
|
90 | fn experiments_11_bits() -> Vec<ExperimentParameters> {
| ^^^^^^^^^^^^^^^^^^^
warning: `v0-parameters` (bin "woppbs-parameters") generated 2 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.94s
Running `target/debug/woppbs-parameters --p-fail 2.938735877055719e-39`
security level: 128
target p_error: 2.9e-39
// -> Experiment for 8 bits
p, n_blocks, n_inputs, k, N, stddev, n, stddev, br_l,br_b, ks_l,ks_b, cb_l,cb_b, pp_l,pp_b, cost
8, 1, 1, 2, 10, -51.49, 618, -13.46, 7, 6, 12, 1, 7, 4, 3, 13, 16707
4, 2, 1, 2, 10, -51.49, 618, -13.46, 4, 9, 6, 2, 2, 9, 2, 17, 3555
2, 4, 1, 2, 10, -51.49, 618, -13.46, 5, 8, 6, 2, 1, 14, 2, 17, 2261
// -> Experiment for 10 bits
p, n_blocks, n_inputs, k, N, stddev, n, stddev, br_l,br_b, ks_l,ks_b, cb_l,cb_b, pp_l,pp_b, cost
10, 1, 1, 4, 9, -51.49, 634, -13.88, 22, 2, 12, 1, 10, 3, 4, 10, 73688
5, 2, 1, 2, 10, -51.49, 622, -13.56, 4, 9, 6, 2, 3, 7, 2, 17, 6230
// -> Experiment for 12 bits
p, n_blocks, n_inputs, k, N, stddev, n, stddev, br_l,br_b, ks_l,ks_b, cb_l,cb_b, pp_l,pp_b, cost
6, 2, 1, 4, 9, -51.49, 620, -13.51, 6, 7, 6, 2, 3, 8, 3, 13, 11466
4, 3, 1, 2, 10, -51.49, 655, -14.44, 4, 9, 6, 2, 2, 9, 2, 17, 5583
3, 4, 1, 2, 10, -51.49, 619, -13.48, 3, 12, 6, 2, 2, 8, 2, 17, 4406

View File

@@ -116,6 +116,10 @@ fn experiments_12_bits() -> Vec<ExperimentParameters> {
precision: 12,
n_blocks: 1,
},
ExperimentParameters {
precision: 6,
n_blocks: 2,
},
ExperimentParameters {
precision: 4,
n_blocks: 3,
@@ -162,7 +166,7 @@ fn launch_experiments(mut writer: impl Write, args: &WopArgs) {
" p, n_blocks, n_inputs, k, N, stddev, n, stddev, br_l,br_b, ks_l,ks_b, cb_l,cb_b, pp_l,pp_b, cost"
)
.unwrap();
for n_inputs in 2..5 {
for n_inputs in 1..2 {
for experiment in experiment_parameters.iter() {
let res = optimize_raw(
0.,
@@ -206,39 +210,39 @@ fn launch_experiments(mut writer: impl Write, args: &WopArgs) {
(solution.complexity / (1024.0 * 1024.0)) as u64,
// solution.p_error
).unwrap();
writeln!(writer,
"lwe_dimension: LweDimension({:1}),\n\
glwe_dimension: GlweDimension({:1}),\n\
polynomial_size: PolynomialSize({:1}),\n\
lwe_modular_std_dev: StandardDev({:.2}),\n\
glwe_modular_std_dev: StandardDev({:.2}),\n\
pbs_base_log: DecompositionBaseLog({:1}),\n\
pbs_level: DecompositionLevelCount({:1}),\n\
ks_base_log: DecompositionBaseLog({:1}),\n\
ks_level: DecompositionLevelCount({:1}),\n\
pfks_level: DecompositionLevelCount({:1}),\n\
pfks_base_log: DecompositionBaseLog({:1}),\n\
pfks_modular_std_dev: StandardDev({:.2}),\n\
cbs_level: DecompositionLevelCount({:1}),\n\
cbs_base_log: DecompositionBaseLog({:1}),\n\
message_modulus: MessageModulus(-),\n\
carry_modulus: CarryModulus(1),\n\
",
solution.internal_ks_output_lwe_dimension,
solution.glwe_dimension,
(solution.glwe_polynomial_size as f64) as u64,
lwe_log_std_dev,
glwe_log_std_dev,
solution.br_decomposition_base_log,
solution.br_decomposition_level_count,
solution.ks_decomposition_base_log,
solution.ks_decomposition_level_count,
solution.pp_decomposition_level_count,
solution.pp_decomposition_base_log,
glwe_log_std_dev,
solution.cb_decomposition_level_count,
solution.cb_decomposition_base_log,
).unwrap();
// writeln!(writer,
// "lwe_dimension: LweDimension({:1}),\n\
// glwe_dimension: GlweDimension({:1}),\n\
// polynomial_size: PolynomialSize({:1}),\n\
// lwe_modular_std_dev: StandardDev({:.2}),\n\
// glwe_modular_std_dev: StandardDev({:.2}),\n\
// pbs_base_log: DecompositionBaseLog({:1}),\n\
// pbs_level: DecompositionLevelCount({:1}),\n\
// ks_base_log: DecompositionBaseLog({:1}),\n\
// ks_level: DecompositionLevelCount({:1}),\n\
// pfks_level: DecompositionLevelCount({:1}),\n\
// pfks_base_log: DecompositionBaseLog({:1}),\n\
// pfks_modular_std_dev: StandardDev({:.2}),\n\
// cbs_level: DecompositionLevelCount({:1}),\n\
// cbs_base_log: DecompositionBaseLog({:1}),\n\
// message_modulus: MessageModulus(-),\n\
// carry_modulus: CarryModulus(1),\n\
// ",
// solution.internal_ks_output_lwe_dimension,
// solution.glwe_dimension,
// (solution.glwe_polynomial_size as f64) as u64,
// lwe_log_std_dev,
// glwe_log_std_dev,
// solution.br_decomposition_base_log,
// solution.br_decomposition_level_count,
// solution.ks_decomposition_base_log,
// solution.ks_decomposition_level_count,
// solution.pp_decomposition_level_count,
// solution.pp_decomposition_base_log,
// glwe_log_std_dev,
// solution.cb_decomposition_level_count,
// solution.cb_decomposition_base_log,
// ).unwrap();
}
_ => {}
}
@@ -248,9 +252,9 @@ fn launch_experiments(mut writer: impl Write, args: &WopArgs) {
};
launch_experiment(experiments_8_bits(), 8);
launch_experiment(experiments_9_bits(), 9);
//launch_experiment(experiments_9_bits(), 9);
launch_experiment(experiments_10_bits(), 10);
launch_experiment(experiments_11_bits(), 11);
//launch_experiment(experiments_11_bits(), 11);
launch_experiment(experiments_12_bits(), 12);
}