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

feat(icicle): Add icicle MSM support #503

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
67 changes: 67 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ members = [

[features]
host = ["jolt-sdk/host"]
icicle = ["jolt-core/icicle"]

[lib]
path = "./src/lib.rs"
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ Examples in the [`examples`](./examples/) directory can be run using e.g.

```cargo run --release -p sha2-chain```

## CUDA Support

JOLT supports CUDA acceleration via [icicle](https://github.com/ingonyama-zk/icicle-jolt).

Dependencies:
1. Install [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit)
2. Install [CMake](https://cmake.org/)

Now you may build Jolt with CUDA acceleration using the `--features icicle` flag.

### Build

```cargo build -p jolt-core --features icicle```

### Bench

```
# Set the icicle backend path - this won't be needed in the future
export ICICLE_BACKEND_INSTALL_DIR=$(pwd)/target/debug/deps/icicle/lib/backend
cargo bench --bench msm_batch --no-fail-fast -p jolt-core --features icicle
```

Note - NVIDIA doesn't support cross compilation on MacOS. Only Windows or Linux.

## Performance profiling

Expand Down
3 changes: 3 additions & 0 deletions examples/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "alloc-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/collatz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "collatz-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/fibonacci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "fibonacci-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
2 changes: 2 additions & 0 deletions examples/muldiv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ edition = "2021"
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "muldiv-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/multi-function/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "multi-function-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
5 changes: 4 additions & 1 deletion examples/overflow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ edition = "2021"

[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "overflow-guest", path = "./guest" }
guest = { package = "overflow-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/sha2-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "sha2-chain-guest", path = "./guest" }

hex = "0.4.3"

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/sha2-ex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "sha2-guest", path = "./guest" }

hex = "0.4.3"

[features]
icicle = ["jolt-sdk/icicle"]
4 changes: 3 additions & 1 deletion examples/sha3-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "sha3-chain-guest", path = "./guest" }
hex = "0.4.3"

hex = "0.4.3"
[features]
icicle = ["jolt-sdk/icicle"]
4 changes: 3 additions & 1 deletion examples/sha3-ex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "sha3-guest", path = "./guest" }

hex = "0.4.3"

[features]
icicle = ["jolt-sdk/icicle"]
3 changes: 3 additions & 0 deletions examples/stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
jolt-sdk = { path = "../../jolt-sdk", features = ["host"] }
guest = { package = "stdlib-guest", path = "./guest" }

[features]
icicle = ["jolt-sdk/icicle"]
36 changes: 25 additions & 11 deletions jolt-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ repository = "https://github.com/a16z/jolt"
license-file = "LICENSE"
keywords = ["SNARK", "cryptography", "proofs"]

[features]
default = [
"ark-ec/parallel",
"ark-ff/parallel",
"ark-std/parallel",
"ark-ff/asm",
"host",
"rayon",
]
host = ["dep:reqwest", "dep:tokio"]
icicle = ["default", "dep:icicle-runtime", "dep:icicle-core", "dep:icicle-bn254"]

[dependencies]
ark-bn254 = "0.4.0"
ark-ec = { version = "0.4.2", default-features = false }
Expand Down Expand Up @@ -65,6 +77,7 @@ bytemuck = "1.19.0"
tokio = { version = "1.38.0", optional = true }
alloy-primitives = "0.7.6"
alloy-sol-types = "0.7.6"
once_cell = "1.19.0"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
Expand Down Expand Up @@ -93,23 +106,24 @@ harness = false
name = "compute_cubic"
harness = false

[[bench]]
name = "msm"
harness = false

[[bench]]
name = "msm_batch"
harness = false

[lib]
name = "jolt_core"
path = "src/lib.rs"

[features]
default = [
"ark-ec/parallel",
"ark-ff/parallel",
"ark-std/parallel",
"ark-ff/asm",
"host",
"rayon",
]
host = ["dep:reqwest", "dep:tokio"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
icicle-runtime = { git = "https://github.com/ingonyama-zk/icicle-jolt.git", features = ["cuda_backend"], rev = "ed93e21", optional = true }
icicle-core = { git = "https://github.com/ingonyama-zk/icicle-jolt.git", rev = "ed93e21", optional = true }
icicle-bn254 = { git = "https://github.com/ingonyama-zk/icicle-jolt.git", features = ["cuda_backend"], rev = "ed93e21", optional = true }
memory-stats = "1.0.0"
sys-info = "0.9.1"
tokio = { version = "1.38.0", optional = true, features = ["rt-multi-thread"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion jolt-core/benches/iai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn eval_poly_setup<F: JoltField>(size: usize) -> (DensePolynomial<F>, Vec<F>) {
#[library_benchmark]
#[bench::long(msm_setup::<G1Projective>(4096))]
fn bench_msm<G: CurveGroup>(input: (Vec<G>, Vec<G::ScalarField>)) -> G {
black_box(VariableBaseMSM::msm(&G::normalize_batch(&input.0), &input.1).unwrap())
black_box(VariableBaseMSM::msm(&G::normalize_batch(&input.0), None, &input.1).unwrap())
}

#[library_benchmark]
Expand Down
Loading
Loading