zkmopro / mopro

Making client-side proving on mobile simple.
https://zkmopro.org
Apache License 2.0
118 stars 32 forks source link

test(msm): ci test for msm benchmarks and correctness within proper time #166

Closed moven0831 closed 3 months ago

moven0831 commented 3 months ago

Issue

The current candidate choice for the MSM benchmarking test takes too long. Specifically, running the command below without the --release tag introduces significant time delays when generating the benchmarking instance:

cargo test --features=gpu-benchmarks test_benchmark_msm

This PR

This PR introduces a lightweight benchmark test using smaller instances, specifically size of 2^10. This allows the tests to be completed within 60 seconds on M3 chips, even without the --release flag. Additionally, it includes a test to verify the correctness of the MSM results using both Arkworks built-in EC arithmetic and Arkworks MSM as the expected MSM result.

Changes

CI test command

For the the CI tests, use the following command:

cargo test --package mopro-core --features=gpu-benchmarks test_msm_correctness
vivianjeng commented 3 months ago

you can also add it in https://github.com/zkmopro/mopro/blob/main/.github/workflows/build-and-test.yml 🙏🏻

cloudflare-workers-and-pages[bot] commented 3 months ago

Deploying mopro with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4c3e2cc
Status: ✅  Deploy successful!
Preview URL: https://547b0d4f.mopro.pages.dev
Branch Preview URL: https://test-ci-test-for-msm.mopro.pages.dev

View logs

FoodChain1028 commented 3 months ago

@moven0831 This command cargo test --package mopro-core --features=gpu-benchmarks test_msm_correctness would run 3 tests and the third one runs with a very long time. should we make the instance size smaller?

running 3 tests
test middleware::gpu_explorations::arkworks_pippenger::tests::test_msm_correctness_small_sample ... ok
test middleware::gpu_explorations::metal::msm::tests::test_msm_correctness_small_sample ... ok
moven0831 commented 3 months ago

@moven0831 This command cargo test --package mopro-core --features=gpu-benchmarks test_msm_correctness would run 3 tests and the third one runs with a very long time. should we make the instance size smaller?

running 3 tests
test middleware::gpu_explorations::arkworks_pippenger::tests::test_msm_correctness_small_sample ... ok
test middleware::gpu_explorations::metal::msm::tests::test_msm_correctness_small_sample ... ok

I've adjusted the instance size from 2^10 to 2^8 and should be faster new. It takes nearly 70 sec to complete on my PC (M3 chip).

vivianjeng commented 3 months ago

I think you can try the macos machine

    gpu-benchmarks:
        runs-on: macos-latest
        steps:
            - uses: actions/checkout@v4
            - name: Run GPU Benchmarks tests
              run: |
                  cd mopro-core
                  cargo test --features=gpu-benchmarks test_msm_correctness -- --nocapture