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

Implement TestLessThanOrEqualAddress y EvalCircuit Hints #1843

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

FrancoGiachetta
Copy link
Contributor

@FrancoGiachetta FrancoGiachetta commented Sep 19, 2024

Implement TestLessThanOrEqual y EvalCircuit Hints

Description

This PR adds the implementations for EvalCircuit and TestLessThanOrEqual. It also changes a little the bytecode that is executed. Before, the it final bytecode consisted of the entry_code, the casm instructions and the footer. Now, due to the way the hint is implemented, the segment values are appended after the casm instructions and before the footer. This is because these are values the operands that will be used to evaluate the circuit's operations, which referenced by the cells in the data segment.

Relates to #1836

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.
    • CHANGELOG has been updated.

Copy link

github-actions bot commented Sep 19, 2024

**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 ± σ):     30.037 s ±  0.087 s    [User: 29.276 s, System: 0.759 s]
  Range (min … max):   29.975 s … 30.099 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     30.612 s ±  0.019 s    [User: 29.790 s, System: 0.820 s]
  Range (min … max):   30.598 s … 30.626 s    2 runs
 
Summary
  'hyper_threading_main threads: 1' ran
    1.02 ± 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 ± σ):     16.745 s ±  0.013 s    [User: 29.294 s, System: 0.820 s]
  Range (min … max):   16.736 s … 16.755 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     16.524 s ±  0.006 s    [User: 29.094 s, System: 0.808 s]
  Range (min … max):   16.520 s … 16.528 s    2 runs
 
Summary
  'hyper_threading_pr threads: 2' ran
    1.01 ± 0.00 times faster than 'hyper_threading_main 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 ± σ):     11.837 s ±  0.434 s    [User: 41.205 s, System: 0.944 s]
  Range (min … max):   11.530 s … 12.144 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     11.688 s ±  0.534 s    [User: 41.200 s, System: 0.973 s]
  Range (min … max):   11.310 s … 12.065 s    2 runs
 
Summary
  'hyper_threading_pr threads: 4' ran
    1.01 ± 0.06 times faster than 'hyper_threading_main 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 ± σ):     11.216 s ±  0.028 s    [User: 41.771 s, System: 0.960 s]
  Range (min … max):   11.196 s … 11.235 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     11.410 s ±  0.017 s    [User: 41.178 s, System: 1.005 s]
  Range (min … max):   11.398 s … 11.422 s    2 runs
 
Summary
  'hyper_threading_main threads: 6' ran
    1.02 ± 0.00 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 ± σ):     11.272 s ±  0.103 s    [User: 41.835 s, System: 0.958 s]
  Range (min … max):   11.199 s … 11.345 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     11.405 s ±  0.225 s    [User: 41.357 s, System: 1.000 s]
  Range (min … max):   11.246 s … 11.564 s    2 runs
 
Summary
  'hyper_threading_main threads: 8' ran
    1.01 ± 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 ± σ):     11.215 s ±  0.230 s    [User: 42.217 s, System: 1.067 s]
  Range (min … max):   11.052 s … 11.378 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     11.015 s ±  0.034 s    [User: 42.100 s, System: 1.029 s]
  Range (min … max):   10.990 s … 11.039 s    2 runs
 
Summary
  'hyper_threading_pr threads: 16' ran
    1.02 ± 0.02 times faster than 'hyper_threading_main threads: 16'


Copy link

github-actions bot commented Sep 19, 2024

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.402 ± 0.011 2.386 2.417 1.00
head big_factorial 2.418 ± 0.107 2.359 2.661 1.01 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.346 ± 0.035 2.320 2.430 1.01 ± 0.02
head big_fibonacci 2.320 ± 0.038 2.291 2.408 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 9.002 ± 0.575 8.421 10.238 1.05 ± 0.07
head blake2s_integration_benchmark 8.553 ± 0.103 8.418 8.781 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.494 ± 0.021 2.466 2.522 1.01 ± 0.02
head compare_arrays_200000 2.464 ± 0.050 2.421 2.598 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.629 ± 0.007 1.620 1.642 1.00 ± 0.02
head dict_integration_benchmark 1.622 ± 0.036 1.598 1.719 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.376 ± 0.024 1.352 1.433 1.00
head field_arithmetic_get_square_benchmark 1.385 ± 0.045 1.347 1.483 1.01 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.679 ± 0.180 8.500 9.005 1.00
head integration_builtins 8.790 ± 0.198 8.653 9.284 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.910 ± 0.159 8.734 9.197 1.00 ± 0.02
head keccak_integration_benchmark 8.895 ± 0.115 8.734 9.012 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.499 ± 0.015 2.481 2.518 1.02 ± 0.01
head linear_search 2.455 ± 0.020 2.424 2.489 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.712 ± 0.033 1.688 1.798 1.03 ± 0.02
head math_cmp_and_pow_integration_benchmark 1.667 ± 0.008 1.660 1.683 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.660 ± 0.018 1.646 1.699 1.03 ± 0.01
head math_integration_benchmark 1.618 ± 0.005 1.609 1.622 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.388 ± 0.009 1.380 1.410 1.02 ± 0.01
head memory_integration_benchmark 1.365 ± 0.017 1.352 1.410 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.780 ± 0.050 1.744 1.911 1.02 ± 0.04
head operations_with_data_structures_benchmarks 1.750 ± 0.039 1.729 1.841 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 575.3 ± 8.0 569.4 596.4 1.01 ± 0.02
head pedersen 568.7 ± 8.1 562.9 590.1 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 690.0 ± 4.8 681.2 695.7 1.01 ± 0.01
head poseidon_integration_benchmark 680.6 ± 2.6 676.9 684.3 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.995 ± 0.034 1.960 2.058 1.01 ± 0.02
head secp_integration_benchmark 1.980 ± 0.009 1.967 1.996 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 702.0 ± 5.7 696.0 712.5 1.03 ± 0.02
head set_integration_benchmark 678.8 ± 8.2 671.8 700.5 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.803 ± 0.064 4.710 4.906 1.01 ± 0.02
head uint256_integration_benchmark 4.739 ± 0.045 4.674 4.789 1.00

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 95.10204% with 12 lines in your changes missing coverage. Please review.

Project coverage is 96.33%. Comparing base (3fb0344) to head (a3abf1f).

Files with missing lines Patch % Lines
...c/hint_processor/cairo_1_hint_processor/circuit.rs 95.23% 9 Missing ⚠️
...processor/cairo_1_hint_processor/hint_processor.rs 90.90% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1843    +/-   ##
========================================
  Coverage   96.32%   96.33%            
========================================
  Files         102      102            
  Lines       40381    40618   +237     
========================================
+ Hits        38899    39129   +230     
- Misses       1482     1489     +7     

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

@FrancoGiachetta FrancoGiachetta changed the title Implement TestLessThanOrEqual y EvalCircuit Hints Implement TestLessThanOrEqualAddress y EvalCircuit Hints Sep 30, 2024
@FrancoGiachetta FrancoGiachetta marked this pull request as ready for review October 1, 2024 12:50
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.

2 participants