lambdaclass / cairo-vm

cairo-vm is a Rust implementation of the Cairo VM. Cairo (CPU Algebraic Intermediate Representation) is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly without the need for this party to re-execute the same program.
https://lambdaclass.github.io/cairo-vm
Apache License 2.0
485 stars 133 forks source link

Implement running from `CairoPie` #1720

Closed fmoletta closed 2 months ago

fmoletta commented 2 months ago

Adds the ability to run Cairo PIEs via cairo_run_pie function

Follow up work:

github-actions[bot] commented 2 months ago
**Hyper Thereading Benchmark results**

hyperfine -r 2 -n "hyper_threading_main threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_main' -n "hyper_threading_pr threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 1
  Time (mean ± σ):     23.609 s ±  0.008 s    [User: 22.909 s, System: 0.700 s]
  Range (min … max):   23.604 s … 23.615 s    2 runs

Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     29.902 s ±  0.051 s    [User: 29.131 s, System: 0.769 s]
  Range (min … max):   29.866 s … 29.938 s    2 runs

Summary
  'hyper_threading_main threads: 1' ran
    1.27 ± 0.00 times faster than 'hyper_threading_pr threads: 1'

hyperfine -r 2 -n "hyper_threading_main threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_main' -n "hyper_threading_pr threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 2
  Time (mean ± σ):     12.299 s ±  0.006 s    [User: 23.207 s, System: 0.690 s]
  Range (min … max):   12.294 s … 12.303 s    2 runs

Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     16.070 s ±  0.081 s    [User: 29.739 s, System: 0.704 s]
  Range (min … max):   16.013 s … 16.128 s    2 runs

Summary
  'hyper_threading_main threads: 2' ran
    1.31 ± 0.01 times faster than 'hyper_threading_pr threads: 2'

hyperfine -r 2 -n "hyper_threading_main threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_main' -n "hyper_threading_pr threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 4
  Time (mean ± σ):      9.931 s ±  0.312 s    [User: 34.911 s, System: 0.935 s]
  Range (min … max):    9.710 s … 10.151 s    2 runs

Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     11.525 s ±  0.513 s    [User: 40.303 s, System: 0.890 s]
  Range (min … max):   11.162 s … 11.888 s    2 runs

Summary
  'hyper_threading_main threads: 4' ran
    1.16 ± 0.06 times faster than 'hyper_threading_pr threads: 4'

hyperfine -r 2 -n "hyper_threading_main threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_main' -n "hyper_threading_pr threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 6
  Time (mean ± σ):      9.632 s ±  0.282 s    [User: 35.563 s, System: 1.004 s]
  Range (min … max):    9.433 s …  9.831 s    2 runs

Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     11.096 s ±  0.089 s    [User: 40.823 s, System: 0.938 s]
  Range (min … max):   11.033 s … 11.159 s    2 runs

Summary
  'hyper_threading_main threads: 6' ran
    1.15 ± 0.03 times faster than 'hyper_threading_pr threads: 6'

hyperfine -r 2 -n "hyper_threading_main threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_main' -n "hyper_threading_pr threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 8
  Time (mean ± σ):      9.539 s ±  0.041 s    [User: 35.441 s, System: 0.981 s]
  Range (min … max):    9.510 s …  9.569 s    2 runs

Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.917 s ±  0.170 s    [User: 40.841 s, System: 0.989 s]
  Range (min … max):   10.797 s … 11.037 s    2 runs

Summary
  'hyper_threading_main threads: 8' ran
    1.14 ± 0.02 times faster than 'hyper_threading_pr threads: 8'

hyperfine -r 2 -n "hyper_threading_main threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_main' -n "hyper_threading_pr threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 16
  Time (mean ± σ):      9.700 s ±  0.199 s    [User: 35.638 s, System: 1.066 s]
  Range (min … max):    9.559 s …  9.840 s    2 runs

Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.986 s ±  0.230 s    [User: 40.835 s, System: 1.058 s]
  Range (min … max):   10.823 s … 11.149 s    2 runs

Summary
  'hyper_threading_main threads: 16' ran
    1.13 ± 0.03 times faster than 'hyper_threading_pr threads: 16'
github-actions[bot] commented 2 months ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 1.935 ± 0.016 1.914 1.971 1.00
head big_factorial 2.395 ± 0.034 2.366 2.487 1.24 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 1.864 ± 0.024 1.848 1.929 1.00
head big_fibonacci 2.334 ± 0.024 2.307 2.397 1.25 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 6.508 ± 0.161 6.399 6.940 1.00
head blake2s_integration_benchmark 8.708 ± 0.260 8.531 9.220 1.34 ± 0.05
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 1.935 ± 0.032 1.910 2.022 1.00
head compare_arrays_200000 2.449 ± 0.044 2.402 2.570 1.27 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.325 ± 0.007 1.315 1.338 1.00
head dict_integration_benchmark 1.540 ± 0.020 1.530 1.595 1.16 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.173 ± 0.016 1.160 1.215 1.00
head field_arithmetic_get_square_benchmark 1.442 ± 0.033 1.415 1.522 1.23 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 6.589 ± 0.086 6.480 6.753 1.00
head integration_builtins 8.726 ± 0.306 8.574 9.584 1.32 ± 0.05
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 6.904 ± 0.307 6.637 7.412 1.00
head keccak_integration_benchmark 8.923 ± 0.219 8.791 9.530 1.29 ± 0.07
Command Mean [s] Min [s] Max [s] Relative
base linear_search 1.961 ± 0.010 1.944 1.978 1.00
head linear_search 2.507 ± 0.045 2.456 2.578 1.28 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.718 ± 0.029 1.694 1.779 1.00
head math_cmp_and_pow_integration_benchmark 1.919 ± 0.016 1.905 1.962 1.12 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.482 ± 0.016 1.471 1.521 1.00
head math_integration_benchmark 1.699 ± 0.023 1.678 1.755 1.15 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.157 ± 0.035 1.135 1.230 1.00
head memory_integration_benchmark 1.359 ± 0.018 1.343 1.392 1.18 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.812 ± 0.055 1.777 1.934 1.00
head operations_with_data_structures_benchmarks 1.984 ± 0.013 1.968 2.011 1.10 ± 0.03
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 508.5 ± 2.0 506.1 511.5 1.00
head pedersen 575.9 ± 14.9 564.8 615.1 1.13 ± 0.03
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 963.4 ± 4.0 958.9 972.8 1.00
head poseidon_integration_benchmark 1011.6 ± 3.8 1006.9 1017.8 1.05 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.774 ± 0.016 1.756 1.804 1.00
head secp_integration_benchmark 2.002 ± 0.037 1.984 2.106 1.13 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 680.3 ± 7.1 674.5 696.1 1.00
head set_integration_benchmark 769.6 ± 2.7 766.4 776.0 1.13 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 3.916 ± 0.207 3.760 4.301 1.00
head uint256_integration_benchmark 4.792 ± 0.013 4.769 4.813 1.22 ± 0.06
codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 89.63964% with 23 lines in your changes are missing coverage. Please review.

Project coverage is 94.78%. Comparing base (3f1f9ec) to head (38b9ff8).

Files Patch % Lines
vm/src/vm/runners/cairo_pie.rs 81.81% 20 Missing :warning:
vm/src/cairo_run.rs 96.00% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1720 +/- ## ======================================== Coverage 94.78% 94.78% ======================================== Files 101 101 Lines 38509 38731 +222 ======================================== + Hits 36499 36711 +212 - Misses 2010 2020 +10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.