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 18 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 ± σ):     29.920 s ±  0.052 s    [User: 29.161 s, System: 0.757 s]
  Range (min … max):   29.884 s … 29.957 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     29.625 s ±  0.015 s    [User: 28.864 s, System: 0.759 s]
  Range (min … max):   29.614 s … 29.636 s    2 runs
 
Summary
  'hyper_threading_pr threads: 1' ran
    1.01 ± 0.00 times faster than 'hyper_threading_main 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.578 s ±  0.107 s    [User: 29.220 s, System: 0.762 s]
  Range (min … max):   16.502 s … 16.654 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     16.615 s ±  0.164 s    [User: 29.097 s, System: 0.788 s]
  Range (min … max):   16.499 s … 16.731 s    2 runs
 
Summary
  'hyper_threading_main threads: 2' ran
    1.00 ± 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 ± σ):     11.656 s ±  0.486 s    [User: 41.050 s, System: 0.925 s]
  Range (min … max):   11.313 s … 12.000 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     11.615 s ±  0.524 s    [User: 40.891 s, System: 0.920 s]
  Range (min … max):   11.244 s … 11.986 s    2 runs
 
Summary
  'hyper_threading_pr threads: 4' ran
    1.00 ± 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.462 s ±  0.103 s    [User: 41.777 s, System: 0.940 s]
  Range (min … max):   11.389 s … 11.535 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     11.163 s ±  0.026 s    [User: 41.722 s, System: 0.941 s]
  Range (min … max):   11.145 s … 11.182 s    2 runs
 
Summary
  'hyper_threading_pr threads: 6' ran
    1.03 ± 0.01 times faster than 'hyper_threading_main 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.078 s ±  0.017 s    [User: 42.450 s, System: 0.958 s]
  Range (min … max):   11.066 s … 11.090 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     11.553 s ±  0.513 s    [User: 41.488 s, System: 0.947 s]
  Range (min … max):   11.191 s … 11.916 s    2 runs
 
Summary
  'hyper_threading_main threads: 8' ran
    1.04 ± 0.05 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.192 s ±  0.128 s    [User: 42.603 s, System: 1.046 s]
  Range (min … max):   11.101 s … 11.282 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     11.291 s ±  0.032 s    [User: 42.472 s, System: 1.035 s]
  Range (min … max):   11.268 s … 11.313 s    2 runs
 
Summary
  'hyper_threading_main threads: 16' ran
    1.01 ± 0.01 times faster than 'hyper_threading_pr 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.337 ± 0.046 2.288 2.444 1.01 ± 0.02
head big_factorial 2.321 ± 0.021 2.297 2.360 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.303 ± 0.060 2.252 2.460 1.01 ± 0.03
head big_fibonacci 2.277 ± 0.050 2.227 2.372 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 8.168 ± 0.087 8.017 8.253 1.00
head blake2s_integration_benchmark 8.222 ± 0.205 8.074 8.758 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.468 ± 0.054 2.405 2.610 1.00
head compare_arrays_200000 2.473 ± 0.048 2.431 2.556 1.00 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.598 ± 0.010 1.578 1.612 1.00 ± 0.01
head dict_integration_benchmark 1.594 ± 0.012 1.574 1.622 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.326 ± 0.014 1.310 1.348 1.00
head field_arithmetic_get_square_benchmark 1.344 ± 0.035 1.313 1.398 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.259 ± 0.118 8.134 8.427 1.00 ± 0.02
head integration_builtins 8.257 ± 0.094 8.134 8.368 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.488 ± 0.093 8.367 8.655 1.00 ± 0.02
head keccak_integration_benchmark 8.484 ± 0.115 8.337 8.626 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.419 ± 0.079 2.365 2.618 1.00 ± 0.04
head linear_search 2.409 ± 0.029 2.380 2.477 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.685 ± 0.023 1.661 1.732 1.01 ± 0.02
head math_cmp_and_pow_integration_benchmark 1.673 ± 0.027 1.649 1.744 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.621 ± 0.020 1.595 1.666 1.00 ± 0.01
head math_integration_benchmark 1.614 ± 0.009 1.600 1.628 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.355 ± 0.011 1.337 1.370 1.00
head memory_integration_benchmark 1.360 ± 0.034 1.329 1.452 1.00 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.768 ± 0.037 1.726 1.835 1.01 ± 0.02
head operations_with_data_structures_benchmarks 1.745 ± 0.019 1.726 1.794 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 567.9 ± 9.4 561.0 593.9 1.00
head pedersen 569.1 ± 4.3 564.0 579.9 1.00 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 688.3 ± 3.7 680.1 693.1 1.00 ± 0.01
head poseidon_integration_benchmark 686.8 ± 5.5 672.9 692.6 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.971 ± 0.019 1.953 2.017 1.00
head secp_integration_benchmark 1.983 ± 0.013 1.966 2.011 1.01 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 678.2 ± 13.4 669.2 714.3 1.00
head set_integration_benchmark 696.2 ± 3.2 691.3 701.2 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.613 ± 0.037 4.547 4.658 1.00
head uint256_integration_benchmark 4.690 ± 0.251 4.561 5.400 1.02 ± 0.06

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 95.66929% with 11 lines in your changes missing coverage. Please review.

Project coverage is 96.31%. Comparing base (7d19956) to head (6bb12ef).

Files with missing lines Patch % Lines
...c/hint_processor/cairo_1_hint_processor/circuit.rs 95.95% 8 Missing ⚠️
...processor/cairo_1_hint_processor/hint_processor.rs 90.90% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1843    +/-   ##
========================================
  Coverage   96.30%   96.31%            
========================================
  Files         101      101            
  Lines       40225    40471   +246     
========================================
+ Hits        38740    38980   +240     
- Misses       1485     1491     +6     
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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