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

Add Icicle GPU acceleration to Plonk BN254 Prover #7

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f61cc6d
Initial integration of Icicle GPU acceleration library for groth16 wi…
jeremyfelder Jul 18, 2023
b6efd94
Remove icicle wrapper and update dependency to use iciclegnark repo f…
jeremyfelder Sep 14, 2023
0fe1afc
Add infinity point and corresponding scalar removals for KRS MSM
jeremyfelder Sep 21, 2023
d7d3218
Fix order of MSMs
jeremyfelder Sep 26, 2023
c0e5994
Add hardware debug log tag
jeremyfelder Sep 26, 2023
7aec044
Update gpu files with changes from upstream
jeremyfelder Sep 27, 2023
a5041a0
Small error handling
jeremyfelder Sep 27, 2023
005bc9d
Remove direct icicle dependency and use iciclegnark for all icicle op…
jeremyfelder Oct 2, 2023
ba152dc
Fix generator prove file to include hardware log attribute
jeremyfelder Oct 2, 2023
f5f9b69
Add additional comments on code
jeremyfelder Oct 15, 2023
e32162b
Add documentation in README for using icicle gpu library
jeremyfelder Oct 15, 2023
03d952a
Update with upstream changes
jeremyfelder Oct 15, 2023
943d959
Update with upstream
jeremyfelder Nov 1, 2023
9dfc49e
Update prove with latest updates, tidy mod file
jeremyfelder Nov 1, 2023
1544bf4
Use left shift instead of pow 2
jeremyfelder Nov 1, 2023
86dfc0b
Use bits.Len instead of Floor(Log2)
jeremyfelder Nov 1, 2023
5b931f0
Change buildtag to icicle instead of gpu
jeremyfelder Nov 1, 2023
a12647f
Merge branch 'consensys-master'
jeremyfelder Nov 1, 2023
88f743e
refactor: init prover option at switch
ivokub Nov 2, 2023
edbf98d
refactor: change logging description
ivokub Nov 2, 2023
8a226e7
feat: implement ICICLE prover option
ivokub Nov 2, 2023
eacf521
refactor: move icicle backend to separate package
ivokub Nov 2, 2023
2b82265
feat: use icicle backend when has tag
ivokub Nov 2, 2023
19b5866
chore: revert unified option generation
ivokub Nov 2, 2023
3b9f229
chore: remove icicle build tag
ivokub Nov 2, 2023
6d64b53
feat: make icicle proving optional
ivokub Nov 2, 2023
18d8ae1
test: add marshal test
ivokub Nov 2, 2023
025a150
test: add reverse marshal test
ivokub Nov 2, 2023
41458ca
chore: remove icicle build tag
ivokub Nov 2, 2023
1f98897
Update readme for toggling on and off icicle acceleration
jeremyfelder Nov 5, 2023
d884130
refactor
bigsky77 Feb 4, 2024
1935a01
add logging
bigsky77 Feb 4, 2024
e6b8c96
impliment second batch apply (works!)
bigsky77 Feb 5, 2024
8ddcc5b
batch apply ntt works
bigsky77 Feb 5, 2024
fbfcf8d
batch apply fft works
bigsky77 Feb 6, 2024
fe08535
update to import from kzg lib
bigsky77 Feb 7, 2024
57d9c35
update for fast ntt(broken)
bigsky77 Feb 7, 2024
b5f55ff
ntt done
bigsky77 Feb 7, 2024
83d72ee
move ntt polys to device earlier
bigsky77 Feb 7, 2024
545df18
refactor scale back fft
bigsky77 Feb 7, 2024
421732a
remove kzg.go
bigsky77 Feb 7, 2024
21c2f7d
add wait group to batchApply
bigsky77 Feb 8, 2024
828e6ec
update scaling vector to device pointers
bigsky77 Feb 11, 2024
a1f7ff5
remove async waitgroup
bigsky77 Feb 12, 2024
e3122a8
add debug to first batch apply
bigsky77 Feb 12, 2024
1fcc25d
add debug to second batch apply
bigsky77 Feb 12, 2024
981d9ea
add debug to third batch apply
bigsky77 Feb 12, 2024
7a15cd0
run shifted opening on cpu
bigsky77 Feb 12, 2024
185cbad
add log to ZShiftOpening
bigsky77 Feb 12, 2024
7efe778
debug batch open
bigsky77 Feb 12, 2024
bd486f6
add wait to LRO commitment
bigsky77 Feb 12, 2024
71cabd5
remove old debug statements
bigsky77 Feb 12, 2024
afc5e1e
add async back to wait group
bigsky77 Feb 12, 2024
2828af0
lock cuda threads
bigsky77 Feb 12, 2024
6306078
add wait group
bigsky77 Feb 12, 2024
8e2fd57
move close outside of waitgroup
bigsky77 Feb 12, 2024
99db1d6
run last batch apply on cpu
bigsky77 Feb 12, 2024
9b5a90f
update to correct icicle gnark
bigsky77 Feb 12, 2024
b0dc9bf
remove wg
bigsky77 Feb 12, 2024
3ae088e
working NTT and batch apply
bigsky77 Feb 12, 2024
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
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,32 @@ func main() {

```

### GPU Support

#### Icicle Library

The following schemes and curves support experimental use of Ingomyama's Icicle GPU library for low level zk-SNARK primitives such as MSM, NTT, and polynomial operations:

- [x] [Groth16](https://eprint.iacr.org/2016/260)

instantiated with the following curve(s)

- [x] BN254

To use GPUs, add the `icicle` buildtag to your build/run commands, e.g. `go run -tags=icicle main.go`.

You can then toggle on or off icicle acceleration by providing the `WithIcicleAcceleration` backend ProverOption:

```go
// toggle on
proofIci, err := groth16.Prove(ccs, pk, secretWitness, backend.WithIcicleAcceleration())

// toggle off
proof, err := groth16.Prove(ccs, pk, secretWitness)
```

For more information about prerequisites see the [Icicle repo](https://github.com/ingonyama-zk/icicle).

## Citing

If you use `gnark` in your research a citation would be appreciated.
Expand Down
14 changes: 14 additions & 0 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type ProverConfig struct {
HashToFieldFn hash.Hash
ChallengeHash hash.Hash
KZGFoldingHash hash.Hash
Accelerator string
}

// NewProverConfig returns a default ProverConfig with given prover options opts
Expand Down Expand Up @@ -122,6 +123,19 @@ func WithProverKZGFoldingHashFunction(hFunc hash.Hash) ProverOption {
}
}

// WithIcicleAcceleration requests to use [ICICLE] GPU proving backend for the
// prover. This option requires that the program is compiled with `icicle` build
// tag and the ICICLE dependencies are properly installed. See [ICICLE] for
// installation description.
//
// [ICICLE]: https://github.com/ingonyama-zk/icicle
func WithIcicleAcceleration() ProverOption {
return func(pc *ProverConfig) error {
pc.Accelerator = "icicle"
return nil
}
}

// VerifierOption defines option for altering the behavior of the verifier. See
// the descriptions of functions returning instances of this type for
// implemented options.
Expand Down
2 changes: 1 addition & 1 deletion backend/groth16/bls12-377/prove.go

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

2 changes: 1 addition & 1 deletion backend/groth16/bls12-381/prove.go

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

2 changes: 1 addition & 1 deletion backend/groth16/bls24-315/prove.go

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

2 changes: 1 addition & 1 deletion backend/groth16/bls24-317/prove.go

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

2 changes: 2 additions & 0 deletions backend/groth16/bn254/icicle/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package icicle_bn254 implements ICICLE acceleration for BN254 Groth16 backend.
package icicle_bn254
Loading
Loading