Skip to content

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

@github-actions
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 ± σ):     26.246 s ±  0.035 s    [User: 25.491 s, System: 0.754 s]
  Range (min … max):   26.221 s … 26.270 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     26.376 s ±  0.153 s    [User: 25.617 s, System: 0.758 s]
  Range (min … max):   26.267 s … 26.484 s    2 runs
 
Summary
  hyper_threading_main threads: 1 ran
    1.00 ± 0.01 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 ± σ):     14.644 s ±  0.062 s    [User: 25.695 s, System: 0.786 s]
  Range (min … max):   14.600 s … 14.688 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.587 s ±  0.008 s    [User: 25.624 s, System: 0.800 s]
  Range (min … max):   14.581 s … 14.593 s    2 runs
 
Summary
  hyper_threading_pr threads: 2 ran
    1.00 ± 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 ± σ):     10.355 s ±  0.330 s    [User: 37.518 s, System: 0.928 s]
  Range (min … max):   10.122 s … 10.588 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     10.759 s ±  0.262 s    [User: 37.747 s, System: 0.951 s]
  Range (min … max):   10.574 s … 10.945 s    2 runs
 
Summary
  hyper_threading_main threads: 4 ran
    1.04 ± 0.04 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.307 s ±  0.415 s    [User: 37.653 s, System: 0.949 s]
  Range (min … max):   10.013 s … 10.600 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     10.644 s ±  0.114 s    [User: 38.115 s, System: 0.937 s]
  Range (min … max):   10.564 s … 10.724 s    2 runs
 
Summary
  hyper_threading_main threads: 6 ran
    1.03 ± 0.04 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.413 s ±  0.123 s    [User: 37.760 s, System: 0.953 s]
  Range (min … max):   10.326 s … 10.500 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.495 s ±  0.142 s    [User: 38.312 s, System: 0.942 s]
  Range (min … max):   10.395 s … 10.596 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 ± σ):     10.132 s ±  0.035 s    [User: 38.271 s, System: 1.041 s]
  Range (min … max):   10.107 s … 10.156 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.270 s ±  0.054 s    [User: 39.025 s, System: 1.065 s]
  Range (min … max):   10.233 s … 10.308 s    2 runs
 
Summary
  hyper_threading_main threads: 16 ran
    1.01 ± 0.01 times faster than hyper_threading_pr threads: 16


@github-actions
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.125 ± 0.020 2.112 2.180 1.00
head big_factorial 2.137 ± 0.007 2.130 2.151 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.046 ± 0.016 2.030 2.087 1.00
head big_fibonacci 2.066 ± 0.008 2.054 2.079 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.442 ± 0.011 7.420 7.452 1.00
head blake2s_integration_benchmark 7.582 ± 0.068 7.506 7.706 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.194 ± 0.022 2.179 2.256 1.00
head compare_arrays_200000 2.215 ± 0.016 2.197 2.252 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.441 ± 0.004 1.436 1.451 1.00
head dict_integration_benchmark 1.443 ± 0.007 1.436 1.458 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.216 ± 0.007 1.205 1.230 1.00
head field_arithmetic_get_square_benchmark 1.225 ± 0.006 1.219 1.239 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.581 ± 0.098 7.522 7.851 1.00
head integration_builtins 7.752 ± 0.155 7.640 8.178 1.02 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.841 ± 0.105 7.763 8.061 1.00
head keccak_integration_benchmark 7.920 ± 0.078 7.838 8.110 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.157 ± 0.020 2.146 2.212 1.00
head linear_search 2.177 ± 0.005 2.170 2.188 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.520 ± 0.006 1.515 1.534 1.00
head math_cmp_and_pow_integration_benchmark 1.522 ± 0.005 1.513 1.533 1.00 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.467 ± 0.008 1.456 1.482 1.00 ± 0.01
head math_integration_benchmark 1.466 ± 0.011 1.456 1.491 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.225 ± 0.024 1.211 1.289 1.00
head memory_integration_benchmark 1.229 ± 0.016 1.217 1.264 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.581 ± 0.016 1.568 1.614 1.00
head operations_with_data_structures_benchmarks 1.585 ± 0.006 1.575 1.598 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 534.1 ± 0.7 533.0 535.2 1.00
head pedersen 536.9 ± 0.7 535.6 538.2 1.01 ± 0.00
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 643.3 ± 2.9 639.5 648.7 1.00 ± 0.01
head poseidon_integration_benchmark 643.2 ± 3.7 638.3 649.9 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.845 ± 0.005 1.837 1.856 1.00
head secp_integration_benchmark 1.857 ± 0.007 1.849 1.874 1.01 ± 0.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 628.8 ± 1.9 626.6 632.1 1.00
head set_integration_benchmark 686.2 ± 6.8 680.6 702.4 1.09 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.200 ± 0.014 4.177 4.220 1.00
head uint256_integration_benchmark 4.230 ± 0.047 4.206 4.362 1.01 ± 0.01

