Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: performance improvements #14

Merged
merged 18 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]
include:
- feature_set: basic
features: batch,dev-graph,gadget-traces,multicore
features: batch,dev-graph,gadget-traces
- feature_set: all
features: batch,dev-graph,gadget-traces,test-dev-graph,thread-safe-region,sanity-checks,circuit-params

Expand Down
7 changes: 1 addition & 6 deletions halo2_gadgets/src/poseidon/pow5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,7 @@ impl<
// The capacity element is never altered by the input.
.unwrap_or_else(|| Value::known(F::ZERO));
region
.assign_advice(
|| format!("load output_{i}"),
config.state[i],
2,
|| value,
)
.assign_advice(|| format!("load output_{i}"), config.state[i], 2, || value)
.map(StateWord)
};

Expand Down
18 changes: 11 additions & 7 deletions halo2_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,24 @@ log = { version = "0.4.17", default_features = false }
backtrace = { version = "0.3", optional = true }
ff = "0.13"
group = "0.13"
halo2curves = { git = "https://github.com/privacy-scaling-explorations/halo2curves", rev="9fff22c", default-features = false }
halo2curves = { git = "https://github.com/privacy-scaling-explorations/halo2curves", rev="b753a832e92d5c86c5c997327a9cf9de86a18851", default-features = false }
rand_core = { version = "0.6", default-features = false }
tracing = "0.1"
blake2b_simd = "1" # MSRV 1.66.0
sha3 = "0.9.1"
rand_chacha = "0.3"
maybe-rayon = { version = "0.1.1"}
lazy_static = { version = "1", optional = true }
env_logger = "0.10.0"
rustc-hash = "2.0.0"

lazy_static = "1.4.0"
# GPU Icicle integration
icicle = { git = "https://github.com/ingonyama-zk/icicle.git", branch = "rust/large-bucket-factor-msm", optional = true }
rustacuda = { version = "0.1", optional = true }
serde = { version = "1", optional = true, features = ["derive"] }
serde_derive = { version = "1", optional = true}
bincode = { version = "1.3.3", default_features = false }
serde = { version = "1.0.126", features = ["derive"] }
instant = { version = "0.1" }


# Developer tooling dependencies
plotters = { version = "0.3.0", default-features = false, optional = true }
Expand All @@ -88,26 +90,28 @@ serde_json = "1"
getrandom = { version = "0.2", features = ["js"] }

[features]
default = ["batch", "bits"]
default = ["batch", "bits", "derive_serde"]
dev-graph = ["plotters", "tabbycat"]
test-dev-graph = [
"dev-graph",
"plotters/bitmap_backend",
"plotters/bitmap_encoder",
"plotters/ttf",
]
asm = ["halo2curves/asm"]
bits = ["halo2curves/bits"]
gadget-traces = ["backtrace"]
thread-safe-region = []
sanity-checks = []
batch = ["rand_core/getrandom"]
circuit-params = []
counter = ["lazy_static"]
counter = []
icicle_gpu = ["icicle", "rustacuda"]
mv-lookup = []
cost-estimator = ["serde", "serde_derive"]
cost-estimator = ["serde_derive"]
derive_serde = ["halo2curves/derive_serde"]
parallel-poly-read = []
precompute-coset = []

