Skip to content

Commit 0971c18

Browse files
committed
recursion CI setup
1 parent 03adf88 commit 0971c18

File tree

3 files changed

+51
-23
lines changed

3 files changed

+51
-23
lines changed

.github/workflows/ci.yml

+29-1
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,43 @@ jobs:
3939
prefix-key: "mpi-v5.0.6" # update me if brew formula changes to a new version
4040
- name: Set RUSTFLAGS for AVX
4141
if: matrix.feature != ''
42-
run: echo "RUSTFLAGS=$RUSTFLAGS -C target-feature=+${{ matrix.feature }}" >> $GITHUB_ENV
42+
run: echo "RUSTFLAGS=$RUSTFLAGS -C target-feature=+${{ matrix.feature }}" >> $GITHUB_ENV
4343
- name: Build and Test
4444
run: |
4545
python3 ./scripts/install.py
4646
mpiexec --version
4747
cargo run --bin=dev-setup --release
4848
cargo build --all-features --release
4949
cargo test --all-features --release --workspace
50+
51+
recursion-test:
52+
name: Recursion test (${{ matrix.os }}${{ matrix.feature != '' && format(', {0}', matrix.feature) || '' }})
53+
runs-on: ${{ matrix.os }}
54+
strategy:
55+
matrix:
56+
include:
57+
- os: 7950x3d
58+
feature: avx2
59+
- os: 7950x3d
60+
feature: avx512f
61+
steps:
62+
- uses: actions/checkout@v4
63+
- uses: dtolnay/rust-toolchain@stable
64+
- uses: Swatinem/rust-cache@v2
65+
with:
66+
# The prefix cache key, this can be changed to start a new cache manually.
67+
prefix-key: "mpi-v5.0.6" # update me if brew formula changes to a new version
68+
- name: Set RUSTFLAGS for AVX
69+
if: matrix.feature != ''
70+
run: echo "RUSTFLAGS=$RUSTFLAGS -C target-feature=+${{ matrix.feature }}" >> $GITHUB_ENV
71+
- name: Recursion test
72+
run: |
73+
python3 ./scripts/install.py
74+
mpiexec --version
75+
cargo run --bin=dev-setup --release
5076
./scripts/test_recursion.py
77+
cd ./recursion
78+
go test ./... -v
5179
5280
gkr-e2e:
5381
name: Benchmark (${{ matrix.os }}${{ matrix.feature != '' && format(', {0}', matrix.feature) || '' }}, ${{ matrix.field }})

recursion/groth16.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func Groth16RecursionImpl() {
4747
panic(err.Error())
4848
}
4949

50-
// TODO(HS) read maybe more than just a single proof file, but rather multiple GKR proofs?
5150
proof, err := circuit.ReadProofFile(gkrProofFiles[0], fields.ECCBN254)
5251
if err != nil {
5352
panic(err.Error())
@@ -100,28 +99,31 @@ func Groth16RecursionImpl() {
10099
vk := groth16.NewVerifyingKey(ecc.BN254)
101100
groth16Proof := groth16.NewProof(ecc.BN254)
102101

102+
var pkFile *os.File = nil
103+
var vkFile *os.File = nil
104+
var proofFile *os.File = nil
105+
103106
switch groth16Mode {
104107
case "setup":
105108
println("Groth16 generating setup from scratch...")
106109
if pk, vk, err = groth16.Setup(r1cs); err != nil {
107110
panic(err.Error())
108111
}
109112

110-
pkFile, err := os.OpenFile(groth16CRSFile, os.O_WRONLY|os.O_CREATE, 0644)
111-
if err != nil {
113+
if pkFile, err = os.OpenFile(groth16CRSFile,
114+
os.O_WRONLY|os.O_CREATE, 0644); err != nil {
112115
panic(err.Error())
113116
}
114117
pk.WriteTo(pkFile)
115118

116-
vkFile, err := os.OpenFile(groth16VKFile, os.O_WRONLY|os.O_CREATE, 0644)
117-
if err != nil {
119+
if vkFile, err = os.OpenFile(groth16VKFile,
120+
os.O_WRONLY|os.O_CREATE, 0644); err != nil {
118121
panic(err.Error())
119122
}
120123
vk.WriteTo(vkFile)
121124
case "prove":
122125
println("Groth16 reading CRS from file...")
123-
pkFile, err := os.OpenFile(groth16CRSFile, os.O_RDONLY, 0444)
124-
if err != nil {
126+
if pkFile, err = os.OpenFile(groth16CRSFile, os.O_RDONLY, 0444); err != nil {
125127
panic(err.Error())
126128
}
127129
pk.ReadFrom(pkFile)
@@ -131,24 +133,22 @@ func Groth16RecursionImpl() {
131133
panic("Groth16 fails")
132134
}
133135

134-
file, err := os.OpenFile(recursiveProofFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
135-
if err != nil {
136+
if proofFile, err = os.OpenFile(recursiveProofFile,
137+
os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
136138
panic(err.Error())
137139
}
138-
groth16Proof.WriteTo(file)
140+
groth16Proof.WriteTo(proofFile)
139141
case "verify":
140142
println("Groth16 reading vk from file...")
141-
vkFile, err := os.OpenFile(groth16VKFile, os.O_RDONLY, 0444)
142-
if err != nil {
143+
if vkFile, err = os.OpenFile(groth16VKFile, os.O_RDONLY, 0444); err != nil {
143144
panic(err.Error())
144145
}
145146
vk.ReadFrom(vkFile)
146147

147-
file, err := os.OpenFile(recursiveProofFile, os.O_RDONLY, 0444)
148-
if err != nil {
148+
if proofFile, err = os.OpenFile(recursiveProofFile, os.O_RDONLY, 0444); err != nil {
149149
panic(err.Error())
150150
}
151-
groth16Proof.ReadFrom(file)
151+
groth16Proof.ReadFrom(proofFile)
152152

153153
publicWitness, err := witness.Public()
154154
if err != nil {

scripts/test_recursion.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Run the script from the root repo of Expander
44

55
import os
6-
import psutil
6+
# import psutil
77
import sys
88
import subprocess
99

@@ -32,13 +32,13 @@ def __post_init__(self):
3232
if len(set(self.cpu_ids)) != len(self.cpu_ids):
3333
raise Exception("mpi cpu id contains duplications")
3434

35-
physical_cpus = psutil.cpu_count(logical=False)
36-
if physical_cpus is None:
37-
raise Exception("hmmm your physical cpu count cannot be found")
35+
# physical_cpus = psutil.cpu_count(logical=False)
36+
# if physical_cpus is None:
37+
# raise Exception("hmmm your physical cpu count cannot be found")
3838

39-
sorted_cpu_ids = sorted(self.cpu_ids)
40-
if sorted_cpu_ids[0] < 0 or sorted_cpu_ids[-1] >= physical_cpus:
41-
raise Exception(f"mpi cpu id should be in range [0, {physical_cpus}]")
39+
# sorted_cpu_ids = sorted(self.cpu_ids)
40+
# if sorted_cpu_ids[0] < 0 or sorted_cpu_ids[-1] >= physical_cpus:
41+
# raise Exception(f"mpi cpu id should be in range [0, {physical_cpus}]")
4242

4343
def cpus(self) -> int:
4444
return len(self.cpu_ids)

0 commit comments

Comments
 (0)