Skip to content

Commit 102c811

Browse files
authored
fix typo in JohnsonBound formula (#187)
* typo in JohnsonBound formula * improved log_eta * missing link --------- Co-authored-by: Tom Wambsgans <TomWambsgans@users.noreply.github.com>
1 parent d5ab698 commit 102c811

File tree

6 files changed

+134
-92
lines changed

6 files changed

+134
-92
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cargo run --release -- recursion --n 2
5252

5353
| Proven | Conjectured |
5454
| --------------- | --------------- |
55-
| 0.8s - 188 KiB | 0.57s - 116 KiB |
55+
| 0.85s - 188 KiB | 0.57s - 116 KiB |
5656

5757

5858
### Bonus: unbounded recursive aggregation

crates/rec_aggregation/fiat_shamir.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ def fs_finalize_sample(fs, total_n_chunks):
179179

180180
@inline
181181
def fs_sample_queries(fs, n_samples):
182-
debug_assert(n_samples < 256)
182+
debug_assert(n_samples < 512)
183183
# Compute total_chunks = ceil(n_samples / 8) via bit decomposition.
184-
# Big-endian: nb[0]=bit7 (MSB), nb[7]=bit0 (LSB).
185-
nb = checked_decompose_bits_small_value_const(n_samples, 8)
186-
floor_div = nb[0] * 16 + nb[1] * 8 + nb[2] * 4 + nb[3] * 2 + nb[4]
187-
has_remainder = 1 - (1 - nb[5]) * (1 - nb[6]) * (1 - nb[7])
184+
# Big-endian: nb[0]=bit8 (MSB), nb[8]=bit0 (LSB).
185+
nb = checked_decompose_bits_small_value_const(n_samples, 9)
186+
floor_div = nb[0] * 32 + nb[1] * 16 + nb[2] * 8 + nb[3] * 4 + nb[4] * 2 + nb[5]
187+
has_remainder = 1 - (1 - nb[6]) * (1 - nb[7]) * (1 - nb[8])
188188
total_chunks = floor_div + has_remainder
189189
# Sample exactly the needed chunks (dispatch via match_range to keep n_chunks const)
190-
sampled = match_range(total_chunks, range(0, 33), lambda nc: fs_sample_data_with_offset(fs, nc, 0))
190+
sampled = match_range(total_chunks, range(0, 65), lambda nc: fs_sample_data_with_offset(fs, nc, 0))
191191
new_fs = fs_finalize_sample(fs, total_chunks)
192192
return sampled, new_fs

crates/rec_aggregation/src/compilation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn compile_main_program(inner_program_log_size: usize, bytecode_zero_eval: F) ->
5353

5454
#[instrument(skip_all)]
5555
fn compile_main_program_self_referential() -> Bytecode {
56-
let mut log_size_guess = 18;
56+
let mut log_size_guess = 19;
5757
let bytecode_zero_eval = F::ONE;
5858
loop {
5959
let bytecode = compile_main_program(log_size_guess, bytecode_zero_eval);
@@ -145,7 +145,7 @@ fn build_replacements(
145145
all_potential_folding_grinding.push(format!("[{}]", folding_grinding_for_rate.join(", ")));
146146
}
147147
if too_much_grinding {
148-
tracing::warn!("Too much grinding for WHIR folding",);
148+
tracing::info!("Warning: Too much grinding for WHIR folding"); // TODO
149149
}
150150
replacements.insert(
151151
"WHIR_FIRST_RS_REDUCTION_FACTOR_PLACEHOLDER".to_string(),

crates/rec_aggregation/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def div_ceil_dynamic(a, b: Const):
1717
def powers(alpha, n):
1818
# alpha: EF
1919
# n: F
20-
assert n < 256
20+
assert n < 400
2121
assert 0 < n
2222
# 2**log2_ceil(i) is not really necessary but helps reduce byetcode size (traedoff cycles / bytecode size)
23-
res = match_range(n, range(1, 256), lambda i: powers_const(alpha, 2**log2_ceil(i)))
23+
res = match_range(n, range(1, 400), lambda i: powers_const(alpha, 2**log2_ceil(i)))
2424
return res
2525

2626

@@ -139,8 +139,8 @@ def eval_multilinear_coeffs_rev(coeffs, point, n: Const):
139139

140140

141141
def dot_product_be_dynamic(a, b, res, n):
142-
debug_assert(n <= 256)
143-
match_range(n, range(1, 257), lambda i: dot_product_be(a, b, res, i))
142+
debug_assert(n < 400)
143+
match_range(n, range(1, 400), lambda i: dot_product_be(a, b, res, i))
144144
return
145145

146146

@@ -150,8 +150,8 @@ def dot_product_be_const(a, b, res, n: Const):
150150

151151

152152
def dot_product_ee_dynamic(a, b, res, n):
153-
debug_assert(n <= 256)
154-
match_range(n, range(1, 257), lambda i: dot_product_ee(a, b, res, i))
153+
debug_assert(n < 400)
154+
match_range(n, range(1, 400), lambda i: dot_product_ee(a, b, res, i))
155155
return
156156

157157

0 commit comments

Comments
 (0)