mirror of
https://github.com/zkonduit/ezkl.git
synced 2026-01-10 06:48:01 -05:00
feat: icicle integration (gpu proving) (#586)
--------- Co-authored-by: Alexander Camuto <45801863+alexander-camuto@users.noreply.github.com> Co-authored-by: Alexander Camuto <alexander.camuto@st-hughs.ox.ac.uk>
This commit is contained in:
100
.github/workflows/rust.yml
vendored
100
.github/workflows/rust.yml
vendored
@@ -62,9 +62,46 @@ jobs:
|
||||
run: cargo test --doc --verbose
|
||||
- name: Library tests
|
||||
run: cargo nextest run --lib --verbose
|
||||
|
||||
|
||||
ultra-overflow-tests-gpu:
|
||||
runs-on: GPU
|
||||
env:
|
||||
ENABLE_ICICLE_GPU: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly-2023-08-24
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- uses: baptiste0928/cargo-install@v1
|
||||
with:
|
||||
crate: cargo-nextest
|
||||
locked: true
|
||||
- uses: mwilliamson/setup-wasmtime-action@v2
|
||||
with:
|
||||
wasmtime-version: "3.0.1"
|
||||
- name: Install wasm32-wasi
|
||||
run: rustup target add wasm32-wasi
|
||||
- name: Install cargo-wasi
|
||||
run: cargo install cargo-wasi
|
||||
# - name: Matmul overflow (wasi)
|
||||
# run: cargo wasi test matmul_col_ultra_overflow -- --include-ignored --nocapture
|
||||
# - name: Conv overflow (wasi)
|
||||
# run: cargo wasi test conv_col_ultra_overflow -- --include-ignored --nocapture
|
||||
- name: lookup overflow
|
||||
run: cargo nextest run --release lookup_ultra_overflow --no-capture --features icicle -- --include-ignored
|
||||
- name: Matmul overflow
|
||||
run: RUST_LOG=debug cargo nextest run matmul_col_ultra_overflow --no-capture --features icicle -- --include-ignored
|
||||
- name: Conv overflow
|
||||
run: RUST_LOG=debug cargo nextest run conv_col_ultra_overflow --no-capture --features icicle -- --include-ignored
|
||||
- name: Conv + relu overflow
|
||||
run: cargo nextest run --release conv_relu_col_ultra_overflow --no-capture --features icicle -- --include-ignored
|
||||
|
||||
|
||||
ultra-overflow-tests:
|
||||
runs-on: self-hosted
|
||||
runs-on: non-gpu
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@@ -155,7 +192,7 @@ jobs:
|
||||
run: cargo nextest run --release --verbose tests::tutorial_
|
||||
|
||||
mock-proving-tests:
|
||||
runs-on: self-hosted
|
||||
runs-on: non-gpu
|
||||
# needs: [build, library-tests, docs]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -350,6 +387,44 @@ jobs:
|
||||
- name: KZG prove and verify tests (encrypted outputs)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_encrypted
|
||||
|
||||
|
||||
prove-and-verify-tests-gpu:
|
||||
runs-on: GPU
|
||||
env:
|
||||
ENABLE_ICICLE_GPU: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly-2023-08-24
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- name: Add rust-src
|
||||
run: rustup component add rust-src --toolchain nightly-2023-08-24-x86_64-unknown-linux-gnu
|
||||
- uses: actions/checkout@v3
|
||||
- uses: baptiste0928/cargo-install@v1
|
||||
with:
|
||||
crate: cargo-nextest
|
||||
locked: true
|
||||
- name: KZG prove and verify tests (kzg outputs)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_kzg_output --features icicle
|
||||
- name: KZG prove and verify tests (public outputs + column overflow)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_with_overflow_::w --features icicle
|
||||
- name: KZG prove and verify tests (public outputs + fixed params + column overflow)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_with_overflow_fixed_params_ --features icicle
|
||||
- name: KZG prove and verify tests (public outputs)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_::t --features icicle
|
||||
- name: KZG prove and verify tests (public outputs + column overflow)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_::t --features icicle
|
||||
- name: KZG prove and verify tests (public inputs)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_public_input --features icicle
|
||||
- name: KZG prove and verify tests (fixed params)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_fixed_params --features icicle
|
||||
- name: KZG prove and verify tests (hashed outputs)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_hashed --features icicle
|
||||
- name: KZG prove and verify tests (encrypted outputs)
|
||||
run: cargo nextest run --release --verbose tests::kzg_prove_and_verify_encrypted --features icicle
|
||||
|
||||
fuzz-tests:
|
||||
runs-on: ubuntu-latest-32-cores
|
||||
needs: [build, library-tests, python-tests]
|
||||
@@ -389,6 +464,25 @@ jobs:
|
||||
locked: true
|
||||
- name: Mock aggr tests
|
||||
run: cargo nextest run --release --verbose tests_aggr::kzg_aggr_mock_prove_and_verify_ --test-threads 8
|
||||
|
||||
|
||||
prove-and-verify-aggr-tests-gpu:
|
||||
runs-on: GPU
|
||||
env:
|
||||
ENABLE_ICICLE_GPU: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly-2023-08-24
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- uses: baptiste0928/cargo-install@v1
|
||||
with:
|
||||
crate: cargo-nextest
|
||||
locked: true
|
||||
- name: KZG )tests
|
||||
run: cargo nextest run --release --verbose tests_aggr::kzg_aggr_prove_and_verify_ --features icicle --test-threads 1 -- --include-ignored
|
||||
|
||||
prove-and-verify-aggr-tests:
|
||||
runs-on: large-self-hosted
|
||||
@@ -450,7 +544,7 @@ jobs:
|
||||
run: cargo nextest run --release tests_examples
|
||||
|
||||
python-tests:
|
||||
runs-on: self-hosted
|
||||
runs-on: non-gpu
|
||||
needs: [build, library-tests, docs]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
174
Cargo.lock
generated
174
Cargo.lock
generated
@@ -163,6 +163,54 @@ version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6"
|
||||
|
||||
[[package]]
|
||||
name = "ark-bls12-377"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc41c02c0d18a226947ee9ee023b1d957bdb6a68fc22ac296722935a9fef423c"
|
||||
dependencies = [
|
||||
"ark-ec",
|
||||
"ark-ff 0.3.0",
|
||||
"ark-std 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-bls12-381"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65be532f9dd1e98ad0150b037276cde464c6f371059e6dd02c0222395761f6aa"
|
||||
dependencies = [
|
||||
"ark-ec",
|
||||
"ark-ff 0.3.0",
|
||||
"ark-std 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-bn254"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea691771ebbb28aea556c044e2e5c5227398d840cee0c34d4d20fa8eb2689e8c"
|
||||
dependencies = [
|
||||
"ark-ec",
|
||||
"ark-ff 0.3.0",
|
||||
"ark-std 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ec"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42"
|
||||
dependencies = [
|
||||
"ark-ff 0.3.0",
|
||||
"ark-serialize 0.3.0",
|
||||
"ark-std 0.3.0",
|
||||
"derivative",
|
||||
"num-traits",
|
||||
"rayon",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ff"
|
||||
version = "0.3.0"
|
||||
@@ -246,12 +294,26 @@ dependencies = [
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-poly"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b0f78f47537c2f15706db7e98fe64cc1711dbf9def81218194e17239e53e5aa"
|
||||
dependencies = [
|
||||
"ark-ff 0.3.0",
|
||||
"ark-serialize 0.3.0",
|
||||
"ark-std 0.3.0",
|
||||
"derivative",
|
||||
"hashbrown 0.11.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-serialize"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671"
|
||||
dependencies = [
|
||||
"ark-serialize-derive",
|
||||
"ark-std 0.3.0",
|
||||
"digest 0.9.0",
|
||||
]
|
||||
@@ -267,6 +329,17 @@ dependencies = [
|
||||
"num-bigint",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-serialize-derive"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-std"
|
||||
version = "0.3.0"
|
||||
@@ -275,6 +348,7 @@ checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"rand 0.8.5",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -635,6 +709,9 @@ name = "cc"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
@@ -1012,6 +1089,24 @@ dependencies = [
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuda-config"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ee74643f7430213a1a78320f88649de309b20b80818325575e393f848f79f5d"
|
||||
dependencies = [
|
||||
"glob",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cuda-driver-sys"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d4c552cc0de854877d80bcd1f11db75d42be32962d72a6799b88dcca88fffbd"
|
||||
dependencies = [
|
||||
"cuda-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.10.2"
|
||||
@@ -1213,7 +1308,7 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30"
|
||||
[[package]]
|
||||
name = "ecc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/zkonduit/halo2wrong?branch=ac/chunked-mv-lookup#662abfc029ec236dfbcb6cd47feeccd9d5bfa51d"
|
||||
source = "git+https://github.com/zkonduit/halo2wrong?branch=ac/chunked-mv-lookup#6fa78143319266767e124e242eded0c6905011f4"
|
||||
dependencies = [
|
||||
"integer",
|
||||
"num-bigint",
|
||||
@@ -2086,7 +2181,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "halo2_gadgets"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/zkonduit/halo2?branch=ac/more-informative-errors#ea8f3e1e002ebc840b64a7d57ca6b6c79ae6ce3f"
|
||||
source = "git+https://github.com/zkonduit/halo2#3d7b5e61b3052680ccb279e05bdcc21dd8a8fedf"
|
||||
dependencies = [
|
||||
"arrayvec 0.7.4",
|
||||
"bitvec 1.0.1",
|
||||
@@ -2103,18 +2198,20 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "halo2_proofs"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/zkonduit/halo2?branch=ac/more-informative-errors#ea8f3e1e002ebc840b64a7d57ca6b6c79ae6ce3f"
|
||||
source = "git+https://github.com/zkonduit/halo2#3d7b5e61b3052680ccb279e05bdcc21dd8a8fedf"
|
||||
dependencies = [
|
||||
"blake2b_simd",
|
||||
"env_logger",
|
||||
"ff",
|
||||
"group",
|
||||
"halo2curves 0.1.0",
|
||||
"icicle",
|
||||
"log",
|
||||
"maybe-rayon",
|
||||
"plotters",
|
||||
"rand_chacha",
|
||||
"rand_core 0.6.4",
|
||||
"rustacuda",
|
||||
"sha3 0.9.1",
|
||||
"tabbycat",
|
||||
"tracing",
|
||||
@@ -2123,7 +2220,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "halo2_solidity_verifier"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/alexander-camuto/halo2-solidity-verifier?branch=ac/chunked-lookup-verifier#3b1ef2fa0443ce6caa42a4c2465b86a1e95b0ae3"
|
||||
source = "git+https://github.com/alexander-camuto/halo2-solidity-verifier?branch=ac/chunked-lookup-verifier#b5885027bae560391334f8b63a14c5d377ce6e0e"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"blake2b_simd",
|
||||
@@ -2177,7 +2274,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "halo2wrong"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/zkonduit/halo2wrong?branch=ac/chunked-mv-lookup#662abfc029ec236dfbcb6cd47feeccd9d5bfa51d"
|
||||
source = "git+https://github.com/zkonduit/halo2wrong?branch=ac/chunked-mv-lookup#6fa78143319266767e124e242eded0c6905011f4"
|
||||
dependencies = [
|
||||
"halo2_proofs",
|
||||
"num-bigint",
|
||||
@@ -2361,6 +2458,29 @@ dependencies = [
|
||||
"tokio-native-tls",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icicle"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/ingonyama-zk/icicle.git?branch=rust/large-bucket-factor-msm#2820f43746263fbae7b30a29e08099ea19383c64"
|
||||
dependencies = [
|
||||
"ark-bls12-377",
|
||||
"ark-bls12-381",
|
||||
"ark-bn254",
|
||||
"ark-ec",
|
||||
"ark-ff 0.3.0",
|
||||
"ark-poly",
|
||||
"ark-std 0.3.0",
|
||||
"cc",
|
||||
"hex",
|
||||
"rand 0.8.5",
|
||||
"rustacuda",
|
||||
"rustacuda_core",
|
||||
"rustacuda_derive",
|
||||
"serde",
|
||||
"serde_cbor",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
@@ -2485,7 +2605,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "integer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/zkonduit/halo2wrong?branch=ac/chunked-mv-lookup#662abfc029ec236dfbcb6cd47feeccd9d5bfa51d"
|
||||
source = "git+https://github.com/zkonduit/halo2wrong?branch=ac/chunked-mv-lookup#6fa78143319266767e124e242eded0c6905011f4"
|
||||
dependencies = [
|
||||
"maingate",
|
||||
"num-bigint",
|
||||
@@ -2548,6 +2668,15 @@ version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.64"
|
||||
@@ -2721,7 +2850,7 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
|
||||
[[package]]
|
||||
name = "maingate"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/zkonduit/halo2wrong?branch=ac/chunked-mv-lookup#662abfc029ec236dfbcb6cd47feeccd9d5bfa51d"
|
||||
source = "git+https://github.com/zkonduit/halo2wrong?branch=ac/chunked-mv-lookup#6fa78143319266767e124e242eded0c6905011f4"
|
||||
dependencies = [
|
||||
"halo2wrong",
|
||||
"num-bigint",
|
||||
@@ -4082,6 +4211,35 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e666a5496a0b2186dbcd0ff6106e29e093c15591bde62c20d3842007c6978a09"
|
||||
|
||||
[[package]]
|
||||
name = "rustacuda"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47208516ab5338b592d63560e90eaef405d0ec880347eaf7742d893b0a31e228"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"cuda-driver-sys",
|
||||
"rustacuda_core",
|
||||
"rustacuda_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustacuda_core"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3858b08976dc2f860c5efbbb48cdcb0d4fafca92a6ac0898465af16c0dbe848"
|
||||
|
||||
[[package]]
|
||||
name = "rustacuda_derive"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43ce8670a1a1d0fc2514a3b846dacdb65646f9bd494b6674cfacbb4ce430bd7e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hex"
|
||||
version = "2.1.0"
|
||||
@@ -4511,7 +4669,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "snark-verifier"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/zkonduit/snark-verifier?branch=ac/chunked-mv-lookup#8b866a77560a3a660eba2236153b98e1d442cd67"
|
||||
source = "git+https://github.com/zkonduit/snark-verifier?branch=ac/chunked-mv-lookup#355a35eca27b68a2b70d699e743fc90e402b4012"
|
||||
dependencies = [
|
||||
"ecc",
|
||||
"halo2_proofs",
|
||||
|
||||
@@ -13,8 +13,8 @@ crate-type = ["cdylib", "rlib"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
halo2_gadgets = { git = "https://github.com/zkonduit/halo2", branch= "ac/more-informative-errors" }
|
||||
halo2_proofs = { git = "https://github.com/zkonduit/halo2", branch= "ac/more-informative-errors" }
|
||||
halo2_gadgets = { git = "https://github.com/zkonduit/halo2", ref= "3d7b5e61b3052680ccb279e05bdcc21dd8a8fedf" }
|
||||
halo2_proofs = { git = "https://github.com/zkonduit/halo2", ref= "3d7b5e61b3052680ccb279e05bdcc21dd8a8fedf" }
|
||||
halo2curves = { version = "0.1.0" }
|
||||
rand = { version = "0.8", default_features = false }
|
||||
itertools = { version = "0.10.3", default_features = false }
|
||||
@@ -157,3 +157,4 @@ onnx = ["dep:tract-onnx"]
|
||||
python-bindings = ["pyo3", "pyo3-log", "pyo3-asyncio"]
|
||||
ezkl = ["onnx", "serde", "serde_json", "log", "colored", "env_logger", "tabled/color", "colored_json", "halo2_proofs/circuit-params"]
|
||||
det-prove = []
|
||||
icicle = ["halo2_proofs/icicle_gpu"]
|
||||
|
||||
18
README.md
18
README.md
@@ -96,6 +96,24 @@ maturin develop --release --features python-bindings
|
||||
pip install torch pandas numpy seaborn jupyter onnx kaggle py-solc-x web3 librosa tensorflow keras tf2onnx
|
||||
```
|
||||
|
||||
### GPU Acceleration
|
||||
|
||||
If you have access to NVIDIA GPUs, you can enable acceleration by building with the feature `icicle` and setting the following environment variable:
|
||||
|
||||
```sh
|
||||
export ENABLE_ICICLE_GPU=true
|
||||
```
|
||||
|
||||
GPU acceleration is provided by [Icicle](https://github.com/ingonyama-zk/icicle)
|
||||
|
||||
To go back to running with CPU, the previous environment variable must be **unset** instead of being switch to a value of false:
|
||||
|
||||
```sh
|
||||
unset ENABLE_ICICLE_GPU
|
||||
```
|
||||
|
||||
**NOTE:** Even with the above environment variable set, icicle is disabled for circuits where k <= 8. To change the value of `k` where icicle is enabled, you can set the environment variable `ICICLE_SMALL_K`.
|
||||
|
||||
### repos
|
||||
|
||||
The EZKL project has several libraries and repos.
|
||||
|
||||
@@ -16,6 +16,9 @@ use log::{error, info};
|
||||
use rand::prelude::SliceRandom;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use std::error::Error;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(feature = "icicle")]
|
||||
use std::env;
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
@@ -23,6 +26,12 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let args = Cli::parse();
|
||||
init_logger();
|
||||
banner();
|
||||
#[cfg(feature = "icicle")]
|
||||
if env::var("ENABLE_ICICLE_GPU").is_ok() {
|
||||
info!("Running with ICICLE GPU");
|
||||
} else {
|
||||
info!("Running with CPU");
|
||||
}
|
||||
info!("command: \n {}", &args.as_json()?.to_colored_json_auto()?);
|
||||
let res = run(args).await;
|
||||
match &res {
|
||||
|
||||
@@ -1093,7 +1093,7 @@ impl Model {
|
||||
|
||||
if run_args.output_visibility.is_public() || run_args.output_visibility.is_fixed() {
|
||||
let output_scales = self.graph.get_output_scales();
|
||||
let _ = outputs
|
||||
let res = outputs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, output)| {
|
||||
@@ -1105,6 +1105,11 @@ impl Model {
|
||||
vars.increment_instance_idx();
|
||||
res
|
||||
} else {
|
||||
// if witnessed_outputs is of len less than i error
|
||||
if witnessed_outputs.len() <= i {
|
||||
return Err("you provided insufficient witness values to generate a fixed output".into());
|
||||
}
|
||||
|
||||
assert_eq!(witnessed_outputs[i].len(), output.len());
|
||||
witnessed_outputs[i].clone()
|
||||
};
|
||||
@@ -1115,7 +1120,11 @@ impl Model {
|
||||
Box::new(HybridOp::RangeCheck(tolerance)),
|
||||
)
|
||||
})
|
||||
.collect_vec();
|
||||
.collect::<Result<Vec<_>,_>>();
|
||||
res.map_err(|e| {
|
||||
error!("{}", e);
|
||||
halo2_proofs::plonk::Error::Synthesis
|
||||
})?;
|
||||
}
|
||||
num_rows = thread_safe_region.row();
|
||||
linear_coord = thread_safe_region.linear_coord();
|
||||
|
||||
@@ -314,6 +314,7 @@ mod native_tests {
|
||||
// "hummingbird_decision_tree",
|
||||
];
|
||||
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
const TESTS_AGGR: [&str; 21] = [
|
||||
"1l_mlp",
|
||||
"1l_flatten",
|
||||
@@ -338,6 +339,9 @@ mod native_tests {
|
||||
"1l_max_pool",
|
||||
];
|
||||
|
||||
#[cfg(feature = "icicle")]
|
||||
const TESTS_AGGR: [&str; 3] = ["1l_mlp", "1l_flatten", "1l_average"];
|
||||
|
||||
const TESTS_EVM: [&str; 21] = [
|
||||
"1l_mlp",
|
||||
"1l_flatten",
|
||||
@@ -396,6 +400,7 @@ mod native_tests {
|
||||
use crate::native_tests::kzg_aggr_mock_prove_and_verify;
|
||||
use tempdir::TempDir;
|
||||
|
||||
#[cfg(not(feature="icicle"))]
|
||||
seq!(N in 0..=20 {
|
||||
|
||||
#(#[test_case(TESTS_AGGR[N])])*
|
||||
@@ -418,6 +423,18 @@ mod native_tests {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
#[cfg(feature="icicle")]
|
||||
seq!(N in 0..=2 {
|
||||
#(#[test_case(TESTS_AGGR[N])])*
|
||||
fn kzg_aggr_prove_and_verify_(test: &str) {
|
||||
crate::native_tests::init_binary();
|
||||
let test_dir = TempDir::new(test).unwrap();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(test_dir.path().to_str().unwrap(), test);
|
||||
kzg_aggr_prove_and_verify(path, test.to_string(), "private", "private", "public");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -842,6 +859,7 @@ mod native_tests {
|
||||
env_logger::init();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
kzg_prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, Some(vec![0,1]), true, "single");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testWasm");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
@@ -854,6 +872,7 @@ mod native_tests {
|
||||
env_logger::init();
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
kzg_prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, Some(vec![0,1]), true, "single");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testWasm");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
@@ -1002,6 +1021,7 @@ mod native_tests {
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
let _anvil_child = crate::native_tests::start_anvil(false);
|
||||
kzg_evm_prove_and_verify(path, test.to_string(), "private", "private", "public");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testBrowserEvmVerify");
|
||||
test_dir.close().unwrap();
|
||||
|
||||
@@ -1016,6 +1036,7 @@ mod native_tests {
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
let _anvil_child = crate::native_tests::start_anvil(false);
|
||||
kzg_evm_prove_and_verify(path, test.to_string(), "encrypted", "private", "public");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testBrowserEvmVerify");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
@@ -1027,6 +1048,7 @@ mod native_tests {
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
let mut _anvil_child = crate::native_tests::start_anvil(false);
|
||||
kzg_evm_prove_and_verify(path, test.to_string(), "hashed", "private", "private");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testBrowserEvmVerify");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
@@ -1039,6 +1061,7 @@ mod native_tests {
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
let mut _anvil_child = crate::native_tests::start_anvil(false);
|
||||
kzg_evm_prove_and_verify(path, test.to_string(), "kzgcommit", "private", "public");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testBrowserEvmVerify");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
@@ -1051,6 +1074,7 @@ mod native_tests {
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
let _anvil_child = crate::native_tests::start_anvil(false);
|
||||
kzg_evm_prove_and_verify(path, test.to_string(), "private", "hashed", "public");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testBrowserEvmVerify");
|
||||
test_dir.close().unwrap();
|
||||
|
||||
@@ -1063,6 +1087,7 @@ mod native_tests {
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
let _anvil_child = crate::native_tests::start_anvil(false);
|
||||
kzg_evm_prove_and_verify(path, test.to_string(), "private", "private", "hashed");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testBrowserEvmVerify");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
@@ -1075,6 +1100,7 @@ mod native_tests {
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
let _anvil_child = crate::native_tests::start_anvil(false);
|
||||
kzg_evm_prove_and_verify(path, test.to_string(), "private", "kzgcommit", "public");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testBrowserEvmVerify");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
@@ -1087,6 +1113,7 @@ mod native_tests {
|
||||
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
|
||||
let _anvil_child = crate::native_tests::start_anvil(false);
|
||||
kzg_evm_prove_and_verify(path, test.to_string(), "private", "private", "kzgcommit");
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
run_js_tests(path, test.to_string(), "testBrowserEvmVerify");
|
||||
test_dir.close().unwrap();
|
||||
}
|
||||
@@ -2140,8 +2167,20 @@ mod native_tests {
|
||||
}
|
||||
|
||||
fn build_ezkl() {
|
||||
#[cfg(feature = "icicle")]
|
||||
let args = [
|
||||
"build",
|
||||
"--release",
|
||||
"--bin",
|
||||
"ezkl",
|
||||
"--features",
|
||||
"icicle",
|
||||
];
|
||||
#[cfg(not(feature = "icicle"))]
|
||||
let args = ["build", "--release", "--bin", "ezkl"];
|
||||
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "--release", "--bin", "ezkl"])
|
||||
.args(&args)
|
||||
.status()
|
||||
.expect("failed to execute process");
|
||||
assert!(status.success());
|
||||
|
||||
Reference in New Issue
Block a user