@codecov
Copy link

codecov bot commented Feb 16, 2025

Codecov Report

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

Project coverage is 96.53%. Comparing base (b427a3e) to head (077da8d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
vm/src/vm/runners/cairo_runner.rs 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1957      +/-   ##
==========================================
+ Coverage   96.46%   96.53%   +0.06%     
==========================================
  Files         103      103              
  Lines       42507    42586      +79     
==========================================
+ Hits        41005    41109     +104     
+ 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
Copy link
Collaborator

@yuvalsw yuvalsw 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 1 of 5 files at r1, 2 of 3 files at r2, 1 of 1 files at r3, 1 of 1 files at r6, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, and @pefontana)


vm/src/types/instance_definitions/builtins_instance_def.rs line 182 at r7 (raw file):

    }

    pub(crate) fn all_cairo_stwo() -> BuiltinsInstanceDef {

I am not familiar enough with the requirements of the ratios (in relation to one another in a single layout) - does it make sense to just take an existing layout and change some builtins to none?


vm/src/types/instance_definitions/builtins_instance_def.rs line 399 at r7 (raw file):

        assert!(builtins.ec_op.is_some());
        assert!(builtins.keccak.is_some());
        assert!(builtins.poseidon.is_some());

consider adding here the mod_builitins check as in in the all_cairo_stwo test below


vm/src/vm/runners/cairo_runner.rs line 3402 at r7 (raw file):

    #[test]
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
    fn run_empty() {

rename to run_empty_all_cairo

@YairVaknin-starkware YairVaknin-starkware changed the base branch from yuval/fix_warnings to main March 9, 2025 17:02
@YairVaknin-starkware YairVaknin-starkware force-pushed the yaiv/add_all_cairo_stwo_layout branch from 5c8f96f to 34d3496 Compare March 9, 2025 17:04
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, 1 unresolved discussion (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @yuvalsw)


vm/src/types/instance_definitions/builtins_instance_def.rs line 182 at r7 (raw file):

Previously, yuvalsw wrote…

I am not familiar enough with the requirements of the ratios (in relation to one another in a single layout) - does it make sense to just take an existing layout and change some builtins to none?

Yeah, since it's not a layout used in a stone proof later. We only care about the pointer init of the builtins we support.

@edg-l edg-l requested a review from noaov1 as a code owner March 10, 2025 10:09
@edg-l edg-l enabled auto-merge March 10, 2025 10:10
@edg-l edg-l added this pull request to the merge queue Mar 10, 2025
Merged via the queue into main with commit 1f472cf Mar 10, 2025
93 checks passed
@edg-l edg-l deleted the yaiv/add_all_cairo_stwo_layout branch March 10, 2025 11:06
Copy link
Collaborator

@yuvalsw yuvalsw left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

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.

6 participants