Skip to content

Commit

Permalink
Use degree() to compute the max_degree
Browse files Browse the repository at this point in the history
  • Loading branch information
iquerejeta committed May 8, 2024
1 parent dd159f6 commit 982fbe7
Show file tree
Hide file tree
Showing 22 changed files with 33 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
5,21,0,3,0,4,16,2,1600
4,21,0,3,0,4,15,2,1504
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
5,201,0,3,0,4,16,2,1792
4,201,0,3,0,4,15,2,1696
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
5,2001,0,3,0,4,16,2,1984
4,2001,0,3,0,4,15,2,1888
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
11,206,1024,10,1,10,48,6,4128
6,206,1024,10,1,10,43,6,3648
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,105,256,9,2,11,55,4,4480
6,105,256,9,2,11,49,4,3904
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,108,256,9,2,11,55,4,4480
6,108,256,9,2,11,49,4,3904
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,105,256,9,2,11,55,4,4480
6,105,256,9,2,11,49,4,3904
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,108,256,9,2,11,55,4,4480
6,108,256,9,2,11,49,4,3904
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,28,256,9,2,11,55,4,4480
6,28,256,9,2,11,49,4,3904
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,36,256,9,2,11,55,4,4480
6,36,256,9,2,11,49,4,3904
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,28,256,9,2,11,55,4,4480
6,28,256,9,2,11,49,4,3904
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,36,256,9,2,11,55,4,4480
6,36,256,9,2,11,49,4,3904
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,156,1024,10,1,11,52,4,4288
9,156,1024,10,1,11,49,4,4000
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,269,1024,10,1,11,52,4,4288
9,269,1024,10,1,11,49,4,4000
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,87,1024,10,1,11,52,4,4288
9,87,1024,10,1,11,49,4,4000
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,151,1024,10,1,11,52,4,4288
9,151,1024,10,1,11,49,4,4000
2 changes: 1 addition & 1 deletion halo2_gadgets/goldenfiles/cost-model/fbsm_short_pallas.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,27,1024,10,1,11,52,4,4288
9,27,1024,10,1,11,49,4,4000
2 changes: 1 addition & 1 deletion halo2_gadgets/goldenfiles/cost-model/fbsm_short_pluto.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
12,27,1024,10,1,11,52,4,4288
9,27,1024,10,1,11,49,4,4000
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
16,16908,1024,10,3,15,84,5,6496
9,16908,1024,10,3,15,77,5,5824
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_deg,rows,table_rows,advice_columns,lookups,permutations,column_queries,point_sets,proof_size
16,4501,1024,10,3,15,84,5,6368
9,4501,1024,10,3,15,77,5,5696
4 changes: 4 additions & 0 deletions halo2_proofs/examples/cost-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ struct CliCostOptions {
#[options(help = "Maximum degree of the custom gates.", meta = "D")]
gate_degree: usize,

#[options(help = "Maximum degree of the Constrain system.", meta = "D")]
max_degree: usize,

#[options(
help = "A lookup over N columns with max input degree I and max table degree T. May be repeated.",
meta = "N,I,T"
Expand All @@ -51,6 +54,7 @@ impl CliCostOptions {
instance: self.instance.clone(),
fixed: self.fixed.clone(),
gate_degree: self.gate_degree,
max_deg: self.max_degree,
lookup: self.lookup.clone(),
permutation: self.permutation.clone(),
rows_count: self.rows,
Expand Down
19 changes: 9 additions & 10 deletions halo2_proofs/src/dev/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub struct CostOptions {
/// Maximum degree of the custom gates.
pub gate_degree: usize,

/// Maximum degree of the constrain system.
pub max_deg: usize,

/// A lookup over N columns with max input degree I and max table degree T. May be repeated.
pub lookup: Vec<Lookup>,

Expand Down Expand Up @@ -173,6 +176,9 @@ impl FromStr for Permutation {
}

impl Permutation {
/// Return the number of columns
pub fn nr_columns(&self) -> usize { self.columns }

fn required_degree(&self) -> usize {

Check warning on line 182 in halo2_proofs/src/dev/cost_model.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

method `required_degree` is never used

warning: method `required_degree` is never used --> halo2_proofs/src/dev/cost_model.rs:182:8 | 178 | impl Permutation { | ---------------- method in this implementation ... 182 | fn required_degree(&self) -> usize { | ^^^^^^^^^^^^^^^

Check warning on line 182 in halo2_proofs/src/dev/cost_model.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

method `required_degree` is never used

warning: method `required_degree` is never used --> halo2_proofs/src/dev/cost_model.rs:182:8 | 178 | impl Permutation { | ---------------- method in this implementation ... 182 | fn required_degree(&self) -> usize { | ^^^^^^^^^^^^^^^

Check warning on line 182 in halo2_proofs/src/dev/cost_model.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest

method `required_degree` is never used

Check warning on line 182 in halo2_proofs/src/dev/cost_model.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

method `required_degree` is never used

Check warning on line 182 in halo2_proofs/src/dev/cost_model.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

method `required_degree` is never used
cmp::max(self.columns + 1, 2)
}
Expand Down Expand Up @@ -237,22 +243,14 @@ pub struct ModelCircuit {

impl From<CostOptions> for ModelCircuit {
fn from(opts: CostOptions) -> Self {
let max_deg = [1, opts.gate_degree]
.iter()
.cloned()
.chain(opts.lookup.iter().map(|l| l.required_degree()))
.chain(opts.permutation.iter().map(|p| p.required_degree()))
.max()
.unwrap();

let mut queries: Vec<_> = iter::empty()
.chain(opts.advice.iter())
.chain(opts.instance.iter())
.chain(opts.fixed.iter())
.cloned()
.chain(opts.lookup.iter().flat_map(|l| l.queries()))
.chain(opts.permutation.iter().flat_map(|p| p.queries()))
.chain(iter::repeat("0".parse().unwrap()).take(max_deg - 1))
.chain(iter::repeat("0".parse().unwrap()).take(opts.max_deg - 1))
.collect();

let column_queries = queries.len();
Expand All @@ -264,7 +262,7 @@ impl From<CostOptions> for ModelCircuit {
k: opts.k,
rows: opts.rows_count,
table_rows: opts.table_rows_count,
max_deg,
max_deg: opts.max_deg,
gate_usages: opts.gate_usages,
advice_columns: opts.advice.len(),
lookups: opts.lookup.len(),
Expand Down Expand Up @@ -596,6 +594,7 @@ pub fn from_circuit_to_cost_model_options<
instance,
fixed,
gate_degree,
max_deg: cs.degree(),
lookup,
permutation,
gate_usages,
Expand Down

0 comments on commit 982fbe7

Please sign in to comment.