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

Cairo1 proof mode #1517

Merged
merged 21 commits into from
Dec 20, 2023
Merged

Cairo1 proof mode #1517

merged 21 commits into from
Dec 20, 2023

Conversation

MauroToscano
Copy link
Contributor

@MauroToscano MauroToscano commented Dec 18, 2023

Cairo1 proof mode

Description

This PR adds an initial working version of Cairo1 proof mode

  • Adds a proof mode header, working very similarly to the Cairo0 proof mode header to the code
  • Makes some small changes to SW Cairo header, so the pointers to the segment are properly aligned now that there are two extra instructions
  • Adds a RunnerMode to select from ExecutionMode, ProofModeCanonical, and ProofModeCairo1
  • Adds a test for dictionaries in cairo1, since they work a bit different in the headers and wasn't being tested
  • Reduces the number of iterations of the sample program to 100 so Cairo1 tests run faster

In the future information should be added so [fp - 2] = fp can be enforced

@MauroToscano MauroToscano marked this pull request as draft December 19, 2023 21:04
Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (8a2ef24) 96.82% compared to head (d777b30) 96.92%.

Files Patch % Lines
vm/src/vm/runners/cairo_runner.rs 97.43% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1517      +/-   ##
==========================================
+ Coverage   96.82%   96.92%   +0.10%     
==========================================
  Files          96       96              
  Lines       39744    39818      +74     
==========================================
+ Hits        38482    38594     +112     
+ Misses       1262     1224      -38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Dec 19, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.832 ± 0.032 2.792 2.897 1.00
head big_factorial 2.863 ± 0.022 2.841 2.911 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.433 ± 0.013 2.406 2.449 1.00
head big_fibonacci 2.434 ± 0.012 2.409 2.448 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.046 ± 0.060 6.988 7.181 1.00 ± 0.02
head blake2s_integration_benchmark 7.036 ± 0.111 6.931 7.293 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.541 ± 0.026 2.509 2.592 1.00
head compare_arrays_200000 2.549 ± 0.029 2.528 2.626 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.735 ± 0.010 1.723 1.750 1.00
head dict_integration_benchmark 1.736 ± 0.011 1.725 1.759 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.201 ± 0.017 1.182 1.243 1.00 ± 0.02
head field_arithmetic_get_square_benchmark 1.198 ± 0.009 1.184 1.214 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.037 ± 0.182 6.932 7.399 1.01 ± 0.03
head integration_builtins 6.981 ± 0.090 6.902 7.133 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.096 ± 0.037 7.051 7.174 1.00
head keccak_integration_benchmark 7.193 ± 0.187 7.066 7.674 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.558 ± 0.019 2.536 2.599 1.00
head linear_search 2.604 ± 0.101 2.549 2.889 1.02 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.723 ± 0.009 1.710 1.740 1.01 ± 0.01
head math_cmp_and_pow_integration_benchmark 1.710 ± 0.017 1.692 1.751 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.654 ± 0.011 1.639 1.681 1.00
head math_integration_benchmark 1.656 ± 0.013 1.634 1.672 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.446 ± 0.005 1.436 1.453 1.00
head memory_integration_benchmark 1.461 ± 0.006 1.452 1.471 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.593 ± 0.020 1.570 1.632 1.00
head operations_with_data_structures_benchmarks 1.593 ± 0.009 1.582 1.605 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 622.0 ± 1.3 619.7 623.8 1.00
head pedersen 623.0 ± 5.0 618.1 633.6 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.215 ± 0.006 1.206 1.228 1.00
head poseidon_integration_benchmark 1.218 ± 0.005 1.213 1.227 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.138 ± 0.015 2.117 2.162 1.00 ± 0.01
head secp_integration_benchmark 2.130 ± 0.013 2.117 2.153 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.212 ± 0.010 1.200 1.236 1.00 ± 0.01
head set_integration_benchmark 1.212 ± 0.006 1.204 1.223 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.383 ± 0.039 4.339 4.468 1.00 ± 0.01
head uint256_integration_benchmark 4.370 ± 0.037 4.331 4.454 1.00

@MauroToscano MauroToscano marked this pull request as ready for review December 20, 2023 14:33
Copy link
Member

@fmoletta fmoletta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a command line argument to set the run to proof_mode instead of just running proof_mode by default

@pefontana
Copy link
Member

should add a command line argument to set the run to proof_mode instead of just running proof_mode by default

Yes @fmoletta, that is the plan
We talked with Mauro, first we can merge this to run always on proof mode, and then we can make a refactor so the user can decide if he wants to execute in proof mode or not

@pefontana pefontana added this pull request to the merge queue Dec 20, 2023
Merged via the queue into main with commit 070aeb9 Dec 20, 2023
59 checks passed
@pefontana pefontana deleted the cairo1_proof_mode_final branch December 20, 2023 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants