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

feat(msm-gpu-exploration): integrate zprize msm #128

Merged
merged 30 commits into from
Apr 19, 2024

Conversation

FoodChain1028
Copy link
Collaborator

Overall

@moven0831 and I integrated the work of TrapdoorTech in zprize into mopro-core, mopro-ffi and run the benchmark on my iphone 14 pro.

And here is the result:
Result running on FoodChain's Iphone 14 pro

logging:

    Average time to execute MSM with 65536 points and scalars in 1 iterations is: 195.635083ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 206.639791ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 205.1675ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 197.742167ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 207.147166ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 199.729459ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 203.080416ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 198.15875ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 201.636916ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 210.273792ms
Done running benchmark. Check the result at: "../mopro-core/benchmarks/gpu_explorations"
Result of Arkwork (Baseline): 202.52110399999998 ms (diff: 0.0 %)
Running MSM in algorithm: TrapdoorTech Zprize...
Vectors already generated
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 470.619458ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 470.25775ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 471.028792ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 470.972375ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 471.092292ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 470.932375ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 471.304875ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 471.343375ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 470.9955ms
Average time to execute MSM with 65536 points and scalars in 1 iterations is: 470.738208ms
Done running benchmark. Check the result at: mopro-core/"../mopro-core/benchmarks/gpu_explorations"
Result of TrapdoorTech Zprize: 470.9284999999999 ms (diff: -132.53304998771878 %)

result screenshot:
MSM result on iphone 14 pro

  • TrapdoorTech Zprize work was done in 2022, and the arkworks components they used were in version 0.3.
  • arkworks MSM algorithm (version: 0.4) has been modified and probably taken some of the awarded algorithm in zprize as references, so that is why runs faster than the old work as shown in the result.

Report

related issue

#22

@oskarth oskarth requested a review from vivianjeng April 16, 2024 10:19
Copy link
Collaborator

@oskarth oskarth left a comment

Choose a reason for hiding this comment

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

Nice one!

Left some minor comments above.

Could we add links to hackmds from gpu_explorations folder README.md? Just for people exploring this randomly to see context

Cargo.toml Outdated
@@ -7,3 +7,10 @@ exclude = ["mopro-cli-example"]
# NOTE: Forked wasmer to work around memory limits
# See https://github.com/wasmerio/wasmer/commit/09c7070
wasmer = { git = "https://github.com/oskarth/wasmer.git", rev = "09c7070" }

# NOTE: For gpu exploration on zprize works
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we put all of these under the gpu explorations feature flag perhaps? As optional

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've added optional = true for the patch in commits fc0c972, which will only be included when --features=gpu-benchmarks is activated.

@@ -921,6 +921,15 @@ public func add(a: UInt32, b: UInt32) -> UInt32 {
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI we will probably get rid of mopro-ios and use mopro-cli - perhaps we can initialize a new project with mopro-cli and put in examples/templates?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds great! we will start this template ASAP.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So ideally the whole swift test app will use mopro-cli and in examples/templates?
@oskarth

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes! we have the basic template for simple apps, but benchmarks should probably be separate, can init with mopro-cli init

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @oskarth, maybe we will create one after this PR since we have to import the msm functions from this PR

@FoodChain1028
Copy link
Collaborator Author

Hi @oskarth

Could we add links to hackmds from gpu_explorations folder README.md? Just for people exploring this randomly to see context

I think add a README.md in the gpu-exploration folder would be great for that, which would include reports and the steps to benchmark.

@oskarth
Copy link
Collaborator

oskarth commented Apr 18, 2024

iOS CI failing, not sure why

Copy link
Collaborator

@moven0831 moven0831 left a comment

Choose a reason for hiding this comment

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

The CI tests have passed for now (arkworks pippenger in 0.4 version and TrapdoorTech's work in zprize 2022). We're going to do more benchmarks on other MSM algorithms such as icicle and halo2curves implementation on the CPU.

Comment on lines +14 to +31
// let pointUrl = URL(string: "https://mopro-msm.s3.eu-north-1.amazonaws.com/vectors/16x10/points")
// let scalarUrl = URL(string: "https://mopro-msm.s3.eu-north-1.amazonaws.com/vectors/16x10/scalars")
// func runDownloadAction() {
// let pointStart = CFAbsoluteTimeGetCurrent()
// FileDownloader.loadFileAsync(url: self.pointUrl!) { (path, error) in
// print("Points File downloaded to : \(path!)")
// let pointEnd = CFAbsoluteTimeGetCurrent()
// print("Download points took:", pointEnd - pointStart, "s")
// }

// let scalarStart = CFAbsoluteTimeGetCurrent()
// FileDownloader.loadFileAsync(url: self.scalarUrl!) { (path, error) in
// print("Scalars File downloaded to : \(path!)")
// let scalarEnd = CFAbsoluteTimeGetCurrent()
// print("Download scalars took:", scalarEnd - scalarStart, "s")
// }

// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we can confirm that the benchmarking instances can always be generated on both iOS simulator and mobile device, we should consider removing these comments in the later PR.

@oskarth oskarth merged commit a8b95da into main Apr 19, 2024
6 checks passed
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