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

Add_all_cairo_stwo_layout #1957

Open
wants to merge 1 commit into
base: yuval/fix_warnings
Choose a base branch
from

Conversation

YairVaknin-starkware
Copy link
Collaborator

@YairVaknin-starkware YairVaknin-starkware commented Feb 16, 2025

TITLE

Adding all_cairo_stwo layout

Description

Adding a layout to the vm that includes all builtins supported by stwo.

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.

This change is Reviewable

Copy link

github-actions bot commented Feb 16, 2025

**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 ± σ):     27.408 s ±  0.269 s    [User: 26.619 s, System: 0.787 s]
  Range (min … max):   27.218 s … 27.598 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     26.850 s ±  0.013 s    [User: 26.056 s, System: 0.793 s]
  Range (min … max):   26.841 s … 26.859 s    2 runs
 
Summary
  hyper_threading_pr threads: 1 ran
    1.02 ± 0.01 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 ± σ):     14.982 s ±  0.074 s    [User: 26.399 s, System: 0.799 s]
  Range (min … max):   14.930 s … 15.035 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.862 s ±  0.020 s    [User: 26.151 s, System: 0.752 s]
  Range (min … max):   14.848 s … 14.876 s    2 runs
 
Summary
  hyper_threading_pr threads: 2 ran
    1.01 ± 0.01 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 ± σ):     10.950 s ±  0.251 s    [User: 39.157 s, System: 0.909 s]
  Range (min … max):   10.773 s … 11.128 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     11.007 s ±  0.565 s    [User: 40.040 s, System: 0.956 s]
  Range (min … max):   10.607 s … 11.406 s    2 runs
 
Summary
  hyper_threading_main threads: 4 ran
    1.01 ± 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 ± σ):     10.711 s ±  0.138 s    [User: 39.789 s, System: 0.916 s]
  Range (min … max):   10.614 s … 10.808 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     11.098 s ±  0.039 s    [User: 39.618 s, System: 0.946 s]
  Range (min … max):   11.070 s … 11.125 s    2 runs
 
Summary
  hyper_threading_main threads: 6 ran
    1.04 ± 0.01 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 ± σ):     10.875 s ±  0.106 s    [User: 39.575 s, System: 0.945 s]
  Range (min … max):   10.800 s … 10.950 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.887 s ±  0.037 s    [User: 40.165 s, System: 0.954 s]
  Range (min … max):   10.861 s … 10.913 s    2 runs
 
Summary
  hyper_threading_main threads: 8 ran
    1.00 ± 0.01 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 ± σ):     10.627 s ±  0.107 s    [User: 40.160 s, System: 1.055 s]
  Range (min … max):   10.552 s … 10.703 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.841 s ±  0.007 s    [User: 40.402 s, System: 1.051 s]
  Range (min … max):   10.836 s … 10.846 s    2 runs
 
Summary
  hyper_threading_main threads: 16 ran
    1.02 ± 0.01 times faster than hyper_threading_pr threads: 16


Copy link

github-actions bot commented Feb 16, 2025

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.181 ± 0.029 2.148 2.234 1.00
head big_factorial 2.221 ± 0.048 2.173 2.341 1.02 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.117 ± 0.017 2.097 2.140 1.00 ± 0.01
head big_fibonacci 2.108 ± 0.014 2.092 2.140 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.800 ± 0.059 7.731 7.892 1.00
head blake2s_integration_benchmark 7.991 ± 0.145 7.810 8.230 1.02 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.246 ± 0.019 2.224 2.281 1.00
head compare_arrays_200000 2.247 ± 0.011 2.231 2.264 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.484 ± 0.013 1.470 1.506 1.01 ± 0.01
head dict_integration_benchmark 1.476 ± 0.011 1.459 1.494 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.268 ± 0.037 1.248 1.372 1.01 ± 0.03
head field_arithmetic_get_square_benchmark 1.261 ± 0.005 1.256 1.272 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.875 ± 0.065 7.813 7.990 1.00
head integration_builtins 7.948 ± 0.101 7.850 8.205 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.183 ± 0.222 8.030 8.622 1.00
head keccak_integration_benchmark 8.188 ± 0.045 8.112 8.241 1.00 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.239 ± 0.043 2.200 2.344 1.00 ± 0.02
head linear_search 2.232 ± 0.016 2.209 2.265 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.554 ± 0.007 1.545 1.568 1.00
head math_cmp_and_pow_integration_benchmark 1.562 ± 0.007 1.553 1.572 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.520 ± 0.025 1.502 1.573 1.00 ± 0.02
head math_integration_benchmark 1.516 ± 0.014 1.503 1.554 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.246 ± 0.017 1.231 1.290 1.00
head memory_integration_benchmark 1.247 ± 0.016 1.231 1.283 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.628 ± 0.022 1.610 1.689 1.00 ± 0.01
head operations_with_data_structures_benchmarks 1.622 ± 0.007 1.612 1.635 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 538.5 ± 1.7 536.6 540.4 1.00
head pedersen 539.6 ± 2.6 536.4 544.0 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 648.7 ± 3.4 643.4 655.0 1.00
head poseidon_integration_benchmark 650.6 ± 4.6 642.3 654.7 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.899 ± 0.009 1.886 1.911 1.00 ± 0.01
head secp_integration_benchmark 1.898 ± 0.003 1.895 1.905 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 680.2 ± 3.2 676.9 687.5 1.00
head set_integration_benchmark 681.6 ± 3.5 677.4 686.7 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.377 ± 0.035 4.334 4.425 1.00
head uint256_integration_benchmark 4.395 ± 0.027 4.342 4.427 1.00 ± 0.01

