Skip to content

Commit

Permalink
test(benchmark): add fri benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
batzor committed Aug 30, 2024
1 parent 17102eb commit 857f757
Show file tree
Hide file tree
Showing 15 changed files with 744 additions and 1 deletion.
81 changes: 80 additions & 1 deletion Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "493a31da6b3ac2a5605ba241c05d083f25487a1fdd2efcb09d582c8b3be8cba9",
"checksum": "0196cd729d17db7cf65b8594500ed8e7a9f294853aac594160ae042741599e75",
"crates": {
"addchain 0.2.0": {
"name": "addchain",
Expand Down Expand Up @@ -12952,6 +12952,84 @@
},
"license": "MIT OR Apache-2.0"
},
"plonky3_fri_benchmark 0.0.1": {
"name": "plonky3_fri_benchmark",
"version": "0.0.1",
"repository": null,
"targets": [
{
"Library": {
"crate_name": "plonky3_fri_benchmark",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "plonky3_fri_benchmark",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "p3-baby-bear 0.1.3-succinct",
"target": "p3_baby_bear"
},
{
"id": "p3-challenger 0.1.3-succinct",
"target": "p3_challenger"
},
{
"id": "p3-commit 0.1.3-succinct",
"target": "p3_commit"
},
{
"id": "p3-dft 0.1.3-succinct",
"target": "p3_dft"
},
{
"id": "p3-field 0.1.3-succinct",
"target": "p3_field"
},
{
"id": "p3-fri 0.1.3-succinct",
"target": "p3_fri"
},
{
"id": "p3-matrix 0.1.3-succinct",
"target": "p3_matrix"
},
{
"id": "p3-merkle-tree 0.1.3-succinct",
"target": "p3_merkle_tree"
},
{
"id": "p3-poseidon2 0.1.3-succinct",
"target": "p3_poseidon2"
},
{
"id": "p3-symmetric 0.1.3-succinct",
"target": "p3_symmetric"
},
{
"id": "p3-util 0.1.3-succinct",
"target": "p3_util"
},
{
"id": "zkhash 0.2.0",
"target": "zkhash"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.0.1"
},
"license": "MIT OR Apache-2.0"
},
"plonky3_poseidon2_benchmark 0.0.1": {
"name": "plonky3_poseidon2_benchmark",
"version": "0.0.1",
Expand Down Expand Up @@ -21549,6 +21627,7 @@
"halo2_msm_benchmark 0.0.1": "benchmark/msm/halo2",
"horizen_poseidon2_benchmark 0.0.1": "benchmark/poseidon2/horizen",
"plonky3_batch_fft_benchmark 0.0.1": "benchmark/fft_batch/plonky3",
"plonky3_fri_benchmark 0.0.1": "benchmark/fri/plonky3",
"plonky3_poseidon2_benchmark 0.0.1": "benchmark/poseidon2/plonky3",
"tachyon_plonky3 0.0.1": "vendors/plonky3",
"tachyon_rs 0.0.1": "tachyon/rs",
Expand Down
19 changes: 19 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 @@ -7,6 +7,7 @@ members = [
"benchmark/fft/bellman",
"benchmark/fft/halo2",
"benchmark/fft_batch/plonky3",
"benchmark/fri/plonky3",
"benchmark/poseidon/arkworks",
"benchmark/poseidon2/horizen",
"benchmark/poseidon2/plonky3",
Expand Down
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ crates_repository(
"//benchmark/fft/bellman:Cargo.toml",
"//benchmark/fft/halo2:Cargo.toml",
"//benchmark/fft_batch/plonky3:Cargo.toml",
"//benchmark/fri/plonky3:Cargo.toml",
"//benchmark/poseidon/arkworks:Cargo.toml",
"//benchmark/poseidon2/horizen:Cargo.toml",
"//benchmark/poseidon2/plonky3:Cargo.toml",
Expand Down
63 changes: 63 additions & 0 deletions benchmark/fri/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
load(
"//bazel:tachyon_cc.bzl",
"tachyon_cc_binary",
"tachyon_cc_library",
)

tachyon_cc_library(
name = "fri_config",
testonly = True,
srcs = ["fri_config.cc"],
hdrs = ["fri_config.h"],
deps = [
"//benchmark:config",
"//tachyon/base/console",
"//tachyon/base/containers:container_util",
],
)

tachyon_cc_library(
name = "fri_runner",
testonly = True,
hdrs = ["fri_runner.h"],
deps = [
":fri_config",
"//benchmark:simple_reporter",
"//tachyon/base/containers:container_util",
"//tachyon/base/time",
"//tachyon/c/math/matrix",
"//tachyon/crypto/hashes/sponge/poseidon2:poseidon2_horizen_external_matrix",
"//tachyon/math/matrix:matrix_types",
],
)

tachyon_cc_binary(
name = "fri_benchmark",
testonly = True,
srcs = ["fri_benchmark.cc"],
deps = [
":fri_config",
":fri_runner",
"//benchmark:simple_reporter",
"//benchmark/fri/plonky3",
"//tachyon/base:profiler",
"//tachyon/c/math/finite_fields/baby_bear",
"//tachyon/crypto/challenger:duplex_challenger",
"//tachyon/crypto/commitments/fri:fri_config",
"//tachyon/crypto/commitments/fri:two_adic_fri",
"//tachyon/crypto/commitments/fri:two_adic_multiplicative_coset",
"//tachyon/crypto/commitments/merkle_tree/field_merkle_tree:extension_field_merkle_tree_mmcs",
"//tachyon/crypto/commitments/merkle_tree/field_merkle_tree:field_merkle_tree_mmcs",
"//tachyon/crypto/hashes/sponge:padding_free_sponge",
"//tachyon/crypto/hashes/sponge:truncated_permutation",
"//tachyon/crypto/hashes/sponge/poseidon2",
"//tachyon/crypto/hashes/sponge/poseidon2:poseidon2_horizen_external_matrix",
"//tachyon/math/finite_fields:packed_field_traits_forward",
"//tachyon/math/finite_fields/baby_bear:baby_bear4",
"//tachyon/math/finite_fields/baby_bear:packed_baby_bear4",
"//tachyon/math/finite_fields/baby_bear:poseidon2",
"//tachyon/math/matrix:matrix_types",
"//tachyon/math/polynomials/univariate:radix2_evaluation_domain",
"@com_google_absl//absl/strings",
],
)
48 changes: 48 additions & 0 deletions benchmark/fri/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Fri PCS Benchmark

## CPU

```bash
Run on 13th Gen Intel(R) Core(TM) i9-13900K (32 X 5500 MHz CPU s)
CPU Caches:
L1 Data 48 KiB (x16)
L1 Instruction 32 KiB (x16)
L2 Unified 2048 KiB (x16)
L3 Unified 36864 KiB (x1)

Run on Apple M3 Pro (12 X 4050 MHz)
CPU Caches:
L1 Data 64 KiB (x12)
L1 Instruction 128 KiB (x12)
L2 Unified 4096 KiB (x12)
```

```shell
bazel run -c opt --//:has_openmp --//:has_rtti --//:has_matplotlib //benchmark/fri:fri_benchmark -- -k 18 -k 19 -k 20 -k 21 -k 22 --batch_size 100 --input_num 4 --log_blowup 2 --vendor plonky3 --check_results
```

## On Intel i9-13900K

| Exponent | Tachyon | Plonky3 |
| :------- | ----------- | -------- |
| 18 | **2.27057** | 2.54643 |
| 19 | **3.82310** | 5.18472 |
| 20 | **6.57053** | 10.2886 |
| 21 | **11.6738** | 20.8495 |
| 22 | **23.3768** | 43.0323 |

![image](/benchmark/fri/fri_benchmark_ubuntu_i9.png)

## On Mac M3 Pro

WARNING: On Mac M3, high degree tests are not feasible due to memory constraints.

| Exponent | Tachyon | Plonky3 |
| :------- | ------- | ------------ |
| 18 | 3.68509 | **1.39107** |
| 19 | 7.37079 | **2.76483** |
| 20 | 14.9081 | **5.62375** |
| 21 | 30.3153 | **11.8295** |
| 22 | 64.8022 | **25.4490** |

![image](/benchmark/fri/fri_benchmark_mac_m3.png)
Loading

0 comments on commit 857f757

Please sign in to comment.