Skip to content

Commit 18560e0

Browse files
committed
finished
1 parent 087d31d commit 18560e0

10 files changed

Lines changed: 1218 additions & 88 deletions

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# zk-IVF-PQ
2+
3+
## Build
4+
5+
Build and install the Python extension:
6+
7+
```bash
8+
maturin develop --release
9+
```
10+
11+
## Experiment 1: Retrieval Utility Evaluation
12+
13+
### Classic ANN (SIFT1M / GIST1M)
14+
15+
```bash
16+
bash scripts/acc_bench.sh
17+
```
18+
19+
Results are cached under `data/acc_bench/`.
20+
21+
### IR (MS MARCO passage retrieval, dev)
22+
23+
Run the two evaluation jobs (high-acc and zk-opt) and then aggregate metrics:
24+
25+
```bash
26+
python -m bench.ms_macro_eval \
27+
--num-runs 1 \
28+
--n-list 8192 \
29+
--n-probe 64 \
30+
--M 8 \
31+
--K 256 \
32+
--cluster-bound 2048 \
33+
--top-k 1000 \
34+
--out-dir data/exp1/ms_macro_high_acc
35+
36+
python -m bench.ms_macro_eval \
37+
--num-runs 1 \
38+
--n-list 2048 \
39+
--n-probe 16 \
40+
--M 8 \
41+
--K 256 \
42+
--cluster-bound 8192 \
43+
--top-k 1000 \
44+
--out-dir data/exp1/ms_macro_zk_fast
45+
46+
python -m bench.ms_macro_result data/exp1/ms_macro_high_acc data/exp1/ms_macro_zk_fast
47+
```
48+
49+
Outputs are written under `data/exp1/`.
50+
51+
## Experiment 2: Proof Cost Evaluation
52+
53+
Script: `scripts/bench_suite.sh` (runs `python -m bench.bench_suite` and caches results under `data/bench_result/`).
54+
55+
```bash
56+
bash scripts/bench_suite.sh
57+
```
58+
59+
Optional: if `matplotlib` is available, a summary plot is generated at `data/bench_result/bench_summary.pdf`.
60+
61+
## Experiment 3: Configuration Trade-offs
62+
63+
### Fixed scan budget: sweep `n_list`
64+
65+
```bash
66+
bash scripts/optimal_config.sh
67+
```
68+
69+
Outputs are written to `data/optimal_config/`.
70+
71+
### Fixed code budget: gate-only sweep over `K` (and zk-opt selection)
72+
73+
```bash
74+
bash scripts/optimal_mem_gate_only_ann_ir.sh
75+
```
76+
77+
Outputs are written to `data/optimal_mem_gate_only/`.

bench/bench_suite.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ def d(self) -> int:
8181

8282

8383
DEFAULT_CONFIGS: List[BenchConfig] = [
84-
BenchConfig(
85-
name="basic", # 基础测试, 后面都是以这个为基础
86-
N=8192,
87-
D=128,
88-
M=8,
89-
K=16,
90-
n_list=256,
91-
n_probe=16,
92-
top_k=64,
93-
merkled=False,
94-
),
84+
# BenchConfig(
85+
# name="basic", # 基础测试, 后面都是以这个为基础
86+
# N=8192,
87+
# D=128,
88+
# M=8,
89+
# K=16,
90+
# n_list=256,
91+
# n_probe=16,
92+
# top_k=64,
93+
# merkled=False,
94+
# ),
9595
BenchConfig(
9696
name="basic-merkle", # 基础测试, 后面都是以这个为基础
9797
N=8192,
@@ -103,17 +103,17 @@ def d(self) -> int:
103103
top_k=64,
104104
merkled=True,
105105
),
106-
BenchConfig(
107-
name="low-acc", # 超低精度测试, 主要是测试circuit是否有机会
108-
N=8192,
109-
D=128,
110-
M=8,
111-
K=1,
112-
n_list=16,
113-
n_probe=1,
114-
top_k=1,
115-
merkled=False,
116-
),
106+
# BenchConfig(
107+
# name="low-acc", # 超低精度测试, 主要是测试circuit是否有机会
108+
# N=8192,
109+
# D=128,
110+
# M=8,
111+
# K=1,
112+
# n_list=16,
113+
# n_probe=1,
114+
# top_k=1,
115+
# merkled=False,
116+
# ),
117117
BenchConfig(
118118
name="low-acc-merkle", # 超低精度测试, 主要是测试circuit是否有机会
119119
N=8192,
@@ -125,17 +125,17 @@ def d(self) -> int:
125125
top_k=1,
126126
merkled=True,
127127
),
128-
BenchConfig(
129-
name="large", # 大规模, 高精度测试
130-
N=65536,
131-
D=256,
132-
M=16,
133-
K=256,
134-
n_list=512,
135-
n_probe=64,
136-
top_k=128,
137-
merkled=False,
138-
),
128+
# BenchConfig(
129+
# name="large", # 大规模, 高精度测试
130+
# N=65536,
131+
# D=256,
132+
# M=16,
133+
# K=256,
134+
# n_list=512,
135+
# n_probe=64,
136+
# top_k=128,
137+
# merkled=False,
138+
# ),
139139
BenchConfig(
140140
name="large-merkle", # 大规模, 高精度测试
141141
N=65536,

0 commit comments

Comments
 (0)