[lib]
bench = false
Expand Down
16 changes: 8 additions & 8 deletions halo2_proofs/examples/simple-lookup-unblinded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ fn main() {
println!("k = {K}");
// time it
println!("keygen");
let start = std::time::Instant::now();
let start = instant::Instant::now();
let (params, pk) = keygen(K);
let end = std::time::Instant::now();
let end = instant::Instant::now();
println!("keygen time: {:?}", end.duration_since(start));

println!("saving proving key 💾");
Expand All @@ -267,7 +267,7 @@ fn main() {

println!("reloading proving key 💾");

let f = std::fs::File::open(path.clone()).unwrap();
let f = std::fs::File::open(path).unwrap();
let mut reader = std::io::BufReader::new(f);
#[cfg(feature = "circuit-params")]
let pk = ProvingKey::<G1Affine>::read::<_, MyCircuit<Fr>>(
Expand Down Expand Up @@ -297,7 +297,7 @@ fn main() {

println!("reloading verifier key 💾");

let f = std::fs::File::open(path.clone()).unwrap();
let f = std::fs::File::open(path).unwrap();
let mut reader = std::io::BufReader::new(f);
#[cfg(feature = "circuit-params")]
let vk = VerifyingKey::<G1Affine>::read::<_, MyCircuit<Fr>>(
Expand All @@ -315,14 +315,14 @@ fn main() {

// time it
println!("prover");
let start = std::time::Instant::now();
let start = instant::Instant::now();
let proof = prover(K, &params, &pk);
let end = std::time::Instant::now();
let end = instant::Instant::now();
println!("prover time: {:?}", end.duration_since(start));
// time it
println!("verifier");
let start = std::time::Instant::now();
let start = instant::Instant::now();
verifier(&params, &vk, &proof);
let end = std::time::Instant::now();
let end = instant::Instant::now();
println!("verifier time: {:?}", end.duration_since(start));
}
16 changes: 8 additions & 8 deletions halo2_proofs/examples/simple-lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ fn main() {
println!("k = {K}");
// time it
println!("keygen");
let start = std::time::Instant::now();
let start = instant::Instant::now();
let (params, pk) = keygen(K);
let end = std::time::Instant::now();
let end = instant::Instant::now();
println!("keygen time: {:?}", end.duration_since(start));

println!("saving proving key 💾");
Expand All @@ -267,7 +267,7 @@ fn main() {

println!("reloading proving key 💾");

let f = std::fs::File::open(path.clone()).unwrap();
let f = std::fs::File::open(path).unwrap();
let mut reader = std::io::BufReader::new(f);
#[cfg(feature = "circuit-params")]
let pk = ProvingKey::<G1Affine>::read::<_, MyCircuit<Fr>>(
Expand Down Expand Up @@ -297,7 +297,7 @@ fn main() {

println!("reloading verifier key 💾");

let f = std::fs::File::open(path.clone()).unwrap();
let f = std::fs::File::open(path).unwrap();
let mut reader = std::io::BufReader::new(f);
#[cfg(feature = "circuit-params")]
let vk = VerifyingKey::<G1Affine>::read::<_, MyCircuit<Fr>>(
Expand All @@ -315,14 +315,14 @@ fn main() {

// time it
println!("prover");
let start = std::time::Instant::now();
let start = instant::Instant::now();
let proof = prover(K, &params, &pk);
let end = std::time::Instant::now();
let end = instant::Instant::now();
println!("prover time: {:?}", end.duration_since(start));
// time it
println!("verifier");
let start = std::time::Instant::now();
let start = instant::Instant::now();
verifier(&params, &vk, &proof);
let end = std::time::Instant::now();
let end = instant::Instant::now();
println!("verifier time: {:?}", end.duration_since(start));
}
4 changes: 2 additions & 2 deletions halo2_proofs/examples/vector-mul-unblinded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@ fn main() {
// of the instance column, so we position it there in our public inputs.
let mut public_inputs = c;

let start = std::time::Instant::now();
let start = instant::Instant::now();
// Given the correct public input, our circuit will verify.
let prover = MockProver::run(k, &circuit, vec![public_inputs.clone()]).unwrap();
assert_eq!(prover.verify(), Ok(()));
println!("positive test took {:?}", start.elapsed());

// If we try some other public input, the proof will fail!
let start = std::time::Instant::now();
let start = instant::Instant::now();
public_inputs[0] += Fp::one();
let prover = MockProver::run(k, &circuit, vec![public_inputs]).unwrap();
assert!(prover.verify().is_err());
Expand Down
4 changes: 2 additions & 2 deletions halo2_proofs/examples/vector-mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,14 @@ fn main() {
// of the instance column, so we position it there in our public inputs.
let mut public_inputs = c;

let start = std::time::Instant::now();
let start = instant::Instant::now();
// Given the correct public input, our circuit will verify.
let prover = MockProver::run(k, &circuit, vec![public_inputs.clone()]).unwrap();
assert_eq!(prover.verify(), Ok(()));
println!("positive test took {:?}", start.elapsed());

// If we try some other public input, the proof will fail!
let start = std::time::Instant::now();
let start = instant::Instant::now();
public_inputs[0] += Fp::one();
let prover = MockProver::run(k, &circuit, vec![public_inputs]).unwrap();
assert!(prover.verify().is_err());
Expand Down
Loading
Loading