Copy link

codecov bot commented Feb 16, 2025

Codecov Report

Attention: Patch coverage is 97.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.53%. Comparing base (441cc4e) to head (5c8f96f).

Files with missing lines Patch % Lines
vm/src/vm/runners/cairo_runner.rs 85.71% 2 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           yuval/fix_warnings    #1957      +/-   ##
======================================================
+ Coverage               96.46%   96.53%   +0.06%     
======================================================
  Files                     103      103              
  Lines                   42510    42585      +75     
======================================================
+ Hits                    41008    41108     +100     
+ Misses                   1502     1477      -25     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@YairVaknin-starkware YairVaknin-starkware force-pushed the yaiv/add_all_cairo_stwo_layout branch from bc25090 to 6182e1f Compare February 17, 2025 07:04
Copy link
Collaborator

@OmriEshhar1 OmriEshhar1 left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @yuvalsw)


vm/src/types/instance_definitions/builtins_instance_def.rs line 401 at r1 (raw file):

        assert!(builtins.poseidon.is_some());
    }

add get_builtins_all_cairo_stwo() test?


vm/src/types/layout.rs line 470 at r1 (raw file):

        );
    }

add get_all_cairo_stwo_instance() test?

Copy link
Collaborator Author

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @OmriEshhar1, @Oppen, @pefontana, and @yuvalsw)


vm/src/types/layout.rs line 470 at r1 (raw file):

Previously, OmriEshhar1 wrote…

add get_all_cairo_stwo_instance() test?

yeah, they are ready. will post later. I pushed without any tests to see where CI fails and then add all at once.

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

Hi @YairVaknin-starkware! The codecov workflow seems to be failing. Could you add some unit tests? You can use an an example these tests:

  • #[test]
    fn get_builtins_all_solidity() {
    let builtins = BuiltinsInstanceDef::all_solidity();
    assert!(builtins.output);
    assert!(builtins.pedersen.is_some());
    assert!(builtins.range_check.is_some());
    assert!(builtins.ecdsa.is_some());
    assert!(builtins.bitwise.is_some());
    assert!(builtins.ec_op.is_some());
    assert!(builtins.keccak.is_none());
    assert!(builtins.poseidon.is_none());
    }
  • fn get_all_solidity_instance() {
    let layout = CairoLayout::all_solidity_instance();
    let builtins = BuiltinsInstanceDef::all_solidity();
    assert_eq!(layout.name, LayoutName::all_solidity);
    assert_eq!(layout.rc_units, 8);
    assert_eq!(layout.builtins, builtins);
    assert_eq!(layout.public_memory_fraction, 8);
    assert_eq!(
    layout.diluted_pool_instance_def,
    Some(DilutedPoolInstanceDef::default())
    );
    }

Copy link
Collaborator Author

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

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

yeah, they are ready. will post later. I pushed without any tests to see where CI fails and then add all at once.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @OmriEshhar1, @Oppen, @pefontana, and @yuvalsw)

@YairVaknin-starkware YairVaknin-starkware force-pushed the yaiv/add_all_cairo_stwo_layout branch from 6182e1f to 1b8e606 Compare February 17, 2025 16:48
Copy link
Collaborator Author

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

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

Done @JulianGCalderon

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @OmriEshhar1, @Oppen, @pefontana, and @yuvalsw)


vm/src/types/layout.rs line 470 at r1 (raw file):

Previously, YairVaknin-starkware wrote…

yeah, they are ready. will post later. I pushed without any tests to see where CI fails and then add all at once.

Done


vm/src/types/instance_definitions/builtins_instance_def.rs line 401 at r1 (raw file):

Previously, OmriEshhar1 wrote…

add get_builtins_all_cairo_stwo() test?

Done.

@YairVaknin-starkware YairVaknin-starkware force-pushed the yaiv/add_all_cairo_stwo_layout branch from 1b8e606 to d2ab417 Compare February 17, 2025 17:23
Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@OmriEshhar1 OmriEshhar1 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @yuvalsw)

@YairVaknin-starkware YairVaknin-starkware force-pushed the yaiv/add_all_cairo_stwo_layout branch 2 times, most recently from d39f68c to bdce4f0 Compare March 4, 2025 15:50
@YairVaknin-starkware YairVaknin-starkware changed the base branch from main to yuval/fix_warnings March 4, 2025 15:52
@OmriEshhar1 OmriEshhar1 force-pushed the yaiv/add_all_cairo_stwo_layout branch 2 times, most recently from ad19ba2 to 5ec3568 Compare March 6, 2025 08:18
Copy link
Collaborator

@OmriEshhar1 OmriEshhar1 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @yuvalsw)

@YairVaknin-starkware YairVaknin-starkware force-pushed the yaiv/add_all_cairo_stwo_layout branch from 5ec3568 to 5c8f96f Compare March 6, 2025 08:45
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.

3 participants