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

accelerate wit_infer_by_expr via grid-strde-loop & vector pool #775

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

hero78119
Copy link
Collaborator

@hero78119 hero78119 commented Dec 19, 2024

related #772

This PR re-design wit_infer_by_expr to try grid-strde-loop traverse + reuse a simple vector pool to make vector reuse across closure of expression evaluation. This design is aiming to avoid massively interface change.

highlight of change

  • introduce a simple vector pool to maximize vector reuse during expression evaluation, as we can't just allocated a simple vector and mutable it, due to the expression degree > 0, thus inevitable there will be intermediate poly.

    the evaluation of read/write/lookup expression also changed to sequential, so can maximize the vector pool utilization.

  • refactor wit_infer_by_expr to use grid-strde-loop style and maximize cpu cache hit rate. vector are updated concurrently with SyncUnsafeCell, which require nightly feature #![feature(sync_unsafe_cell)].

    SyncUnsafeCell is just an UnsafeCell in stable, except it implements Sync if T implements Sync.

benchmark

with command

cargo bench --bench fibonacci --package ceno_zkvm -- --baseline baseline

on ceno server (16 cores, 32 HT) fibonacci e2e latency reduce ~13%

fibonacci_max_steps_1048576/prove_fibonacci/fibonacci_max_steps_1048576
                        time:   [4.1685 s 4.1951 s 4.2220 s]
                        change: [-15.436% -13.927% -12.397%] (p = 0.00 < 0.05)
                        Performance has improved.

@hero78119 hero78119 marked this pull request as draft December 19, 2024 04:10
@hero78119
Copy link
Collaborator Author

hero78119 commented Dec 19, 2024

There are many code redundant since I still do the experiment and see what the best design and avoid massive change its done and cleanup

@hero78119 hero78119 marked this pull request as ready for review December 19, 2024 12:17
@hero78119 hero78119 changed the title accelerate wit_infer_by_expr via grid-strde-loop + vector pool accelerate wit_infer_by_expr via grid-strde-loop & vector pool Dec 19, 2024
@hero78119
Copy link
Collaborator Author

It seems I am test on the wrong branch, will update it once benchmark result is confirmed

@hero78119 hero78119 marked this pull request as draft December 20, 2024 14:40
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.

1 participant